Reputation: 7708
Works:
make -f Makefile.custom CFLAGS="-DFLAG_ONE -DFLAG_TWO" clean target
What does not work is
FLAGS="-DFLAG_ONE -DFLAG_TWO"
make -f Makefile.custom CFLAGS=$FLAGS clean target
Error: It starts to think that -D is an argument to make and fails.
Tried: Using escape characters
FLAGS="\"-DFLAG_ONE -DFLAG_TWO\""
Any help would be appreciated.
--UPDATE--
This is a workaround but the question still remains open.
CFLAGS="-DFLAG_ONE -DFLAG_TWO"
export CFLAGS
make -f Makefile.custom clean target
Upvotes: 0
Views: 183
Reputation: 212356
Quoting is necessary:
FLAGS="-DFLAG_ONE -DFLAG_TWO"
make -f Makefile.custom CFLAGS="$FLAGS" clean target
Upvotes: 1
Reputation: 789
CFLAGS="-DFLAG_ONE -DFLAG_TWO" make -f Makefile.custom clean target
And simple Makefile:
all:
echo ${CFLAGS}
...will print:
-DFLAG_ONE -DFLAG_TWO
...thus it does work.
Upvotes: 1