Makefile if语句不使用导出变量求值?
|
这是我其他问题的分支。
为了使导出变量有效,我需要做些特别的事情吗?
因此,我正在从包含另一个位置的主Makefile的Makefile中运行此文件。在此本地Makefile中,我具有:
include /path/to/master/Makefile/
export TOOL = A
现在在我的主Makefile中,我有:
ifeq ( $(TOOL), A )
echo \"Tool A will be run...\"
[syntax for toolA]
else
echo \"Tool B will be run...\"
[syntax for toolB]
endif
但是当我运行gmake时,toolB总是运行!我检查了变量$(TOOL),它显示A。我在做什么错?
谢谢!!
编辑:添加Makefile示例。
对于我的问题,在导出后将include移至解决了我的问题。但是,这是一个现有的Makefile,并且始终将include放在最顶部一直有效!
include语句在本地最高,而所有出口在底部。只有我的新出口线失败。有人知道为什么吗?
本地Makefile
export TOOL A
include /path/to/master/Makefile
export VERSION IMP-IR5
主生成文件
export VERSION IAP-100
ci:
ifeq ( $(TOOL), A )
echo \"Tool A will be run...\"
[syntax for toolA]
echo $(VERSION)
else
echo \"Tool B will be run...\"
[syntax for toolB]
echo $(VERSION)
endif
输出量
echo \"Tool A will be run...\"
Tool A will be run...
echo IMP-IR5
IMP-IR5
但是,如果我将顶部切换到本地Makefile中的行(就像原来一样):
include /path/to/master/Makefile
export TOOL A
export VERSION IMP-IR5
我得到:
echo \"Tool B will be run...\"
Tool B will be run...
echo IMP-IR5
IMP-IR5
为什么IMP-IR5不能通过工具A?如此迷茫...
没有找到相关结果
已邀请:
2 个回复
捐焦
行移到本地Makefile中的
语句上方。并将
更改为
。
呢率篓舍烫
否则包含的Makefile中的规则将看不到。 另外,请注意条件中的空格:
编辑: 简单!您使用不同的两个变量。 Make从上到下评估makefile,在重建任何目标之前确定要重建的目标,然后使用变量获取的任何值执行规则。考虑以下makefile:
Make到达
行,尚未定义
,因此它的计算结果为空,因此makefile的内容为:
Mow Make已确定将执行
规则,并以
(太晚)和
执行。从而: