# create Makefile from this file with configure script
##### User configurable options #####
ALL: mpi
LARCH       = @ARCH@
COMM        = @COMM@
DEVICE      = @DEVICE@
MPIR_HOME   = @MPIR_HOME@
INCLUDE_DIR = @INCLUDE_PATH@ -Impid/@DEVICE@ -Iinclude
PREFIX	    = @PREFIX@
MAKE        = @MAKE@
CPRP        = @CPRP@
RSHCOMMAND  = @RSHCOMMAND@
DEFAULT_MACHINE = @DEFAULT_MACHINE@
ROMIO       = @ROMIO@
BUILDCPP    = @buildcpp@
NOF77	    = @NOF77@
NOMPE       = @NOMPE@
### End User configurable options ###

SHELL = /bin/sh

MPIDIRS  = src/pt2pt src/env src/dmpi src/util src/context src/coll \
	   src/topol src/profile 
MPI2DIRS = src/misc2 src/external
DIRS     = $(MPIDIRS) $(MPI2DIRS) mpid/$(DEVICE) \
	   examples examples/basic examples/test/pt2pt examples/test/coll \
	   examples/test/topol examples/test/context \
	   examples/test/env examples/test/profile examples/test \
	   examples/perftest src/infoexport
# 
# This is a list of the devices that are available
DEVICES  = mpid/ch2 \
	   mpid/ch_nx mpid/ch_p4 \
	   mpid/ch_mpl mpid/t3e mpid/ch_meiko mpid/ch_shmem \
	   mpid/globus mpid/ch_lfshmem \
	   mpid/ch_cenju3
# Change this in maint/maketar also
OTHERDEVICES  = mpid/ch_nx mpid/ch_p4 mpid/ch_mpl \
		mpid/ch_meiko mpid/ch_shmem mpid/ch_lfshmem mpid/t3e \
		mpid/globus mpid/ch_cenju3
# 
# Build the device FIRST in case the device include, used in mpiimpl.h, 
# needs to be built (e.g., ch_p4 device)
# We need MPI2DIRS for the Fortran interface, among other things
CODEDIRS = mpid/$(DEVICE) $(MPIDIRS) $(MPI2DIRS) 

#
# The order here was chosen to identify problems early in the build
# In particular, we try a linktest as soon as the libraries are available,
# with a second link test after the profiling libraries are built just to
# be sure that they still succeed.  There are "make clean"s around the 
# whole thing so that there is reduced danger of finding the "wrong" 
# object files .
#
# Notes on C++ interface:
# This is still incomplete.  In particular, there are a LOT of include
# files, including one name "config.h" in the C++ interface.  The
# C++ library is named libmpi++.a .
mpi:
	./makelinks
	$(MAKE) clean
	$(MAKE) rmlib
	$(MAKE) mpilib
	$(MAKE) mpiflib
	$(MAKE) clean
	$(MAKE) profile
	$(MAKE) mpelib        
	@if [ $(ROMIO) = 1 ] ; then \
	    echo "making romio" ;  \
            (cd romio ; $(MAKE) )    \
        fi
	@if [ $(BUILDCPP) = 1 ] ; then \
            echo "making C++ interface" ; \
	    $(MAKE) cpplib ; \
	fi
	@echo "Testing that MPI applications can be linked..."
	$(MAKE) linktest
	$(MAKE) mpichsharelibs
	$(MAKE) clean
	@if [ $(DEVICE) = "ch_p4" ] ; then \
	    echo '--->' ; \
	    echo "You may want to do" ; \
	    echo "    $(MAKE) serv_p4" ; \
	    echo "or"; \
	    echo "    $(MAKE) server "; \
	    echo "as well." ; \
	    echo '---<' ; \
	fi
	/bin/rm -f bin/mpirun
	$(MAKE) mpirun
	/bin/rm -f bin/mpireconfig
	$(MAKE) mpireconfig
	$(MAKE) mpiman
	$(MAKE) util/mpiinstall
	@echo '--->'
	@echo "Completed build of MPI.  Check the output for errors"
	@echo "Also try executing 'make testing' in examples/test"
	@echo "(This relies on mpirun, which currently works for many"
	@echo "but not all systems.  mpirun requires that you first"
	@echo "setup the util/machines/machines.$(LARCH) file for the"
	@echo "ch_p4 device.  Other devices do not need that file)."
	@echo " "
	@echo "Send bugs and comments to mpi-bugs@mcs.anl.gov"
	@echo "With any bug report, please send"
	@echo "     The version of MPICH (e.g., 1.1.1)"
	@echo " "
	@echo "The output of running your program with the -mpiversion argument"
	@echo "(e.g., mpirun -np 1 a.out -mpiversion)"
	@echo " "
	@echo "The output of "
	@echo "        uname -a"
	@echo "for your system.  If you are on an SGI system, also"
	@echo "	       hinv"
	@echo " "
	@echo "If the problem is with a script like configure or mpirun, run the"
	@echo "script with the -echo argument "
	@echo "(e.g., mpirun -echo -np 4 a.out )"
	@echo " "
	@echo "If you are using a network of workstations, also send the output of"
	@echo "util/tstmachines."
	@echo '---<'


