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

MAKE                 = make --no-print-directory

MPI_CC               = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/bin/mpicc
MPI_F77              = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/bin/mpif77
MPI_CLINKER          = $(MPI_CC)
MPI_FLINKER          = $(MPI_F77)
#
DEBUG_LIBS           = 
MPI_INC              = 
MPI_LIBS             = 
CFLAGS               = 
FFLAGS               = 
MPE_INCDIR           = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/include
MPE_LIBDIR           = /proj/tpfimos/larour/Libraries/linux/mpich2-1.0.2p1/src/mpe2/lib
ANIM_LIBS            = -L$(MPE_LIBDIR) -lampe -lmpe -L/usr/X11R6/lib -lX11 $(MPI_LIBS)
C_XGRAPH_LIBS        = -L$(MPE_LIBDIR) -lmpe -L/usr/X11R6/lib -lX11 $(MPI_LIBS)
F_XGRAPH_LIBS        = -L$(MPE_LIBDIR) -lmpe -L/usr/X11R6/lib -lX11 $(MPI_LIBS)
#
C_INCS               = -I$(MPE_INCDIR) $(MPI_INC)
F_INCS               = -I$(MPE_INCDIR) $(MPI_INC)
LDFLAGS              = 
MPE_BUILD_FORTRAN2C  = yes
RM                   = rm 

### End User configurable options ###

VPATH=.:$(srcdir)

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

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 cxgraphics

.SUFFIXES: .c .f .o 

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

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

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

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

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

linktest: linktest_C

linktest_C: 
	@-echo ; \
	echo "** Testing if C application can be linked with animation library" ; \
	$(RM) -f cpi_anim ; \
	$(MAKE) cpi_anim ; \
	if test -x cpi_anim ; then \
	    echo "** C application can be linked with animation library" ; \
	    $(RM) -f cpi_anim ; \
	else \
	    echo "** C application CANNOT be linked with animation library" ; \
	fi
	@-echo ; \
	echo "** Testing if C application can be linked with graphics library" ; \
	$(RM) -f cxgraphics ; \
	$(MAKE) cxgraphics ; \
	if test -x cxgraphics ; then \
	    echo "** C application can be linked with graphics library" ; \
	    $(RM) -f cxgraphics ; \
	else \
	    echo "** C application CANNOT be linked with graphics library" ; \
	fi ; \
	echo
	@-$(MAKE) clean

linktest_F77: 
	@-if [ "$(MPE_BUILD_FORTRAN2C)" = "yes" ] ; then \
	      echo ; \
	      echo "** Testing if Fortran77 application can be linked with graphics library" ; \
	      $(RM) -f fxgraphics ; \
	      $(MAKE) fxgraphics ; \
	      if test -x fxgraphics ; then \
	          echo "** Fortran77 application can be linked with graphics library" ; \
	          $(RM) -f fxgraphics ; \
	      else \
	          echo "** Fortran77 application CANNOT be linked with graphics library" ; \
	      fi ; \
	      echo ; \
	      $(MAKE) clean ; \
	  fi

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

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