I saw previous SO posts 1, 2 etc. I want to pass a preprocessor directive at compile time. With scons, I could do:
num_times = ARGUMENTS.get('c', 1)
env.Append(CCFLAGS = '-DNUM_TIMES=%d' % int(num_times))
I hope, it should also be possible using make. I want to issue
make c=4
or something like that. Can someone suggest a method. I am compiling a folder, which has subfolders with their own makefiles. Thanks in advance.
One simple approach is to do:
call with
make c=2, and not to touchCFLAGSin the sub-folder makefiles.Another is to have a
Makefilepart in your root folder with all the common settings that youincludein your subdirectory makefiles (withinclude). ($(MAKE)ensures that the command line arguments you gave tomakewill also be passed to sub-makes.)