ALL: all

MAKE   = make --no-print-directory
SHELL  = /bin/sh
MKDIR  = mkdir
RM     = rm
CP     = cp

top_srcdir        = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/src/graphics
srcdir            = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/src/graphics

# Build directories
includebuild_dir  = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/include
libbuild_dir      = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/lib
binbuild_dir      = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/bin
sbinbuild_dir     = @sbinbuild_dir@

# Building Fortran to C interface
MPE_BUILD_FORTRAN2C  = yes
# MPI implementation: used to turn on/off of certain feature
MPI_IMPL             = MPICH2
# MPE header files that are needed by endusers
MPE_HEADERS          = mpe_graphics.h mpe_graphicsf.h

# Assumption: This Makefile won't be created if X is not available
all: build_include build_lib_bin linktest_all

#######  Building from the source
build_include:
	@-if [ -n "$(includebuild_dir)" ] ; then \
	      if [ ! -d $(includebuild_dir) ] ; then \
	          $(MKDIR) -p $(includebuild_dir) ; \
	      fi ; \
	      for file in $(MPE_HEADERS) ; do \
	          if [ -f $(top_srcdir)/include/$$file ] ; then \
	              $(CP) -f $(top_srcdir)/include/$$file \
	                       $(includebuild_dir) ; \
	          fi ; \
	      done ; \
	  fi

build_lib_bin:
	@( cd src && $(MAKE) )

########  Linkage Tests
linktest_all: linktest_C linktest_F77

linktest_C:
	@if [    "$(MPI_IMPL)" != "MPICH" \
	      -a "$(MPI_IMPL)" != "MPICH2" ] ; then \
	     ( cd contrib/test && $(MAKE) linktest_C ) ; \
	 fi

linktest_F77:
	@if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	     if [    "$(MPI_IMPL)" != "MPICH" \
	          -a "$(MPI_IMPL)" != "MPICH2" ] ; then \
	         ( cd contrib/test && $(MAKE) linktest_F77 ) ; \
	     fi ; \
         fi
	@echo

########  Cleaning
# This is always a VPATH build, cleaning up the MPE_HEADERS
clean_include:
	@-cd $(includebuild_dir) && \
	  for file in $(MPE_HEADERS) ; do \
	      $(RM) -f $$file ; \
	  done

clean_lib:

clean_bin:

clean: clean_bin clean_lib
	@( cd src && $(MAKE) clean )

distclean: clean_include clean_bin clean_lib
	@-( cd src && $(MAKE) distclean )
	@-$(RM) -f mpe_graphics_conf.h
	@-$(RM) -f Makefile contrib/*/Makefile
	@-$(RM) -f config.log config.status
	@-$(RM) -rf autom4te*.cache

maintainer-clean: distclean
	@-$(RM) -f mpe_graphics_conf.h.in

owner-clean: maintainer-clean
	@-$(RM) -f configure
