# Generated automatically from Makefile.in by configure.
ALL: default
##### User configurable options #####

SHELL       = /bin/sh
ARCH        = LINUX
MPIR_HOME   = /usr/
CC          = mpicc
CLINKER     = $(CC)
F77         = mpif77 -I/usr/include -L/usr/lib
FLINKER     = $(F77)
F90         = mpif77 -I/usr/include -L/usr/lib
F90LINKER   = $(F90)      
CCC         = mpiCC
CCLINKER    = $(CCC)
AR          = ar crl
RANLIB      = ranlib
LOG_LIB     = -mpilog -lm
PROF_LIB    = -lmpe -lm
OPTFLAGS    = 
#MPE_DIR     = /root/mpich-1.2.3/mpe
MAKE        = make --no-print-directory
#
srcdir=~/basic

VPATH=.:$(srcdir)
### End User configurable options ###
.SUFFIXES:	.cc .C .f90

CFLAGS	  = $(OPTFLAGS) 
CFLAGSMPE = $(CFLAGS) -I$(MPE_DIR)/include 
CCFLAGS	  = $(CFLAGS)
#FFLAGS	  = '-qdpc=e' 
FFLAGS	  = $(OPTFLAGS)
EXECS	  = cpi systest srtest 
ALL_EXECS = ${EXECS} fpi cpilog cpi_autolog hello++ iotest pi3f90 

all: cpi systest srtest fpi cpilog hello++ iotest pi3f90 

#
# The cp for pi3f90 is needed because different Fortran 90 compilers
# accept *different* suffixes.
# pi3f90 also wants an MPI module.  If modules not supported, don't
# try to build pi3f90
default: $(EXECS)
	@if [ "1" = 1 -a -s iotest.c ] ; then $(MAKE) iotest ; fi
	@if [ "1" = 1 ] ; then $(MAKE) hello++ ; fi
	@if [ "0" = 0 ] ; then $(MAKE) fpi ; fi
	@if [ "0" = 0 ] ; then $(MAKE) cpilog ; fi
	@if [ "0" = 0 ] ; then $(MAKE) cpi_autolog ; fi
	@if [ -n "-I" ] ; then \
	    if [ ! -s pi3f90.f90 ] ; then \
		cp ${srcdir}/pi3f90.f90 pi3f90.f90 ; fi ; \
	    $(MAKE) pi3f90 ; fi


fpi: fpi.o 
	$(FLINKER) $(OPTFLAGS) -o fpi fpi.o

# Some Fortran 90 compilers do not accept a .f90 suffix (xlf90 for one)
pi3f90.o: pi3f90.f90
	$(F90) $(FFLAGS) -c pi3f90.f90
pi3f90: pi3f90.o
	$(F90LINKER) $(OPTFLAGS) -o pi3f90 pi3f90.o

cpi: cpi.o
	$(CLINKER) $(OPTFLAGS) -o cpi cpi.o -lm

cpi_autolog: cpi.o
	$(CLINKER) $(OPTFLAGS) -o cpi_autolog cpi.o $(LOG_LIB)

cpilog: cpilog.o
	$(CLINKER) $(OPTFLAGS) -o cpilog cpilog.o $(PROF_LIB)

srtest: srtest.o
	$(CLINKER) $(OPTFLAGS) -o srtest srtest.o -lm

systest: systest.o
	$(CLINKER) $(OPTFLAGS) -o systest systest.o -lm

iotest: iotest.o
	$(CLINKER) $(OPTFLAGS) -o iotest iotest.o -lm

hello++: hello++.o
	$(CCLINKER) hello++.o -o hello++

unsafe: unsafe.o
	$(CLINKER) $(OPTFLAGS) -o unsafe unsafe.o 
# Intel Fortran (ifc) creates work.*; pgCC creates .ti and .ii files
clean:
	rm -f work.pc work.pcl
	rm -f *.o *~ PI* $(ALL_EXECS) upshot rdb.* startup.* core
	rm -f hello++.ti hello++.ii

cpilog.o: cpilog.c
	@if test -z "$(MPE_DIR)" ; then \
	    echo "Can only build cpilog if MPE libraries built" ; \
	    echo "Use -mpe to configure to have the MPE libraries built" ; \
	    exit 1 ; \
	fi
	$(CC) $(CFLAGSMPE) -c ${srcdir}/cpilog.c
.c.o:
	$(CC) $(CFLAGS) -c $<
.f.o:
	$(F77) $(FFLAGS) -c $<
.cc.o:
	$(CCC) -c $<
.C.o:
	$(CCC) -c $<
.f90.o:
	$(F90) -c $<
