# @(#) build.sh	1.0	84Sep18	mikec
# Enhanced version of build (which is an enhanced version of make). This one
# allows the VPATH assignment to be in the makefile
#
#	Michael Condict  9/84
#
for i do
	if [ "$use_next_arg" ] ; then
		makefile="$i"
		break
	fi
	case "$i" in
	-f)	use_next_arg=true ;;
	-f?*)	makefile=`echo "$i" | sed -e s/-f//` ;; 
	esac
done

# Use VPATH to find the makefile:
if [ "$VPATH" = "" ] ; then VPATH=. ; fi

for f in `echo "$VPATH" | sed -e 's/:/ /'` ; do
	if [ ! "$makefile" ] ; then
		if [ -f "$f/makefile" ] ; then
			makefile="$f/makefile" ; break
		elif [ -f "$f/Makefile" ] ; then
			makefile="$f/Makefile" ; break
		fi
	else
		if [ -f "$f/$makefile" ] ; then
			makefile="$f/$makefile" ; break
		fi
	fi
done

if [ -r "$makefile" ] ; then
	vpath_line="`grep '^ *VPATH *=' $makefile | sed -e 's/ //g'`"
	if [ "$vpath_line" ] ; then
		eval "$vpath_line"
		export VPATH
	fi
fi
MAKE=/usr/630/bin/build
export MAKE
exec /usr/630/bin/build.obj "$@"
