make:在先决条件中使用目标特定的变量 [英] make: Using target specific variables in prerequisites
本文介绍了make:在先决条件中使用目标特定的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写Makefile,其中前提条件是使用目标特定变量
I'm trying to write a Makefile where prerequisites using target specific variables
version=
target1: override version=1
target1: package
target2: override version=2
target2: package
package: dir=package-${version}\
package: source
source: src/${version}.c
当我运行时,请使版本变量位于目标软件包中,并且源文件为空.
When i run make the version variable is in target package and source empty.
我做错了什么?
推荐答案
使用
这个答案是错误的,由于 answer 中的解释原因,建议的代码无法使用 UPD.
UPD.
This answer is wrong, the suggested code won't work because of the reasons explained in the answer to a similar question.
TL; DR:目标特定的变量
TL;DR: Target-specific variables take their effect based on the target that make is currently building [1]. Second expansion, in turn, takes place right at the end of the read-in phase [2], before building anything.
感谢 @koniiiik 指出.
这篇关于make:在先决条件中使用目标特定的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文