examples: bin/mpirun
	( cd examples ; $(MAKE) default )

# 
# This is an experimental target.  We skip the C++ library for now.
mpichsharelibs:
	@-( cd build/@ARCH@/@DEVICE@/lib ; \
	CC="$(CC)" ; export CC ; CLINKER="@CLINKER@" ; export CLINKER ; \
	for lib in lib*.a ; do \
		if test $$lib != lib@MPILIBNAME@++.a ; then \
		../../../../util/makesharedlib -lib=$$lib -kind=@SHAREDKIND@ ; \
	fi ; \
	done )

linktest:
	@-if [ $(NOF77) = 1 ] ; then \
	( cd examples/test/pt2pt ; $(MAKE) linktest1 ) ; \
	else \
	( cd examples/test/pt2pt ; $(MAKE) linktest ) ; \
	fi

testing:
	(cd examples/test ; $(MAKE) testing)

#
# This is the target for the report function.  The optional lines on the make
# are
#   AUTHOR=string
#   CONFIGLOG=file
#
report:
	( if [ -n "$(AUTHOR)" ] ; then auth=-author="$(AUTHOR)" ; fi ; \
	  if [ -n "$(CONFIGLOG)" ] ; then conf=-config=$(CONFIGLOG) ; fi ; \
	doc/port -dotest $$auth $$conf ; )
	doc/docgather
	mv doc.tar doc$(ARCH)$(DEVICE).tar
	@echo "Final location of tar file is doc$(DEVICE).tar"
	@echo "util/insttest -prefix=install_directory"
	@echo "may be run to complete the testing.  This must be run"
	@echo "in the foreground.  It will try to start Upshot and Nupshot."
	@echo "It also does an installation into 'install_directory'"


#
# Make sure that a failure during the make causes the make to stop at 
# that point.
mpilib: Makefile.in
	./makelinks
	-@(cd mpid/@DEVICE@ ; $(MAKE) setlinks)
	@for dir in $(CODEDIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir ; \
	  $(MAKE) default_all ; if [ $$? != 0 ] ; then \
		echo "Exit status from make was $$?" ; exit 1 ; fi ;) ;\
	  done
	-(cd src/infoexport ; $(MAKE) default_all )
	@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/lib@MPILIBNAME@.a
	@if test -w build/$(LARCH)/$(DEVICE)/lib/lib@MPILIBNAME@++.a ; then \
		@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/lib@MPILIBNAME@++.a ; fi

mpiflib: Makefile.in
	@for dir in $(MPIDIRS) $(MPI2DIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir ; \
	  $(MAKE) wrapperlib ) ;\
	  done
	@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/libf@MPILIBNAME@.a

