#! /bin/sh
# $Id: buildsunos,v 2.0.2.4.2.5 1999/02/15 09:26:25 darrenr Exp $
:
rev=`uname -r | sed -e 's/^\([^\.]*\)\..*/\1/'`
if [ -d /usr/ccs/bin ] ; then
	PATH=/usr/ccs/bin:${PATH}
fi
if [ $rev = 5 ] ; then
	cpu=`uname -p`
	cpudir=${cpu}-`uname -r`
	solrev=`uname -r | sh -c 'IFS=. read j n x; echo $n'`
	if [ ! -d SunOS5/${cpudir} -a ! -h  SunOS5/${cpudir} ] ; then
		mkdir -p SunOS5/${cpudir}
	fi
	/bin/rm -f SunOS5/${cpudir}/Makefile
	/bin/rm -f SunOS5/${cpudir}/Makefile.ipsend
	ln -s `pwd`/SunOS5/Makefile SunOS5/${cpudir}/Makefile
	ln -s `pwd`/SunOS5/Makefile.ipsend SunOS5/${cpudir}/Makefile.ipsend
	if [ -d /opt/SUNWspro/bin ] ; then
		CC=/opt/SUNWspro/bin/cc
		export CC
	else
		CC=gcc
	fi
else
	cpu=`uname -m`
	cpudir=${cpu}-`uname -r`
fi
if [ $cpu = i86pc ] ; then
	make ${1+"$@"} sunos5x86 SOLARIS2="-DSOLARIS2=$solrev" CPU= CPUDIR=${cpudir} CC=$CC
	exit $?
fi
if [ x$solrev = x ] ; then
	make ${1+"$@"} sunos$rev "ARCH=`uname -m`"
	exit $?
fi
make ${1+"$@"} sunos$rev SOLARIS2="-DSOLARIS2=$solrev" CPU= CPUDIR=${cpudir} CC=$CC
exit $?
