
##### User configurable options #####

MAKE                 = @MAKE@

MPI_CC               = @MPI_CC@
MPI_F77              = @MPI_F77@
MPI_CLINKER          = $(MPI_CC)
MPI_FLINKER          = $(MPI_F77)
#
DEBUG_LIBS           = @DEBUG_LIBS@
MPI_INC              = @MPI_INC@
MPI_LIBS             = @MPI_LIBS@
CFLAGS               = @CFLAGS@
FFLAGS               = @FFLAGS@
MPE_INCDIR           = @includebuild_dir@
MPE_LIBDIR           = @libbuild_dir@
MPE_SBINDIR          = @sbinbuild_dir@
ANIM_LIBS            = -L$(MPE_LIBDIR) @ANIM_LIBS@ $(MPI_LIBS)
C_XGRAPH_LIBS        = -L$(MPE_LIBDIR) @XGRAPH_LIBS@ $(MPI_LIBS)
F_XGRAPH_LIBS        = @FLIB_PATH_LEADER@$(MPE_LIBDIR) @XGRAPH_LIBS@ $(MPI_LIBS)
#
C_INCS               = -I$(MPE_INCDIR) $(MPI_INC)
F_INCS               = @FINC_PATH_LEADER@$(MPE_INCDIR) $(MPI_INC)
LDFLAGS              = @LDFLAGS@
MPE_BUILD_FORTRAN2C  = @MPE_BUILD_FORTRAN2C@

### End User configurable options ###

SHELL         = @SHELL@
RM            = @RM@ 

@VPATH@

srcdir        = @srcdir@

CC_FLAGS      = $(CFLAGS) $(C_INCS) $(MPE_COPTS)
FC_FLAGS      = $(FFLAGS) $(F_INCS) $(MPE_FOPTS)
CC_LDFLAGS    = $(LDFLAGS) $(CFLAGS) $(MPE_LDOPTS)
FC_LDFLAGS    = $(LDFLAGS) $(FFLAGS) $(MPE_LDOPTS)
EXECS         = cpi_anim@EXEEXT@ cxgraphics@EXEEXT@

.SUFFIXES: .c .f .@OBJEXT@ @EXEEXT@

.c.@OBJEXT@:
	$(MPI_CC) $(CC_FLAGS) -c $<
.f.@OBJEXT@:
	$(MPI_F77) $(FC_FLAGS) -c $<

default: $(EXECS)
	-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	     $(MAKE) fxgraphics@EXEEXT@ ; \
	 fi

cpi_anim@EXEEXT@: cpi.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(ANIM_LIBS) $(DEBUG_LIBS) -lm 

cxgraphics@EXEEXT@: cxgraphics.@OBJEXT@
	$(MPI_CLINKER) $(CC_LDFLAGS) -o $@ $? $(C_XGRAPH_LIBS) $(DEBUG_LIBS) -lm

fxgraphics@EXEEXT@: fxgraphics.@OBJEXT@
	$(MPI_FLINKER) $(FC_LDFLAGS) -o $@ $? $(F_XGRAPH_LIBS) $(DEBUG_LIBS) -lm

linktest: linktest_C

linktest_C: 
	@-$(MPE_SBINDIR)/mpetestlink cpi_anim@EXEEXT@ \
	  "*** Link C program with the MPI animation library ........................"
	@-$(MPE_SBINDIR)/mpetestlink cxgraphics@EXEEXT@ \
	  "*** Link C program with the X11 graphics library ........................."
	@-echo ; $(MAKE) clean

linktest_F77: 
	@-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	      $(MPE_SBINDIR)/mpetestlink fxgraphics@EXEEXT@ \
	      "*** Link F77 program with the X11 graphics library ......................." ; \
	      $(MAKE) clean ; \
	      echo ; \
	  fi

runtest_C: 
	@-$(MPE_SBINDIR)/mpetestexec cpi_anim@EXEEXT@ \
	  "*** Test C program with the MPI animation library ........................"
	@-$(MPE_SBINDIR)/mpetestexec cxgraphics@EXEEXT@ \
	  "*** Test C program with the X11 graphics library ........................."
	@-echo ; $(MAKE) clean

runtest_F77: 
	@-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	      $(MPE_SBINDIR)/mpetestexec fxgraphics@EXEEXT@ \
	      "*** Test F77 program with the X11 graphics library ......................." ; \
	      $(MAKE) clean ; \
	      echo ; \
	  fi

clean:
	@-$(RM) -f work.pc work.pcl
	@-$(RM) -f *.@OBJEXT@ *~ PI* $(EXECS)
	@-$(RM) -f cpi_anim@EXEEXT@ cxgraphics@EXEEXT@ fxgraphics@EXEEXT@

distclean: clean
	@-$(RM) -f Makefile