#
# This target is used to remove the libraries for this configuration; this
# can lead to better performance when rebuilding.
rmlib:
	/bin/rm -f build/$(LARCH)/$(DEVICE)/lib/lib*.a 
	/bin/rm -f build/$(LARCH)/$(DEVICE)/lib/shared/lib*.so*
#
# This is a special target for just the device part of the transport
# (used to speed builds for multiple Chameleon transport layers)
#
# WARNING: THIS DEPENDS ON THE ROUTINES IN MPIDIRS CALLING ROUTINES, NOT
# MACROS, FROM THE ADI.  THIS IS CURRENTLY THE CASE BUT MAY CHANGE
# 
# This uses the "default" entry instead of "default_all" because it is
# usually executed alone, and the RANLIB is needed at the end of this
# target anyway.
mpelib:
	@-if [ $(NOMPE) = 0 ] ; then \
            echo "making mpe graphics libraries" ; \
	    (cd mpe ; MAKE="$(MAKE)" ; export MAKE ; \
	     /bin/rm -f config.cache ; \
	     if [ $(NOF77) = 1 ] ; then \
                 if ./configure --with-mpich=$(MPIR_HOME) \
			        --with-mpichdev=build/$(LARCH)/$(COMM)/lib  \
			        --disable-f77  \
				--prefix=$(PREFIX) \
	                        "@JUMPSHOT_OPTS@" \
				@MPE_OPTS@ ; then $(MAKE) ; \
		 else echo "Error configuring mpe" ; \
		      if [ -s config.log ] ; then cat config.log ; fi ; \
		 fi  \
	     else \
                 if ./configure --with-mpich=$(MPIR_HOME) \
			        --with-mpichdev=build/$(LARCH)/$(COMM)/lib  \
				--prefix=$(PREFIX) \
	                        "@JUMPSHOT_OPTS@" \
			        @MPE_OPTS@ ; then $(MAKE) ; \
		 else echo "Error configuring mpe" ; \
		      if [ -s config.log ] ; then cat config.log ; fi ; \
		 fi   \
	     fi ) \
	fi
	@if test -w build/$(LARCH)/$(DEVICE)/lib/libmpe.a ; then \
		@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/libmpe.a ; fi
	@if test -w build/$(LARCH)/$(DEVICE)/lib/libmpe_nompi.a ; then \
		@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/libmpe_nompi.a ; fi

cpplib:
	@(cd MPI-2-C++ ; MAKE="$(MAKE)" ; export MAKE ; \
	/bin/rm -f config.cache ; \
	CXXFLAGS="" ; export CXXFLAGS ; \
	CXX="g++" ; export CXX ; \
	if ./configure --with-mpich=$(MPIR_HOME) \
			--with-libopt=" " \
			 --with-profiling \
	                 --with-mpichdev=build/$(LARCH)/$(COMM)/lib ; then $(MAKE) ; fi ) 
	@if [ -f "MPI-2-C++/src/libmpi++.a" ] ; then \
	    cp -p MPI-2-C++/src/libmpi++.a $(MPIR_HOME)/build/$(LARCH)/$(COMM)/lib/libmpich++.a ; fi 

mpidevlib:
	(cd mpid/$(DEVICE) ; $(MAKE) clean )
	@for dir in mpid/$(DEVICE) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir ; \
	  $(MAKE) default) ;\
	  done

#
# This is mpilib, but with memory leak/usage debugging turned on.
# The command line switch -chmemdebug will enable leak reporting
# when MPI_Finalize is called.
mpilibdebug:
	@for dir in $(CODEDIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir ; \
	  $(MAKE) default_all MPIPROFILE="-DMPIR_DEBUG_MEM" ) ;\
	  (cd $$dir ; $(MAKE) clean ; \
	  $(MAKE) profile_all MPIPROFILE="-DMPIR_DEBUG_MEM -DMPI_BUILD_PROFILING");\
	  done 
	@RANLIB@ build/$(LARCH)/$(COMM)/lib/lib@MPILIBNAME@.a
	@RANLIB@ build/$(LARCH)/$(COMM)/lib/libp@MPILIBNAME@.a
	@if test -w build/$(LARCH)/$(COMM)/lib/lib@MPILIBNAME@++.a ; then \
		@RANLIB@ build/$(LARCH)/$(COMM)/lib/lib@MPILIBNAME@++.a ; fi

