#!/bin/sh
####
# NAME
#	default-make : execute gnu make or bsd make
# VERSION
#	$Id$
# USAGE
#	default-make [-p|-g] other-args
# DESCRIPTION
#  This script executes gnu make command or bsd make command or
#  default make command. The '-p' option choose the bsd make.
#  The '-g' option choose the gnu make command. 
#  The 'other-args' options are passed to these make commands.
# COPYRIGHT
#  Copyright (C) 2000,2001 Steel Wheels Project.
#  This file is a apart of the papaya utilities. 
#  If you need the information of copyright of this file, see COPYING
#  file distributed with file or see http://www.asahi-net.or.jp/~em7t-hmd
#  web page.

make_command="make"

error(){
	echo "ERROR: $1" >&2 ;
	exit 1 ;
}

arg=$1 ;

if [ "x$arg" = "x-p" ] ; then
	if search-exec -n pmake ; then
		make_command="pmake" 
	fi
	shift 
elif [ "x$arg" = "x-g" ] ; then
	if search-exec -n gmake ; then
		make_command=/usr/pkg/bin/gmake
	fi
	shift 
fi

echo "$make_command $*" 
if $make_command $* ; then
	exit 0 ;
else
	exit 1 ;
fi

