加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

变量 – 有条件地附加到Makefile目标内的变量

发布时间:2020-12-16 09:26:06 所属栏目:百科 来源:网络整理
导读:我有一个看起来有点像这样的GNU Makefile: LIST = item1.PHONY: targetMain targetA targetB preA preBtargetMain:# DO all the work in here echo $(LIST)targetA: preA targetMaintargetB: preB targetMainpreA:LIST += itemApreB:LIST += itemB 我的想法
我有一个看起来有点像这样的GNU Makefile:

LIST = item1

.PHONY: targetMain targetA targetB preA preB

targetMain:
# DO all the work in here
    echo $(LIST)

targetA: preA targetMain
targetB: preB targetMain

preA:
LIST += itemA

preB:
LIST += itemB

我的想法是运行make targetA或make targetB.他们两个都做了非常类似的事情,但有一个不同的项目列表.问题是变量没有有条件地附加到,它总是附加到,这意味着我的输出始终是“item1 itemA itemB”.

我如何有条件地附加到变量?

解决方法

LIST = item1

.PHONY: targetMain targetA targetB

targetMain:
# DO all the work in here
    echo $(LIST)

targetA: LIST+=itemA
targetB: LIST+=itemB

targetA targetB: targetMain

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读