profile:
	@for dir in $(MPIDIRS) $(MPI2DIRS) ;\
	  do \
	  echo " " ;\
	  echo making mpir in directory $$dir ;\
	  (cd $$dir ; \
	  $(MAKE) profile_all MPIPROFILE="-DMPI_BUILD_PROFILING" ) ;\
	  done
	@RANLIB@ build/$(LARCH)/$(DEVICE)/lib/libp@MPILIBNAME@.a

#
# Make mpirun from mpirun.*.in
#
mpirun: bin/mpirun

#
# If you change this, ALSO change it in the install target!
# Note that the csh version is no longer built
bin/mpirun: util/mpirun.sh.in util/mpirun.pg.in util/mpirun.ch_p4.in
	-@(cd util ; for file in mpirun.*.in tstmachines.in ; do \
	bfile=`basename $$file .in` ; \
	/bin/rm -f $$bfile ; \
	cat $$file | sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
		-e "s%\#AUTOMOUNTFIX\#%@AUTOMOUNTFIX@%g" \
		-e "s%\#EXECER_DIR\#%$(MPIR_HOME)/util%g" \
		-e "s%\#DEFAULT_DEVICE\#%$(DEVICE)%g" \
		-e "s%\#RSHCOMMAND\#%$(RSHCOMMAND)%g" \
		-e "s%\#SYNCLOC\#%@SYNCLOC@%g" \
		-e "s%\#CC\#%@CC@%g" \
	        -e "s%\#GLOBUSDIR\#%@GLOBUSDIR@%g" \
		-e "s%\#CLINKER\#%@CLINKER@%g" \
	        -e "s%\#MPIRUN_BIN\#%build/$(LARCH)/$(DEVICE)/bin%g" \
		-e "s%\#DEFAULT_MACHINE\#%$(DEFAULT_MACHINE)%g" \
		-e "s%\#DEFAULT_ARCH\#%$(LARCH)%g" > $$bfile ; \
	chmod 775 $$bfile ; \
	/bin/rm -f ../build/$(LARCH)/$(DEVICE)/bin/$$bfile ; \
	cp $$bfile ../build/$(LARCH)/$(DEVICE)/bin ; done ; \
        mv ../build/$(LARCH)/$(DEVICE)/bin/mpirun.sh ../build/$(LARCH)/$(DEVICE)/bin/mpirun ; \
	mv mpirun.sh ../bin/mpirun ; mv mpirun.args ../bin/mpirun.args)
	@if test -s util/mpirun.$(DEVICE) ; then \
	    rm -f bin/mpirun.$(DEVICE) ; \
	    mv util/mpirun.$(DEVICE) bin/mpirun.$(DEVICE) ; \
	fi
	@if test $(DEVICE) = "ch_p4" -o $(DEVICE) = "globus" ; then \
	    rm -f bin/mpirun.pg ; \
	    mv util/mpirun.pg bin/mpirun.pg ; \
	fi
#
# If you change this, ALSO change it in the install target!
mpireconfig: bin/mpireconfig config.status
bin/mpireconfig: util/mpireconfig.in
	@cat util/mpireconfig.in | sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
			    -e "s%\#ARCH\#%$(LARCH)%g" \
			    -e "s%\#PREFIX\#%$(PREFIX)%g" \
			    -e "s%\#DEVICE\#%$(DEVICE)%g" \
			    -e "s%\#COMM\#%$(COMM)%g" > \
		    bin/mpireconfig ;\
	chmod 775 bin/mpireconfig
	@-/bin/rm -f build/$(LARCH)/$(DEVICE)/bin/mpireconfig \
		build/$(LARCH)/$(DEVICE)/bin/config.status 
	@-cp bin/mpireconfig config.status build/$(LARCH)/$(DEVICE)/bin

