if test -r /tmp/buildd_in_progress
then
   echo Qualcuno ci ha pensato prima. Ciao!
   exit
fi
touch /tmp/buildd_in_progress
trap "rm /tmp/buildd_in_progress;echo ok, basta;exit" 2

btouch

CPLUSCOMP=cc++
CCOMP=cc++
MCOMP=mskcomp
LINKC=linkunoc
IP=$SRC_HOME/include/
if [ "$EXEHOME" = "" ];
then
  EXEHOME=$P2HOME
fi
EP=$EXEHOME/campo/
CLIB=$DEVHOME/p.uno/
MLIB=$DEVHOME/mathlib/
TMPF=
CFLAGS="-r -p "
O=$SRC_HOME/objs
EXT=
LIB=
LIBINSERT="echo >>$TMPF"
UPDLIB=updlib
export CPLUSCOMP CCOMP MCOMP LINKC IP EP LIB O EXT CFLAGS CLIB TMPF UPDLIB LIBINSERT MLIB
FLAGS=
ALL=T
L1=
L2=
LM=
DIR=`pwd | grep -v $P2HOME`
if [ "$DIR" = "" ];
then
	LIBP=$P2HOME/lib
else
	LIBP=$SRC_HOME/lib
fi
DASH=`echo $1 | cut -c1 `
while [ "$DASH" = "-" ];
do
	if [ "$1" = "-l1" ];
	then
		ALL=
		L1=T
	else
		if [ "$1" = "-l2" ];
		then
			ALL=
			L2=T
		else
			if [ "$1" = "-lm" ];
			then
				ALL=
				LM=T
			else
				FLAGS=$FLAGS" "$1
			fi
		fi
	fi
	shift
	DASH=`echo $1 | cut -c1 `
done
if [ "$ALL" = "T" -o "$L2" = "T" ];
then
	LIB=$LIBP/libdued.a
	TMPF=/tmp/ar0$$
	LIBINSERT="echo >>$TMPF"
	gmake -f makedue.mak $FLAGS $*
fi
if [ "$ALL" = "T" -o "$L1" = "T" ];
then
	LIB=$LIBP/libunod.a
	TMPF=/tmp/ar1$$
	LIBINSERT="echo >>$TMPF"
	CFLAGS="-k S4DEBUG "$CFLAGS
	gmake -f makeuno.mak $FLAGS $*
fi
if [ "$ALL" = "T" -o "$LM" = "T" ];
then
	LIB=$LIBP/libgfmd.a
	TMPF=/tmp/ar2$$
	LIBINSERT="echo >>$TMPF"
	gmake -f makegfm.mak $FLAGS $*
fi
rm /tmp/buildd_in_progress
