gpt4 book ai didi

mainframe - Gnu Make 和 z/OS USS make

转载 作者:行者123 更新时间:2023-12-01 12:58:08 26 4
gpt4 key购买 nike

1) 我们需要 Makefile 来在 z/OS USS 和 Linux 平台上构建 C++。是否建议在 z/OS USS 上使用 gnu make 以保持我们的 makefile 通用?

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
]

最佳答案

免责声明:

  1. 我对 z/OS USS 一无所知,
  2. 我对 Make 了解很多(当您拿着锤子时,...)。

建议:

  • 是的,我建议在这两个平台上都使用 GNUMake 并使您的 Makefile 尽可能通用。
  • 有几种方法可以将条件性放入 Makefile。

    # Usually one defines a variable first.SYSTEM = $(shell uname)# Then one can define other variables conditionallySOMEFILE = $(SYSTEM)_fileifeq ($(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-somethingendif# 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

    当您对这些技巧感到厌倦时,还可以尝试其他更高级的技巧。

  • 当你说你希望命令按组处理时,我不确定你的意思,但我怀疑你可以通过将 ;\附加到每个命令来获得你想要的组,以便它们将在同一个子 shell 中一个接一个地执行(否则每个命令都有自己的子 shell)。

  • 关于mainframe - Gnu Make 和 z/OS USS make,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1535314/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com