根据目标定义编译变量 [英] Define compilation variables based on target for

查看:48
本文介绍了根据目标定义编译变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的c ++源文件查找从makefile传递的特定变量.当创建不同的目标时,此变量定义是不同的.

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

如何根据目标在Makefile中定义变量.

How can I define a variable in Makefile based on target.

谢谢

推荐答案

您可以使用

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

这篇关于根据目标定义编译变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