Define compilation variables based on target for

后端 未结 3 1194
刺人心
刺人心 2020-12-03 15:17

my c++ source file look for a specific variable passed from the makefile. when making a different target, this variable definition is different.

How can I define a

3条回答
  •  误落风尘
    2020-12-03 16:18

    You can use target-specific variable values, they propagate to target's prerequisites:

    all : foo bar
    foo : CXXFLAGS += -DFOO
    bar : CXXFLAGS += -DBAR
    
    foo bar :
        @echo target=$@ CXXFLAGS=${CXXFLAGS}
    
    .PHONY : all
    

提交回复
热议问题