## Define the appropriate configuration variables.

PACKAGE = /fsys2/u2/usystem/software/u++-5.0.1

## Include the architecture dependent definitions.

include $(PACKAGE)/CONFIG

## Define the path names of important directories.

SRCDIR = $(PACKAGE)/src/examples

HOSTNAME = $(shell hostname)
ifeq ($(HOSTNAME),plg2.math)
	CCFLAGS += -O2 -Wall -Wno-unused-label #
else
	CCFLAGS += -O2 #
endif

.SILENT : all abortexit bench features EHM realtime multiprocessor

all : bench features EHM realtime multiprocessor

abortexit:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
		$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} AbortExit.cc; \
		./a.out 0 & \
		sleep 1 ; \
		kill $$! ; \
		sleep 1 ; \
		ps -u$${USER} | grep a.out ; \
		echo "************************** 1 **************************" ; \
		./a.out 1 ; \
		echo "uExit exit code is $$?" ; \
		sleep 1 ; \
		ps -u$${USER} | grep a.out ; \
		echo "************************** 2 **************************" ; \
		./a.out 2 ; \
		echo "uAbort exit code is $$?" ; \
		sleep 1 ; \
		ps -u$${USER} | grep a.out ; \
		echo "************************** 3 **************************" ; \
		./a.out 3 ; \
		echo "exploding child exit code is $$?" ; \
		sleep 1 ; \
		ps -u$${USER} | grep a.out ; \
		echo "************************** 4 **************************" ; \
	done ; \
	"rm" -f a.out core core.* ;

bench:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for filename in Bench ; do \
		for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
			$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} $${filename}.cc ; \
			./a.out ; \
		done ; \
	done ; \
	"rm" -f ./a.out ;

features:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for filename in FloatTest Allocation BinaryInsertionSort Merger Locks PThread MonAcceptBB MonConditionBB SemaphoreBB TaskAcceptBB TaskConditionBB TimeSlice Timeout TimedWait Migrate Sleep ; do \
		for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
			$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} $${filename}.cc ; \
			./a.out ; \
		done ; \
	done ; \
	"rm" -f ./a.out ;

EHM:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for filename in EHM1 EHM2 EHM3 EHM4 EHM5 EHM6 EHM7 EHM8 EHM9 EHM10 ; do \
		for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
			$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} $${filename}.cc ; \
			./a.out ; \
		done ; \
	done ; \
	"rm" -f ./a.out ;

realtime:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for filename in PeriodicTaskTest PeriodicTaskTest1 PeriodicTaskTestStatic RealTimePhilosophers RealTimePhilosophers1 RealTimePhilosophersStatic Disinherit Disinherit1 DisinheritStatic Disinherit1Static ; do \
		for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
			$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} $${filename}.cc ; \
			time ./a.out ; \
		done ; \
	done ; \
	"rm" -f ./a.out ;

multiprocessor:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	$(INSTALLBINDIR)/u++ $(CCFLAGS) uCalibrate.cc ; \
	./a.out > uCalibrate.h ; \
	for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
		$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} Sim.cc; \
		time ./a.out 1 100 500000 ; \
		time ./a.out 2 100 500000 ; \
		time ./a.out 4 100 500000 ; \
		time ./a.out 8 100 500000 ; \
	done ; \
	"rm" -f ./a.out ;


## Local Variables: ##
## compile-command: "gmake install" ##
## End: ##
