## Define the appropriate configuration variables.

PACKAGE = /fsys2/u/usystem/software/u++-4.7

## Include the architecture dependent definitions.

.INCLUDE : ${PACKAGE}/CONFIG

## Ensure the correct shell is used

SHELL !:= /bin/sh
GROUPSHELL !:= /bin/sh

## Define the path names of important directories.

SRCDIR = ${PACKAGE}/src/examples

#.IF ${TCPU} == mips
#	CCFLAGS += -O2
#.ELSE
#	CCFLAGS += -O3
#.END
HOSTNAME = $(shell hostname)
.IF ${HOSTNAME} == plg2.math
	CCFLAGS += -msupersparc
.END

GROUPFLAGS = -x

all :
@[
if [ ${MULTI} = TRUE ] ; then
	multi=${MULTI}
fi

for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} File.cc
	./a.out File.cc
	echo "************************** 1 **************************"
	./a.out File.cc
	echo "************************** 2 **************************"
	./a.out File.cc
	echo "************************** 3 **************************"
done

for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} NBStream.cc
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	echo "\n************************** 1 **************************"
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	echo "\n************************** 2 **************************"
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	echo "\n************************** 3 **************************"
done

for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} NBFile.cc
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	cat xxx
	echo "\n************************** 1 **************************"
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	cat xxx
	echo "\n************************** 2 **************************"
	( echo 1; sleep 1; echo 2; sleep 1; echo 3; sleep 1; echo 4; sleep 1; ) | ./a.out
	cat xxx
	echo "\n************************** 3 **************************"
done

"rm" -f xxx a.out

"rm" -f fred		# in case of previous failure
for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ClientUNIX.cc -o Client
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ServerUNIX.cc -o Server
	( ./Server fred & \
 	( \
		sleep 10 ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 1 **************************" ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 2 **************************" ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 3 **************************" ; \
 	) ; wait )	
	"rm" -f fred Server Client
done

"rm" -f fred		# in case of previous failure
for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ClientUNIX2.cc -o Client
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ServerUNIX2.cc -o Server
	( ./Server fred & \
 	( \
		sleep 10 ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 1 **************************" ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 2 **************************" ; \
		( ./Client fred < File.cc & ./Client fred < File.cc & ./Client fred < File.cc & \
			./Client fred < File.cc & ./Client fred < File.cc ; wait ) ; \
		echo "************************** 3 **************************" ; \
 	) ; wait )	
	"rm" -f fred Server Client
done

"rm" -f portno		# in case of previous failure
for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ClientINET.cc -o Client
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ServerINET.cc -o Server
	( ./Server > portno & \
	( \
		sleep 10 ; portno=`cat portno` ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 1 **************************" ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 2 **************************" ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 3 **************************" ; \
	) ; wait )
	"rm" -f portno Server Client
done

"rm" -f portno		# in case of previous failure
#for ccflags in "" "-nodebug" $${{multi+"-multi"}} $${{multi+"-multi -nodebug"}} ; do
for ccflags in "" ; do
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ClientINET2.cc -o Client
	${INSTALLBINDIR}/u++ ${CCFLAGS} $${{ccflags}} ServerINET2.cc -o Server
	( ./Server > portno & \
	( \
		sleep 10 ; portno=`cat portno` ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 1 **************************" ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 2 **************************" ; \
		( ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc & \
			./Client $${{portno}} < File.cc & ./Client $${{portno}} < File.cc ; wait ) ; \
		echo "************************** 3 **************************" ; \
	) ; wait )
	"rm" -f portno Server Client
done
]

# Local Variables: ##
# compile-command: "dmake" ##
# End: ##

#	( truss ./Client $${{portno}} < File.cc 2>&1 | cat > y1 & truss ./Client $${{portno}} < File.cc 2>&1 | cat > y2 & \
#		truss ./Client $${{portno}} < File.cc 2>&1 | cat > y3 & truss ./Client $${{portno}} < File.cc 2>&1 | cat > y4 & \
#		truss ./Client $${{portno}} < File.cc 2>&1 | cat > y5 ;  wait )
