开发者

Change a variable based on a target in Makefile

开发者 https://www.devze.com 2023-03-31 19:58 出处:网络
How can I change the value of a variable based on one of the targets in Makefile? Something link this:

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

精彩评论

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

关注公众号