Gnu Make and z / OS USS do
1) We need Makefiles to build C ++ on both z / OS USS and Linux platform. Is it advisable to use gnu make for z / OS USS so that our shared files are normal?
2) If Makefiles are shared, then some of the steps in Makefiles will still be platform-specific. Can we do this with steps similar to conditional compilation? If so, can we get some help with the syntax?
3) Our z / OS USS Makefiles have shell scripts or groups of commands, as in the example below, with square brackets [] representing commands to the shell as a group, rather than one line at a time. It looks like, using GNU make, we had to modify these commands to become one line, which is messy, and the nested loop was a problem. Is there an easier way to group commands using 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
]
source to share
Denial of responsibility:
- I don't know anything about z / OS USS,
- I know a lot about Make (and when you hold the hammer, ...).
Advice:
Yes, I would recommend using GNUMake on both platforms and keeping your Makefiles as simple as possible. There are several ways to set conditions in a Makefile.
# 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 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
And there are other, more advanced tricks to try when you get bored.
I'm not sure what you mean when you say you want commands to be processed in groups, but I suspect you can get what you want by adding; \ to each command in the group so that they are executed one at a time to others in the same subshell (otherwise each command gets its own subshell).source to share