mmtauqir
mmtauqir

Reputation: 9319

Define a pre-processor variable for all the files in make

I have a number of .c and .h files with some parts of the code disabled by putting the code block in pre-processor directives e.g.

#ifdef FOOBAR
// some code that can be compiled if needed by defining FOOBAR in pre-processor.
#endif

No I need to define FOOBAR such that its defined for every file that is compiled by gcc using make.

Is there a way to do this with some option to make or Makefile ?

Thanks.

Upvotes: 10

Views: 13513

Answers (1)

Jens Gustedt
Jens Gustedt

Reputation: 78903

Add the compiler option -DFOOBAR to the make variable CFLAGS

Upvotes: 16

Related Questions