开发者

Change a variable based on a target in Makefile

How can I change the value of a variable based on one of the targets in Makefile? Something link this:

target:开发者_开发问答
    DEFINES += -DDEPLOY


If your make is GNU make, target-specific variable might meet the purpose. This facility allows almost the same notation as in the question like the following:

target: DEFINES += -DDEPLOY


 ifeq ($(MAKECMDGOALS),target)
 DEFINES += DDEPLOY
 endif


Maybe something like:

target:
    DEFINES="${DEFINES} -DDEPLOY"

and on the compiler invocation line:

gcc -c blablabla ... ${DEFINES}

Not sure if it work, don't know if it is compatible with every shell...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