#
# Make mpiman from mpiman.in
#
mpiman: bin/mpiman

#
# If you change this, ALSO change it in the install target!
bin/mpiman: util/mpiman.in
	@/bin/rm -f bin/mpiman
	@cat util/mpiman.in \
	    | sed -e "s%\#INSTALL_DIR\#%$(MPIR_HOME)%g" > bin/mpiman
	@chmod 755 bin/mpiman

#
# If you change this, ALSO change it in the install target!
serv_p4:
	( cd mpid/ch_p4/p4/servers ; $(MAKE) serv_p4 ; \
	  cp ../bin/serv_p4 ../../../../build/$(LARCH)/ch_p4/bin )
	/bin/rm -f bin/chp4_servs
	cat util/chp4_servs.in | sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
		-e "s%\#DEFAULT_DEVICE\#%$(DEVICE)%g" \
		-e "s%\#RSHCOMMAND\#%$(RSHCOMMAND)%g" \
		-e "s%\#DEFAULT_MACHINE\#%$(DEFAULT_MACHINE)%g" \
		-e "s%\#DEFAULT_ARCH\#%$(LARCH)%g" > \
		    bin/chp4_servs ;\
	chmod 775 bin/chp4_servs
	-cp bin/chp4_servs build/$(LARCH)/$(DEVICE)/bin
	-cp util/chkserv build/$(LARCH)/$(DEVICE)/bin
	-cp util/chkmachine build/$(LARCH)/$(DEVICE)/bin
#
# If you change this, ALSO change it in the install target!
server:
	( cd mpid/server ; /bin/rm -f config.cache ; \
	  ./configure ; $(MAKE) server ; \
	  cp server ../../build/$(LARCH)/$(DEVICE)/lib )
	/bin/rm -f bin/chp4_servs
	cat util/chp4_servs.in | sed -e "s%\#MPIR_HOME\#%$(MPIR_HOME)%g" \
		-e "s%\#DEFAULT_DEVICE\#%$(DEVICE)%g" \
		-e "s%\#RSHCOMMAND\#%$(RSHCOMMAND)%g" \
		-e "s%\#DEFAULT_MACHINE\#%$(DEFAULT_MACHINE)%g" \
		-e "s%\#DEFAULT_ARCH\#%$(LARCH)%g" > \
		    bin/chp4_servs ;\
	chmod 775 bin/chp4_servs
	-cp bin/chp4_servs build/$(LARCH)/$(DEVICE)/bin
	-cp util/chkserv build/$(LARCH)/$(DEVICE)/bin
	-cp util/chkmachine build/$(LARCH)/$(DEVICE)/bin

#
# Changed clean to not remove the library, only the object files
#
# Also, it should not remove the "executables"
# We also do NOT clean util, since it has files (like mpicc) that are built
# by configure.  Builds with a new architecture
# should use make cleanslate
# We also remove the Makefile in nupshot after using it as it is created
# by the nupshot configure itself.
# We pass MAKE to the MPE Makefile to make sure that it has a valid
# version of make.  Since MPE is configured separately, it might have
# a make choice from a previous configuration.
clean:
	@-if [ -d tsuite ] ; then \
	    (cd tsuite ; $(MAKE) clean ) ; fi
	@-if [ -d bugs -a -s bugs/Makefile ] ; then \
	    (cd bugs ; $(MAKE) clean ) ; fi
	@-if [ -d mpid/server -a -s mpid/server/Makefile ] ; then \
	    (cd mpid/server ; $(MAKE) clean ) ; fi
	@-if [ -d romio -a -s romio/Makefile -a "@ROMIO@" = 1 ] ; then \
	    (cd romio ; $(MAKE) clean ) ; fi
	@-if [ -d installtest -a -s installtest/Makefile ] ; then \
	    (cd installtest ; $(MAKE) clean ) ; fi
	@-if [ -d MPI-2-C++ -a -s MPI-2-C++/Makefile -a "@buildcpp@" = 1 ] ; then \
	    (cd MPI-2-C++ ; $(MAKE) clean ) ; fi
	@-if [ -d mpe -a -s mpe/Makefile -a "@NOMPE@" = 0 ] ; then \
	    (cd mpe ; $(MAKE) MAKE="$(MAKE)" clean ) ; fi
	@-for dir in $(DIRS) ;\
	  do \
	  echo cleaning $$dir ;\
	  (cd $$dir ; if [ -s Makefile ] ; then $(MAKE) clean ; fi ) ;\
	  done
	-@if [ -s mpid/ch_shmem/p2ptest/Makefile ] ; then \
	    echo "cleaning mpid/ch_shmem/p2ptest" ; \
	    (cd mpid/ch_shmem/p2ptest ; $(MAKE) clean ) ; fi
	-@if [ -s mpid/tests/Makefile ] ; then \
	    (cd mpid/tests ; $(MAKE) clean ) ; fi
