#!/bin/sh

# gmake wrapper script

# This is needed because the name of the make command in the cernlib source
# is assumed to be "gmake", but GNU Make is simply called "make" in most
# Linux distributions.

# Do not install this script; it should be used only for the cernlib build
# process.

if [ "x$ADDONDIR" = x ] ; then
	echo "gmake: this script is not intended to be used outside the"
	echo "       cernlib build process!"
	exit 1
fi

MAKE=""

# see if there is a "gmake" other than this script
OLDPATH="$PATH"
export PATH="`echo "$OLDPATH" | sed \
	-e 's,:'"${ADDONDIR}"'/bin:,:,g' \
	-e 's,^'"${ADDONDIR}"'/bin:,,g' \
	-e 's,:'"${ADDONDIR}"'/bin$,,g'`"
which gmake > /dev/null 2>&1 && MAKE="`which gmake`"
export PATH="$OLDPATH"

# if not, try to use "make"
[ "x$MAKE" = x ] && which make > /dev/null 2>&1 && MAKE=make

if [ "x$MAKE" = x ] ; then
	echo "gmake: wrapper script can find neither gmake nor make in \$PATH!"
	exit 1
fi

exec "$MAKE" "$@"

