#!/bin/csh -f
#
# Eric A. Brewer  4-17-90
# Version 2.0  -- 8-27-91
#
# $Header: /a/ulana/proteus/take1/RCS/makesim_p,v 1.1 1993/11/17 01:57:54 ulana Exp $
#
# $Log: makesim_p,v $
# Revision 1.1  1993/11/17  01:57:54  ulana
# Initial revision
#
# Revision 1.1  1993/11/17  01:57:54  ulana
# Initial revision
#
#
#

set cpp = 'cc -E'
set cpp_args = ""
set make_args = "-k"
set usermake = "UserMake_p"

setenv PATH $HOME/prot-bin:$PATH
#echo $PATH
#which augment
#which saveparams

while ("$1" != "")
	if ("$1" =~ -D*) then
		set cpp_args = ($cpp_args $1)
	else if ("$1" =~ -U*) then
		set cpp_args = ($cpp_args $1)
	else if ("$1" =~ -I*) then
		set cpp_args = ($cpp_args $1)
	else if ("$1" == "-f") then
		if ($#argv > 1) then
			set usermake = $2
			shift
		endif
	else
		set make_args = ($make_args $1)
	endif
	shift
end

#echo CPP: $cpp_args
#echo MAKE: $make_args

set tmp_file = makesim.$$
onintr cleanup

$cpp SimMake_p $cpp_args -DUSERMAKE_P='"'$usermake'"' > $tmp_file
if ($status) exit 1

/bin/make $make_args -f $tmp_file
if ($status) then
	/bin/rm $tmp_file 
	exit 1
endif

/bin/rm -f $tmp_file 
exit $status

cleanup:
echo "cleaning up..."
/bin/rm -f $tmp_file 
exit 1

