0

I am implementing Non-Recursive Make, using John Graham Cummings example here. I would like to be able to specify specific includes or specific compilation flags, depending on which module I'm compiling.

For instance, say I have directories(and therefore separate Makefiles in) src/lib1 and src/executable. Say I would like to use -std=c++11 for the src/lib1 Makefile compilation, and (for some reason) -std=gnu99 for the src/executable Makefile.

Another example, say I need to include different paths for these directories.

What is the standard way to do this in non-recursive make?

What I have tried so far is something like...

$(MODULE_NAME)_CXXFLAGS:=-std=c++11

$(MODULE_NAME)_INCLUDES:=--I/.

But then the following printit just echos nothing.

printit:
      @echo $($(MODULE_NAME)_INCLUDES)
wizurd
  • 3,541
  • 3
  • 33
  • 50
  • Did what you try not work? In what way did it not work? – Etan Reisner Jul 22 '14 at 16:39
  • Ok, I updated the question. Basically, that variable $(MODULE_NAME)_INCLUDES doesn't seem to hold anything when I echo it out – wizurd Jul 22 '14 at 16:43
  • In what makefile are you putting that printit target? Do you see that print something meaningful if you use `$(info $(MODULE_NAME): $($(MODULE_NAME)_INCLUDES))` in one of the sub-makefiles? – Etan Reisner Jul 22 '14 at 16:48
  • I put the printit in a sub-makefile and the bottom Makefile. Doesn't seem to matter. When I execute that, I get the correct output(the correct include path). The problem is when I try to use that variable $(($MODULE_NAME)_INCLUDES) in a rule in the bottom Makefile. It's just empty – wizurd Jul 22 '14 at 17:07
  • Hm... It certainly seems that JGC left that detail out of the article (though I've only just skimmed it so far). The issue is that at the time of rule application the last assignment to `_MODULE_NAME` is the one that will be in effect. Whatever assignment that happens to be. If you want a rule body to use a specific value for the variable you are going to need to assign it in a target-specific simply-expanded variable or use another such method to force immediate evaluation. – Etan Reisner Jul 22 '14 at 17:15
  • My answer [here](http://stackoverflow.com/a/24707583/258523) is likely to be of some use to you here. – Etan Reisner Jul 22 '14 at 17:17

0 Answers0