dodona
November 8, 2017, 3:48pm
1
I need some help.
I use variables and conditionals to build with or without specic libraries. I set
USEAL ?= 1 # get value from cmd, defaults to 1
(see comment)
the conditional is:
ifeq ($(USEAL),1)
LIBS = <any libs>
else
LIBS =
endif
Its amazing that this works when invoked from the command line setting the variable to 1 explicit:
make USEAL=1
However when invoked without setting the variable
make
it doesn't work.
I already defined a test target to print USEAL's default value, which is 1.
It looks like 1 != 1
any idea?
In what way does it "not work"? What actually happens?
dodona
November 8, 2017, 5:46pm
3
USEAL's default value is 1, nevertheless it ignores it as if USEAL's default value would be 0, unless I invoke with USEAL=1.
I've tested it with this Makefile:
USEAL ?= 1
ifeq ($(USEAL),1)
LIBS = qwertyuip
else
LIBS =
endif
all:
echo $(LIBS)
$ make
echo qwertyuip
qwertyuip
$ make USEAL=0
echo
$ make USEAL=1
echo qwertyuip
qwertyuip
$
Seems to work. The problem may be elsewhere, if there's anything to your makefile you haven't posted yet.
dodona
November 9, 2017, 1:53pm
5
Thanks a lot!
I did the same job. Then I carefully copied all the working lines from the test makefile into the real one et voila: it works. The only real difference is that the
VARIABLE ?= DEF.VAL
now is located at the beginning of the makefile, whereas before it was placed somewhat in the middle part.
1 Like