3 # This is make+. Make+ is a set of scripts which enhance GNU make and
4 # let you build RPMs, and other packages types with just one control
5 # file. Read more at http://www.annexia.org/freeware/makeplus/
7 # The original author is Richard W.M. Jones <rich@annexia.org>.
9 # This software has been explicitly placed in the PUBLIC DOMAIN. You
10 # do not need any sort of license or agreement to use or copy this
11 # software. You may also copyright this software yourself, and/or
12 # relicense it under any terms you want, at any time and at no cost.
13 # This allows you (among other things) to include this software with
14 # other packages so that the user does not need to download and
15 # install make+ separately.
17 # The control file. XXX Parse and remove the -f option.
18 _mp_makefile="Makefile+"; export _mp_makefile
20 # Check the control file exists in the current directory. You can only
21 # run make+ from the top level source directory, the one which contains
22 # Makefile+. You should not be doing anything recursive with make+.
23 if [ ! -r "$_mp_makefile" ]; then
24 echo "make+: $_mp_makefile: file not found or not readable"
25 echo "You should always run make+ from the top-level source"
26 echo "directory, the one which contains the Makefile+ file."
30 # Find a suitable copy of GNU make. You can override this test
31 # by setting the $MAKE option.
32 if [ "x$MAKE" = "x" ]; then
33 if sh -c 'gmake --version' 2>/dev/null | grep -q 'GNU Make'; then
35 elif sh -c 'make --version' 2>/dev/null | grep -q 'GNU Make'; then
38 echo "make+: I cannot find a copy of GNU make. Please set the \$MAKE"
39 echo "environment variable to point to the GNU make binary."
43 # Check for a sufficiently recent version of GNU make.
44 if $MAKE --version | grep -q '^GNU Make .*3\.'; then
48 echo "make+: Your 'make' is not GNU make (or not a recent version)"
49 echo "Please install a recent version of GNU make."
53 # Check that either MAKEPLUS_HOME or /etc/make+.conf exists, and run it.
54 if [ "x$MAKEPLUS_HOME" = "x" ]; then
55 for d in /etc /usr/etc /usr/local/etc; do
56 if [ -f $d/make+.conf ]; then
63 # Check MAKEPLUS_HOME looks reasonable.
64 if [ ! -f "$MAKEPLUS_HOME/main.mk" ]; then
65 echo "make+: MAKEPLUS_HOME environment variable not set correctly."
66 echo "This environment variable should point to the installation"
67 echo "directory for make+ (eg. /usr/share/makeplus). You would normally"
68 echo "do this by creating a file called /etc/make+.conf containing"
69 echo " export MAKEPLUS_HOME=/usr/share/makeplus"
70 echo "or you can set it as an environment variable each time you run"
76 MAKEFILES=$MAKEPLUS_HOME/main.mk; export MAKEFILES
78 # Construct a suitable target architecture.
79 # XXX Cross compiling.
81 os=`uname -s | tr 'A-Z' 'a-z'`
82 hw=`( uname -i 2>/dev/null || echo "unknown" ) | tr -cd 'A-Za-z0-9'`
83 _mp_builddir=build-$arch-$hw-$os; export _mp_builddir
85 # Create the build directory.
87 mkdir -p $_mp_builddir
90 # Create the directories under the build directory.
91 (cd .. && find . -type d -a \! -name CVS) | grep -v $_mp_builddir |
94 # Run GNU make from the build directory.
95 $MAKE -f ../$_mp_makefile "$@"