Compilation error

Dear all,

I stumbled upon a small hiccup during compilation of LAMMPS (14Mar15):
when I try to use Make.py with any flag (except -h) I get the error:

ERROR: Makefile variable objdir appears more than once

To fix it I changed lines 31, 35 and 39 of src/Makefile adding
indentation to the the lines.
Hope this can be useful to someone else,

P

Dear all,

I stumbled upon a small hiccup during compilation of LAMMPS (14Mar15):
when I try to use Make.py with any flag (except -h) I get the error:

ERROR: Makefile variable objdir appears more than once

To fix it I changed lines 31, 35 and 39 of src/Makefile adding
indentation to the the lines.

this doesn't make much sense. the syntax of those lines is correct as
it is. it is more likely that your make program doesn't understand
some of the constructs used in the makefile properly.

can you compile directly from the unmodified makefile using plain make
(not using Make.py)?
if yes, can you correctly also compile the shared library version (mode=shlib)?

what OS/version are you compiling on?
what do you get with:

make -v
uname -a

thanks,
     axel.

Dear all,

I stumbled upon a small hiccup during compilation of LAMMPS (14Mar15):
when I try to use Make.py with any flag (except -h) I get the error:

ERROR: Makefile variable objdir appears more than once

To fix it I changed lines 31, 35 and 39 of src/Makefile adding
indentation to the the lines.

this doesn't make much sense. the syntax of those lines is correct as
it is. it is more likely that your make program doesn't understand
some of the constructs used in the makefile properly.

Well, I thought the the body of the condition needed to be indented,
but probably is either superfluous or ancient syntax.

can you compile directly from the unmodified makefile using plain make
(not using Make.py)?

Yes. For example:

make -j 5 serial

produces a working executable.
(For the record I'm unpacking a new copy for every test)

if yes, can you correctly also compile the shared library version (mode=shlib)?

Yes again.

make -j 5 serial mode=shlib

produces liblammps_serial.so.
And for the record even the Makefile with the indentation of the body
of the ifeq, does.

Still if I do even something like

python Make.py -p rigid

I get the error.

what OS/version are you compiling on?

Linux (Kernel 3.18 x86_64)
GNU Make 4.0 (x86_64-pc-linux-gnu)
Python 2.7.9
gcc 4.8.3

[...]

Well, I thought the the body of the condition needed to be indented,
but probably is either superfluous or ancient syntax.

can you compile directly from the unmodified makefile using plain make
(not using Make.py)?

Yes. For example:

make -j 5 serial

produces a working executable.
(For the record I'm unpacking a new copy for every test)

ok. great. that is what i suspected.

if yes, can you correctly also compile the shared library version (mode=shlib)?

Yes again.

fantastic.

make -j 5 serial mode=shlib

produces liblammps_serial.so.
And for the record even the Makefile with the indentation of the body
of the ifeq, does.

Still if I do even something like

python Make.py -p rigid

I get the error.

ok. considering your observations (and mine), the only conclusion is
that the origin of the problem has to be in Make.py and a quick test
with grep confirms that the error message is actually coming from
Make.py and not from calling make itself. there is code in it that
appears not to be fooled by those conditionals.

axel.

paolo,

please try out the following change to Make.py
this should work around the problem.

axel.

diff --git a/src/Make.py b/src/Make.py
index 29bcd93..9297289 100755
--- a/src/Make.py
+++ b/src/Make.py
@@ -1752,12 +1752,20 @@ class MakeReader:
     newlines = []
     pattern = "(\S+\s+=\s+)(.*)"
     multiline = 0
+ conditional = 0
     self.ccindex = self.lmpindex = 0

     for line in lines:
       line = line[:-1]
       if "CC =" in line: self.ccindex = len(newlines)
       if "LAMMPS-specific settings" in line: self.lmpindex = len(newlines)
+ if "ifeq" in line:
+ conditional = 1
+ continue
+ if conditional:
+ if "endif" in line:
+ conditional = 0
+ continue
       if multiline:
         if '#' in line: line = line[:line.find('#')]
         morevalues = line.split()

It works, thanks!

This will be in the next patch.

Thanks Axel,

Steve

This will be in the next patch.

steve,

i think there is an error in indentation. i see a difference to my version:

diff --git a/src/Make.py b/src/Make.py
index b6a1303..90869e8 100755
--- a/src/Make.py
+++ b/src/Make.py
@@ -1765,7 +1765,7 @@ class MakeReader:
       if conditional:
         if "endif" in line:
           conditional = 0
- continue
+ continue
       if multiline:
         if '#' in line: line = line[:line.find('#')]
         morevalues = line.split()

the change is meant to make the makefile parser skip all conditionally
included lines completely. with your change, it only skips the
conditionals itself.

ok, will patch again.

Sorry about that,
Steve