cleanslate: clean
	(cd util ; if [ -s Makefile ] ; then $(MAKE) clean ; fi )
#
# distclean removes mpirun etc as well as the libraries.
distclean: cleanslate
	/bin/rm -f *~ *.ln bin/mpirun bin/mpirun.args bin/mpirun.ch_p4 \
			   o bin/mpirun.ch_shmem bin/mpirun.pg bin/mpiman \
			    bin/mpireconfig bin/mpicc bin/mpiCC bin/mpif77 \
			    bin/mpif90 bin/mpiinstall bin/upshot bin/jumpshot \
			    installtest/Makefile 
	if [ -s util/Makefile ] ; then \
	    (cd util ; /bin/rm -f chkmachine chkserv Makefile ) ; fi 
	(cd util/machines ; \
	    /bin/rm -f machines.IRIX* machines.sun* machines.solaris* \
	    machines.cray* machines.CRAY* machines.LINUX machines.rs600 \
	    machines.alpha machines.hp* )
	/bin/rm -f doc/port doc/portbuild doc/portperf doc/porttest
	if [ -d mpid/server -a -s mpid/server/Makefile ] ; then \
	       (cd mpid/server ; $(MAKE) distclean) ; fi
	if [ -d jumpshot ] ; then \
	  /bin/rm -f jumpshot/confdefs.h jumpshot/config.log \
	  jumpshot/config.cache jumpshot/config.status ; fi
	if [ -d mpe -a -s mpe/Makefile -a "@NOMPE@" = 0 ] ; then \
	    (cd mpe ; $(MAKE) MAKE=$(MAKE) distclean ) ; fi
	/bin/rm -f build/*/*/lib/*.[oa]
	/bin/rm -f build/*/*/lib/*.[oa]
	/bin/rm -f build/*/*/lib/*.so.*
	/bin/rm -f build/*/*/lib/*.so
	/bin/rm -f build/*/*/lib/shared/*
	/bin/rm -f build/*/*/include/mpi*
	/bin/rm -f build/*/*/bin/mpi* build/*/*/bin/config.status \
	           build/*/*/bin/jumpshot build/*/*/bin/tstmachines
	/bin/rm -f ID
	for dir in $(DEVICES) ; do echo cleaning $$dir ; \
	     (cd $$dir ; if [ -s Makefile ] ; then \
	      $(MAKE) clean ; fi ) ; \
	done
	if [ -s mpid/ch_p4/Makefile ] ; then \
	    (cd mpid/ch_p4 ; $(MAKE) distclean ) ; fi
	if [ -s mpid/ch_shmem/Makefile ] ; then \
	    (cd mpid/ch_shmem ; $(MAKE) distclean ) ; fi
	if [ -d mpid/tests -a -s mpid/tests/Makefile ] ; then \
	    (cd mpid/tests ; $(MAKE) distclean ) ; fi
	if [ -s mpid/ch_p4/p4/Makefile ] ; then \
	    (cd  mpid/ch_p4/p4 ; $(MAKE) realclean ) ; fi
	if [ -s romio/Makefile ] ; then \
	    (cd  romio ; $(MAKE) cleanall ) ; fi
	if [ -d MPI-2-C++ -a -s MPI-2-C++/Makefile -a "@buildcpp@" = 1 ] ; then \
	    (cd MPI-2-C++ ; $(MAKE) distclean ) ; fi
	for dir in $(DIRS) ;\
	  do \
	  echo removing Makefile in $$dir ;\
	  (cd $$dir ; /bin/rm -f Makefile) ;\
	  done
	if [ -s examples/test/runtests ] ; then \
	    /bin/rm -f examples/test/runtests ; fi
	if [ -s examples/test/coll/runtests ] ; then \
	    /bin/rm -f examples/test/coll/runtests ; fi
	if [ -s examples/test/context/runtests ] ; then \
	    /bin/rm -f examples/test/context/runtests ; fi
	if [ -s examples/test/env/runtests ] ; then \
	    /bin/rm -f examples/test/env/runtests ; fi
	if [ -s examples/test/profile/runtests ] ; then \
	    /bin/rm -f examples/test/profile/runtests ; fi
	if [ -s examples/test/pt2pt/runtests ] ; then \
	    /bin/rm -f examples/test/pt2pt/runtests ; fi
	if [ -s examples/test/topol/runtests ] ; then \
	    /bin/rm -f examples/test/topol/runtests ; fi
	if [ -s examples/test/config.status ] ; then \
	      /bin/rm -f examples/test/config.status ; fi
	if [ -s src/env/Makefile ] ; then \
	    /bin/rm -f src/env/mpehname.c  src/env/farg.f ; fi
	/bin/rm -f Makefile config.log config.status 
