ARCH        = LINUX
RANLIB      = ranlib
FILE_SYSTEM = testfs ufs nfs
MAKE        = make
AR          = ar cr
LIBNAME     = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/lib/libmpich.a
NOF77       = 0
NOPROFILE   = 0
MPI         = mpich
PREFIX      = /proj/tpfimos/larour/Libraries/linux/mpich2-gnu/
BUILD_MPI_INFO = 
BUILD_MPI_ARRAY = 
DIRS        = mpi-io adio/common mpi-io/glue/mpich2
MPIO_DIRS   = mpi-io
EXTRA_SRC_DIRS = 
FILE_SYS_DIRS =  adio/ad_testfs adio/ad_ufs adio/ad_nfs
ALL_DIRS    = mpi-io mpi-io/fortran mpi2-other/info mpi2-other/info/fortran mpi2-other/array mpi2-other/array/fortran adio/common adio/ad_pfs adio/ad_piofs adio/ad_nfs adio/ad_ufs adio/ad_xfs adio/ad_hfs adio/ad_sfs adio/ad_testfs adio/ad_pvfs adio/ad_pvfs2 adio/ad_panfs adio/ad_gridftp test
SHELL       = /bin/sh

VPATH = .:${srcdir}

all: mpio

# The sleep 1 at the end of the build is used to ensure that make
# builds the libraries for any steps that *follow* this one and
# use the same library.  This is a work around for a bug in make that 
# is related to the use of file time stamps in make, but is in fact
# a bug in the logic of several make implementations, including gnumake
#
# The make clean /make profile /make clean handles the rebuilding of
# the object files with the same names but with different CPP definitions.
# If weak symbols are supported or profiling is turned off, we don't
# need to rebuild everything.
#
# Eventually, the clean at the top will also be removed, at least for the
# MPICH builds (which do their own clean if required)
#	$(MAKE) clean
mpio:
	$(MAKE) mpiolib
	@if [ "$(NOPROFILE)" = 0 ] ; then\
            $(MAKE) profile; \
        fi;\
	$(RANLIB) $(LIBNAME)
	@if [ "$(WITHIN_KNOWN_MPI_IMPL)" = no ] ; then \
           echo " "; \
           echo "Completed build of ROMIO. Check the output for errors."; \
           echo " " ;\
           echo "To compile the example programs, cd to the test directory"; \
           echo "and type make."; \
           echo "Run the examples the way you would run any MPI program."; \
           echo "Each program takes the filename as a command-line argument"; \
           echo "'-fname filename'." ; \
           echo " " ;\
        fi
	@sleep 1

# FIXME: This should invoke the clean targets in each of the Makefiles.
clean:
	@-rm -f work.pc work.pcl
	@for dir in $(DIRS) $(FILE_SYS_DIRS) $(EXTRA_SRC_DIRS) ;\
         do \
            echo " " ;\
            echo cleaning directory $$dir ;\
            (cd $$dir && rm -f *.o *.lo) ;\
         done; \
         echo " " ;\
         echo cleaning directory test ;\
         (cd test && $(MAKE) clean);\
         echo " ";

mpiolib:
	@if [ "$(WITHIN_KNOWN_MPI_IMPL)" = no ] ; then \
            echo " " ;\
            echo "deleting previously built library if it exists" ;\
            rm -f $(LIBNAME) ;\
        fi
	@for dir in $(DIRS) $(FILE_SYS_DIRS) $(EXTRA_SRC_DIRS) ;\
         do \
            echo " " ;\
            echo compiling ROMIO in directory $$dir ;\
	    sleep 1;\
            (cd $$dir && $(MAKE) ;) ;\
            if [ $$? != 0 ] ; then \
                echo "Make failed in directory $$dir" ; exit 1 ;\
            fi ;\
         done

profile: 
	@if [ "1" = 0 ] ; then \
	    $(MAKE) clean ;\
	   for dir in $(MPIO_DIRS) $(EXTRA_SRC_DIRS) ;\
              do \
               echo " " ;\
               echo building profiling interface in directory $$dir ;\
               sleep 1;\
               (cd $$dir && \
                $(MAKE) profile MPIOPROFILE="-DMPIO_BUILD_PROFILING";) ;\
                if [ $$? != 0 ] ; then \
                    echo "Make failed in directory $$dir" ; exit 1 ;\
                fi ;\
            done ;\
	   $(MAKE) clean ;\
	fi

coverage:
	(cd mpi-io && make coverage)
	(cd adio/ad_ufs && make coverage)
	(cd adio/ad_nfs && make coverage)

cleanall:
	@dirs=`echo "$(ALL_DIRS)"`; \
	echo "cleaning test directory" ;\
	(cd test && ${MAKE} cleanall ) ;\
        echo cleaning current directory ;\
        (rm -f config.status Makefile *~ *.log romio.tar*) ;\
        for dir in $$dirs ;\
         do \
            echo " " ;\
	    if [ ! -d $$dir ] ; then continue ; fi ; \
            echo cleaning directory $$dir ;\
            (cd $$dir; rm -f *.o Makefile *~) ;\
         done; \
         echo " " ;\
         echo "cleaning directory include" ;\
         (cd include; rm -f *.h);\
         echo " " ;\
         echo "cleaning directory util" ;\
         (cd util; rm -f romioinstall *~)
	-rm -f lib

install:
	$(MAKE) clean
	@./util/romioinstall -prefix=$(PREFIX)

# LAM added uninstall target
uninstall:
	@./util/romioinstall -prefix=$(PREFIX) -uninstall

romio_lflags:
	@echo ''

romio_liblist:
	@echo ' -lpthread  -lrt '

romio_tcflags:
	@echo ''

romio_tcppflags:
	@echo ''

romio_tfflags:
	@echo ''

# distclean the standard form for cleanall
distclean: cleanall

# Allow dependencies target
dependencies:

# MPICH2 documentation targets
mandoc:
	(cd mpi-io && $(MAKE) mandoc )
htmldoc:
	(cd mpi-io && $(MAKE) htmldoc )
latexdoc:
	(cd mpi-io && $(MAKE) latexdoc )


tags: TAGS
TAGS:
	for dir in mpi-io adio/common - ; do \
		if [ "$$dir" = "-" ] ; then break ; fi ; \
		(cd $$dir && ${MAKE} TAGS ; ) ; done
