如何将变量有条件地附加到Makefile目标内的变量改写成长尾词?

2026-04-16 17:082阅读0评论SEO资讯
  • 内容介绍
  • 相关推荐

本文共计194个文字,预计阅读时间需要1分钟。

如何将变量有条件地附加到Makefile目标内的变量改写成长尾词?

我有这样一个看起来有点像GNU Makefile的东西:

LIST=item1.PHONY: targetMain targetA targetB preA preBtargetMain: targetA targetB preA preB

我有一个看起来有点像这样的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

如何将变量有条件地附加到Makefile目标内的变量改写成长尾词?

本文共计194个文字,预计阅读时间需要1分钟。

如何将变量有条件地附加到Makefile目标内的变量改写成长尾词?

我有这样一个看起来有点像GNU Makefile的东西:

LIST=item1.PHONY: targetMain targetA targetB preA preBtargetMain: targetA targetB preA preB

我有一个看起来有点像这样的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

如何将变量有条件地附加到Makefile目标内的变量改写成长尾词?