Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 用一个似乎正在设置变量的目标调用'make-f'意味着什么?(为什么它对我不起作用?) 总结_Linux_Makefile_Sh - Fatal编程技术网

Linux 用一个似乎正在设置变量的目标调用'make-f'意味着什么?(为什么它对我不起作用?) 总结

Linux 用一个似乎正在设置变量的目标调用'make-f'意味着什么?(为什么它对我不起作用?) 总结,linux,makefile,sh,Linux,Makefile,Sh,我试图理解一个复杂的makefile链,以便构建成功。在构建脚本中,我将问题缩小到这一点: INF_RL=`make -f $BUILD_ROOT/Makefile BUILD_ROOT_MAKEFILE= show__BUILD_INF_RL` $INF_RL/$BUILD_UTILS_RELDIR/BuildAll.sh /userhome/andrew.cheong/TPS/makefile.LINUX_X86.include:3: /foo_rel_linx86/infrastruct

我试图理解一个复杂的makefile链,以便构建成功。在构建脚本中,我将问题缩小到这一点:

INF_RL=`make -f $BUILD_ROOT/Makefile BUILD_ROOT_MAKEFILE= show__BUILD_INF_RL`
$INF_RL/$BUILD_UTILS_RELDIR/BuildAll.sh
/userhome/andrew.cheong/TPS/makefile.LINUX_X86.include:3: /foo_rel_linx86/infrastructure_release/v8.0.14
$INF\u RL
正在设置为空字符串(或未设置)。如果我将第一行替换为

INF_RL=/foo_rel_linx86/infrastructure_release/v8.0.14
为了对我所知道的
$INF\RL
进行硬编码,构建工作将顺利进行。但我想知道如何用正确的方法解决这个问题

我的努力/想法 我的第一个想法是
make-f
失败了。所以我在我的壳里试了一下:

% make -f $BUILD_ROOT/Makefile BUILD_ROOT_MAKEFILE= show__BUILD_INF_RL

% setenv | grep BUILD_ROOT
BUILD_ROOT=/userhome/andrew.cheong/TPS
实际上,它返回了一个空字符串。但我能从中得出什么结论呢?我不确定shell是否与Make将其makefile链接在一起的环境/范围相同。我放弃了这次调查


接下来,我研究了
show\u BUILD\u INF\u RL
,它似乎是在
$BUILD\u ROOT/Makefile
中定义的:

BUILD_ROOT_MAKEFILE = 1

MAKE_DIRS = src

CASE_KITS = tpsIn tpsOut

REQUIRED_VERSIONS = "case.v$(INF_VS)"

all:

## These next 3 rules allows any variable set in this makefile (and therefore
## the included makefile.include to have it's value echoed from the command
## "make show_<variableName>"
## NOTE: the "disp" target is vital as it allows the show_% implicit rule to be
##       recognised as such - implicit rules *must* have a target.

show_% := DISPLAY_MACRO = $(@:show_%=%)

show_% : disp
    @ echo $($(DISPLAY_MACRO))

disp:

include $(BUILD_ROOT)/makefile.include
虽然这是一个完全无知的猜测,但我认为这里设置了
BUILD\u INF\u RL
,并打算在调用宏
show\u BUILD\u INF\u RL
时将其提取到构建脚本的变量
INF\u RL
。我添加了中间一行,以查看它是否确实被设置,实际上,我在运行构建脚本时得到了以下输出:

INF_RL=`make -f $BUILD_ROOT/Makefile BUILD_ROOT_MAKEFILE= show__BUILD_INF_RL`
$INF_RL/$BUILD_UTILS_RELDIR/BuildAll.sh
/userhome/andrew.cheong/TPS/makefile.LINUX_X86.include:3: /foo_rel_linx86/infrastructure_release/v8.0.14
i、 看起来就像我上面硬编码的一样!但是为什么它不能成为
INF\RL
?还有另一个文件,
makefile.include
,也在
$BUILD\u ROOT
中:

#
# INCLUDE THIS FILE AS THE LAST LINE IN THE LOCAL MAKEFILE
#
# makefile.include - use this file to define global build settings
# e.g. infrastructure version and location, or third-party
#
# supported macros in addition to build-utils-makefile.include
#
# BUILD_INF_RL  : optional, specification of infrastructure release location
#                 defaults to vdev_build area
#

include $(BUILD_ROOT)/../../makefile.include.$(BUILD_ARCH).Versions

#include $(BUILD_UTILS)/makefile.archdef.include
include $(BUILD_ROOT)/makefile.$(BUILD_ARCH).include

$(warning $(BUILD_INF_RL))

_BUILD_INF_RL = $(BUILD_INF_RL)

# place the results at the root of the infdemo tree
BUILD_DEST = $(BUILD_ROOT)

INCLUDE_DIRS += $(BUILD_INF_RL)/core/$(BUILD_TARGET)/include

LINK_DIRS += $(BUILD_INF_RL)/core/$(BUILD_TARGET)/lib

# libraries required for a typical fidessa app, including OA and DB access
FIDEVMAPP_LIBS = FidApp FidInf FidCore Fidevm

include $(BUILD_UTILS)/makefile.include
$(警告…
又是我的,当运行构建脚本时,我得到:

/userhome/andrew.cheong/TPS/makefile.include:18: /foo_rel_linx86/infrastructure_release/v8.0.14
问题 当我运行调用
make-f的构建脚本时,两个
$(警告…
都会显示出来。。。show\u BUILD\u INF\u RL
,告诉我这些生成文件正在被包括在内。那么是什么导致宏失败并返回空字符串而不是正确的
INF\u RL
路径


历史笔记
这些构建脚本是在我们仅为Solaris编译时编写的。(这些脚本基于一个基础架构团队编写的模板,该团队松散地考虑了Solaris和Linux,但我们从未运行过Linux分支,因为这是不必要的。)我们现在完全迁移到Linux,并解决了这个问题。我之所以怀疑这是Linux和Solaris的问题,是因为我们至少有四种其他产品使用类似的Makefile链,并且迁移后没有任何问题。我不知道为什么这个问题表现得特别不同。

你的问题很长很复杂,所以我没有全部读过。。。因此,如果你只是问一个你想知道答案的特定的有针对性的问题,用一个简单的复制案例,通常会更好

我不能解释为什么不同的makefile的行为不同,但这行代码:

show_% := DISPLAY_MACRO = $(@:show_%=%)
对我来说似乎真的错了。这是(a)设置变量
show%
,它实际上不在任何地方使用,(b)设置为简单扩展的字符串
DISPLAY\u MACRO=
,因为此时在makefile中变量
$@
未设置为任何值

也许你想让这句话变成这样:

show_% : DISPLAY_MACRO = $(@:show_%=%)

(注意
不是
:=
)所以它是一个特定于模式的变量赋值,而不是一个简单的变量赋值?

你搞定了!是的,很抱歉问了这么长的问题,但是当处理90年代以来如此庞大且杂乱无章的公司基础架构代码时,就不可能把事情简化为“简单的重新编写案例”。我的意思是,假设你成功地“复制”了这个问题,也就是说,
INF\u RL
没有设置,我怎么知道在我删掉数千行代码(构建脚本是几千行)时,我是否做了其他事情来清除
INF\u RL
?考虑到这么多未知因素,我问问题的方式是我能做的最好的。