#####################################################################
#                                                                   #
# PARKBENCH Version 2.0                                             #
#                                                                   #
# November 10, 1995                                                 #
#                                                                   #
# University of Tennesee, Knoxville                                 #
# University of Southampton, United Kingdom                         #
#                                                                   #
#####################################################################

SHELL			= /bin/sh
XDIR			= bin/$(PVM_ARCH)
NPB_link 		= NPB2.1/config/make.def
NPB_xdir 		= NPB2.1/bin
PSTSWM_xdir 		= Comp_Apps/PSTSWM/bin

all conf:	testarch

testarch: null
	if [ $$PVM_ARCH ]; then $(MAKE) configure; else $(MAKE) setarch; fi

setarch:
	make PVM_ARCH=`./pvmgetarch` configure;

configure: dir_links

dir_links: ../$(XDIR) ../$(NPB_xdir) ../$(PSTSWM_xdir) ../$(NPB_link) make.def
	cd ../include; $(MAKE) conf

null:

# links for the various directories

../$(XDIR):
	@echo "Making directory for executables in $(XDIR)."
	mkdir -p ../$(XDIR)

../$(NPB_xdir): ../$(XDIR) 
	@ echo "Linking directory for NPB executables."
	-ln -s `pwd`/../$(XDIR) ../$(NPB_xdir)  

../$(NPB_link): make.def
	@echo "Making link to make.def for NPB benchmarks."
	-ln -s `pwd`/make.def ../$(NPB_link)

../$(PSTSWM_xdir): ../$(XDIR) 
	@echo "Linking directory for PSTSWM executables."
	-ln -s `pwd`/../$(XDIR) ../$(PSTSWM_xdir)  

###   If you want to change PVM_ARCH call 'makeconf' directly!   ###
###   Otherwise you get the values of the old make.def file.     ###

make.def: make.def.$(PVM_ARCH) ../make.local.def
	makeconf

make.def.$(PVM_ARCH):
	@ echo "make.def$(PVM_ARCH) file for architecture $(PVM_ARCH) is missing."
	@ echo "Trying to use make.def.Generic instead."
	cp make.def.Generic make.def.$(PVM_ARCH)

clean:
	-rm -f *~

clobber: clean
	-rm -f make.def
	-rm -rf ../$(NPB_xdir) ../$(NPB_link) ../$(PSTSWM_xdir)