Gnu Make 和 z/OS USS make
题
1) 我们需要 Makefiles 在 z/OS USS 和 Linux 平台上构建 C++。为了保持我们的 makefile 的通用性,是否建议在 z/OS USS 上使用 gnu make?
2) 如果 Makefile 是通用的,那么 Makefile 中的某些步骤仍然会以平台为条件。我们可以通过类似于条件编译的步骤来做到这一点吗?如果是,我们可以获得语法方面的帮助吗?
3) 我们的 z/OS USS Makefile 具有 shell 脚本或命令组,如下例所示,其中方括号 [] 将命令作为一组而不是一次一行呈现给 shell。看来使用GNU make,我们得把这些命令修改成一行,比较乱,而且嵌套循环也是个问题。有没有更简单的方法使用 gmake 对命令进行分组?
[
dirs=$(targets)
rc=0
for dir in $$dirs
do
cd $$dir/src
make -r
rc=$$?
if [ $$rc != 0 ]; then
echo "build failed for directory:" $$dir:
break;
fi
cd ../..
done
echo "return code from make = " $$rc
]
解决方案
免责声明:
- 我对 z/OS USS 一无所知,
- 我对 Make 了解很多(当你拿着锤子时,......)。
建议:
# Usually one defines a variable first. SYSTEM = $(shell uname) # Then one can define other variables conditionally SOMEFILE = $(SYSTEM)_file ifeq ($(SYSTEM), Linux) # Do some Linux things, define variables, whatever. else # Do some z/OS USS things. endif # In a block of commands, if the conditional DOESN'T start with a tab, # it's a Make statement and follows Make syntax. thing: ifeq($(SYSTEM), Linux) shell-command-do-something endif # If the conditional DOES follow a tab, Make expands the variables and passes # the whole thing to the shell, so the syntax is whatever the shell requires. otherthing: if($(SYSTEM)==ZOS) do_x ; otherwise do_y ; finish
当您对这些感到厌倦时,还有其他更高级的技巧可以尝试。
其他提示
如果您有需要携带的Makefile,通过各种手段使用GNU使。我一直在USS下现在正在运行了多年,没有任何问题。如果你觉得不舒服自己构建它,你可以得到一份AA的 “nofollow的noreferrer”>
我已经建立了使用UNIX系统服务(USS)和C / C ++ / HLASM z / OS上多个应用程序。 我发现它是值得使用gmake命令,而不是做。是的,你必须下载使用gmake并设置它,但它的方式更容易使用,而且比较容易的方式,使便携性。 除了GMAKE,你可能希望得到的庆典的为好。这将是更容易有USS和其他平台之间移植的shell脚本使用bash,而不是强迫自己使用的 SH 的。 可能有几个地方,你可以从gmake命令和bash,但我已经使用了火箭队网站的 http://www.rocketsoftware.com/product-categories/mainframe/bash-zos (这是免费的,如果你不想支持)。