1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
#! /bin/sh
# Shell script to build a makefile in a build directory. It is called from the
# generic make file which is initially set up and run from inside the
# directory.
scripts=../scripts
# First off, get the OS type, and check that there is a make file for it.
os=`$scripts/os-type -generic` || exit 1
if test ! -r ../OS/Makefile-$os
then echo ""
echo "*** Sorry - operating system $os is not supported"
echo "*** See OS/Makefile-* for supported systems" 1>&2
echo ""
exit 1;
fi
# We also need the architecture type, in order to test for any architecture-
# specific configuration files.
arch=`$scripts/arch-type` || exit 1
# Build a file called makefile in the current directory by joining
# the generic default makefile, the OS base makefile, and then local
# generic, OS-specific, architecture-specific, and OS+architecture-specific
# makefiles, if they exist. These files all contain macro definitions, with
# later definitions overriding earlier ones. Make a temporary file first, in
# case things go wrong. Use short macro names to save typing.
mf=makefile
mft=$mf-t
# Ensure the temporary does not exist and start the new one by setting
# the OSTYPE and ARCHTYPE variables.
rm -f $mft
(echo "OSTYPE=$os"; echo "ARCHTYPE=$arch"; echo "") > $mft || exit 1
# Now concatenate the files to the temporary file.
for f in OS/Makefile-Default \
OS/Makefile-$os \
Local/Makefile \
Local/Makefile-$os \
Local/Makefile-$arch \
Local/Makefile-$os-$arch
do if test -r ../$f
then echo "# From $f"
sed '/^#/d;/^[ ]*$/d' ../$f || exit 1
echo "# End of $f"
echo ""
fi
done >> $mft || exit 1
# Add on a setting of SHELL to MAKE_SHELL. This is necessary because "make"
# seems to treat the macro SHELL specially (at least in some implementations).
# We can't have this setting at the top of the base file, because at least one
# version of "make" objects when MAKE_SHELL is not set, even though the result
# is never used when building the makefile.
cat <<'End' >>$mft || exit 1
# Set SHELL from the configuration setting of MAKE_SHELL
SHELL = $(MAKE_SHELL)
End
# Finally, join on the generic base make file, which contains the actual
# rules and stuff.
cat ../OS/Makefile-Base >> $mft || exit 1
# If the new makefile is the same as an existing one, say so, and just
# update the timestamp. Otherwise remove the old and install the new.
if [ -s $mf ] && cmp -s $mft $mf
then echo ">>> $mf unchanged"
touch $mf || exit
rm -f $mft
elif rm -f $mf
mv $mft $mf
then echo ">>> New $mf installed"
echo '>>> Use "make makefile" if you need to force rebuilding of the makefile'
else echo ""
echo "*** Failed to install $mf - see $mft"
echo ""
exit 1;
fi
# Remove the original make file (link) from the build directory (to stop make
# muttering about both existing).
rm -f Makefile
# End of Configure-makefile
|