Reputation: 1763
I have a makefile include local.mk
which define a variable DEFS
. I hope to append that variable from command.
Here is what I have tried.
local.mk:
DEFS += -DVAR1
Makefile:
DEFS ?=
$(info ${DEFS})
include local.mk
$(info ${DEFS})
test:
echo ${DEFS}
When I run:
make DEFS+=-DVAR2
I expect to get -DVAR1 -DVAR2
but I only got -DVAR2
.
How could I append DEFS
variable instead of override it from command line?
Upvotes: 1
Views: 673
Reputation: 81012
I feel like this should be possible done the way you are trying but I'm having trouble getting the details straight in my head at the moment.
That being said you can do this instead:
DEFS=-DVAR2 make
and get what you want (order aside)
$ DEFS=-DVAR2 make -f start.mk
DEFS=-DVAR2
DEFS=-DVAR2 -DVAR1
echo '-DVAR2 -DVAR1'
-DVAR2 -DVAR1
Upvotes: 1