# makefile for the KAPISN test code, Jon Kinsey, GA
#   in "Lehigh University" style...
#
# for HP-UX system, the IBM RS/6000 system running AIX v4, 
#    the Solaris system, the SGI IRIX system, the DEC alpha system,
#    or Linux systems using either the NAG or Portland Group compilers.
#    Use `gmake clean' to remove all .o files
#
# environment variable CPU is used to set platform-dependent make variables.
#
ifeq ($(CPU),)
   # CPU is undefined; default to HP.
   WARNcpu = 2
   CPU = HP
endif
ifeq ($(filter $(CPU), IBM SOL SGI DEC HP NAG PGI),)
   ERRcpu = 2
endif
#
# Compilation/linking flags
# ...RS6000
#
ifeq ($(CPU),IBM)
   FFLAGS  = -O -qmaxmem=-1
   FFLAGS2 = -qfixed=72 -c
   FC=xlf90
endif
#
# For Solaris compilers, these compilation flags are:
#   NOTE NO -r8 OPTION for SOL !!!
#
ifeq ($(CPU),SOL)
   FFLAGS  = -O
   FFLAGS2 = -c
   FC=f90
endif
#
# For SGI compilers, these compilation flags are (in order):
#
ifeq ($(CPU),SGI)
   FFLAGS  = -O -ftpp -macro_expand
   FFLAGS2 = -c
   FC=f90
endif
#
# For HP compilers, these compilation flags are (in order):
#
ifeq ($(CPU),HP)
   FFLAGS  = -C +DA1.1 +DS1.1
   FFLAGS2 = -c
   FC=f90
endif
#
# For DEC-alpha workstations (dmc)
#
ifeq ($(CPU),DEC)
   FFLAGS  = -O
   FFLAGS2 = -c
   FC=f90
endif
#
# For NagWare (Linux) (dmc)
#
ifeq ($(CPU),NAG)
   FFLAGS = -O -dusty -D__NAGWARE
   FFLAGS2 = -c
   FC=f95
endif
#
# For Portland Group (Linux) (jek)
# Optimized for Pentium II processor
#
ifeq ($(CPU),PGI)
   FFLAGS = -fast -tp p6
   FFLAGS2 = -c
   FC=pgf90
endif
# For the Cray J-90,
#
ifeq ($(CPU),J90)
   FFLAGS = -O -D__CRAY
   FFLAGS2 = -c
   FC=f90
endif
#
# Compiling and Linking commands
#
COMPILE = $(FC) $(FFLAGS) $(FFLAGS2)
LINK    = $(FC) $(FFLAGS)
#
# Targets and Rules
#

testkapisn xtverb::   cputst
        # without any rule, make tries to build c code
	@echo 

testkapisn::  testkapisn.o kapisn.o stripx.o
	$(LINK) -o testkapisn testkapisn.o kapisn.o stripx.o

stripx.o:	stripx.f
	$(COMPILE) -o stripx.o stripx.f

kapisn.o:	kapisn.f
	$(COMPILE) -o kapisn.o kapisn.f

testkapisn.o:	testkapisn.tex xtverb
	touch testkapisn.f
	rm testkapisn.f
	-./xtverb < testkapisn.tex > testkapisn.f
	$(COMPILE) -o testkapisn.o testkapisn.f

xtverb::	xtverb.f
	$(COMPILE) -o xtverb.o xtverb.f
	$(LINK) -o xtverb xtverb.o

cputst:
  ifeq ($(ERRcpu),2)
	@echo CPU=$(CPU) is not yet implemented in KAPISN makefile.
	@exit 2
  endif
  ifeq ($(WARNcpu),2)
	@echo CPU defaulted, CPU=HP assumed.
  endif

clean:
	@rm *.o xtverb


