Hi,

I have a c file foo.c:

 

int main(void)

{

#ifdef FOO

printf("FOO!\n");

#endif

#ifdef BAR

printf("BAR!\n");

#endif

return 0;

 

}

 

and a Makefile may be like this:

CPPFLAGS=-DFOO

a.out:foo.o

        gcc -o $@ $^

%.o:%.c

        gcc -c $< ${CPPFLAGS}

 

if I make it and run a.out (I am on a GNU Make 3.81), the output is

FOO!. If I want to print out BAR! or FOO!BAR!, I could always append -

DBAR onto CPPFLAGS.

 

So, my question is: what if I want to append -DBAR on the command

line?

 

I tried: make CPPFLAGS+=-DBAR

But it will completely replace the defined CPPFLAGS in the Makefile.

Obviously, the one defined on the command line has the precedence.

 

Is this doable through command line arguments to make?

 

Many thanks!

_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to