## Define the appropriate configuration variables.

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

## Include the architecture dependent definitions.

include $(PACKAGE)/CONFIG

## Define the path names of important directories.

SRCDIR = $(PACKAGE)/src/examples

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

.SILENT : all abortexit bench features EHM realtime multiprocessor

all : bench features pthread EHM realtime multiprocessor

errors : ownership abortexit

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

abortexit:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	if [ $(TOS) = freebsd ]; then \
		pscmd="ps u" ; \
	else \
		pscmd="ps -u$${USER}" ; \
	fi ; \
	for ccflags in "" "-nodebug" $${multi+"-multi"} $${multi+"-multi -nodebug"} ; do \
		$(INSTALLBINDIR)/u++ $(CCFLAGS) $${ccflags} AbortExit.cc; \
		echo "************************** 0 Killed by SIGTERM **************************" ; \
		./a.out 0 & \
		sleep 1 ; \
		kill $$! ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 1 Exit **************************" ; \
		./a.out 1 ; \
		echo "return code is $$? should be 1" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 2 uAbort **************************" ; \
		./a.out 2 ; \
		echo "return code is $$?" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 3 Child killed by SIGKILL **************************" ; \
		./a.out 3 ; \
		echo "return code is $$?" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 4 abort **************************" ; \
		./a.out 4 ; \
		echo "return code is $$?" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 5 Assertion failure **************************" ; \
		./a.out 5 ; \
		echo "return code is $$?" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 6 Return from uMain::main **************************" ; \
		./a.out 6 ; \
		echo "return code is $$? should be 6" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
		echo "************************** 7 pthread_shutdown **************************" ; \
		./a.out 7 ; \
		echo "return code is $$? should be 7" ; \
		sleep 1 ; \
		$$pscmd | grep a.out ; \
	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 CorFullProdCons CorFullProdConsStack BinaryInsertionSort Merger Locks MonAcceptBB MonConditionBB SemaphoreBB TaskAcceptBB TaskConditionBB TimeSlice TimeoutAccept TimeoutCondLock TimeoutSem Migrate Migrate2 DeleteProcessor Sleep Atomic ; 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 ;

pthread:
	set -x ; \
	if [ $(MULTI) = TRUE ] ; then \
		multi=$(MULTI) ; \
	fi ; \
	for filename in Pthread TimeoutPthreadsCond ; 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 CRAII UncaughtException; 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: ##