#
# Make an ID database from a suitable subset of the sources
# (Get mkid from sunsite if you want to use this)
#
ID: frc
	find include src/coll src/context src/dmpi src/env src/pt2pt \
		src/topol src/util src/infoexport \
	mpid/ch2 mpid/$(DEVICE) mpid/util -name "*.[hc]" -print | mkid -v -

frc:



INSTALLDIR = /usr/local/mpi
#
# The install target really needs to use some for of 'install' program that
# will create directories, set modes and owners, etc.  Alas, such a function
# is not standard.
# Note that clean removes mpirun (!) and mpiinstall (!) so we need to make
# sure that it is around before doing the install
util/mpiinstall: bin/mpireconfig util/mpiinstall.in
	@-(cd util ; ../bin/mpireconfig mpiinstall ; rm -f .tmp ; \
	sed -e 1d mpiinstall > .tmp ; mv .tmp mpiinstall ; \
	chmod a+x mpiinstall )
install: mpirun util/mpiinstall
	@if [ ! -x util/mpiinstall ] ; then echo "No mpiinstall script!" ; fi
	./util/mpiinstall -prefix=$(PREFIX)

installlib: mpirun util/mpiinstall
	./util/mpiinstall -prefix=$(PREFIX) -libonly -device=$(DEVICE)

#
# Install adds ALL of the examples to the installation area
# This is an initial version.
install-all: install
	(/bin/rm $(PREFIX)/examples/*)
	-$(CPRP) -r examples $(PREFIX)
	# Update the makefiles
	(cd $(PREFIX)/examples ; \
		$(PREFIX)/build/$(LARCH)/$(DEVICE)/bin/mpireconfig Makefile ; \
		for dir in `find . -type d -print` ; do \
			(cd $$dir ; \
			if [ -s Makefile.in ] ; then \
			$(PREFIX)/build/$(LARCH)/$(DEVICE)/bin/mpireconfig Makefile ; \
			fi ) ; \
		done \
	)

etags:
	etags include/*.h mpid/$(DEVICE)/*.h $(CODEDIRS)

