1) We have a need for Makefiles to build C++ on both z/OS USS and a Linux platform. Is it advisable to use gnu make on z/OS USS in order to keep our makefiles common ?
2) If the Makefiles are common, then some steps in the Makefiles, would still be conditional to the platform. Can we do that by steps that are similar to conditional compilation? If yes, can we please get help with the syntax?
3) Our z/OS USS Makefiles have shell scripts or groups of commands, as in example below, with the square brackets [] presenting the commands to the shell as a group, rather than one line at a time. It seems that using the 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
]
Disclaimers:
Advice:
# 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
And there are other, more advanced tricks to try when you're bored with these.