#
#  Support files for the DSYEVR eigenvalue finding routine from LAPACK 3.
#  This Makefile includes the minimum set of routines needed to implement
#  DSYEVR using LAPACK 2 and 3 routines.  The Lahey compiler does not
#  support IEEE per se, and the ILAENV routine supplied with Lahey's
#  6.1 PRO compiler for Linux does not support the calls needed for
#  DSYEVR.  There appear to be other incompatibilities between the ILAENV
#  supplied by Lahey and the generic version available for download from
#  Netlib.  I have manually turned off the IEEE support by setting 
#  IEEEOK = 0 in dsyevr_ek.f.
#  The issues with Lahey are the following:
#  (1) optimization corrupts the correct handling of NaNs in ieeeck.f
#  and dlamch.f.
#  (2) Disabling optimization allow correct handling of NaNs in ieeeck.f
#  and dlamch.f.
#  (3) Compiling dsyevr.f and dependent routines with -O0 and linking the
#  rest with lapackmt and blasmt yields apparent infinite loops at times.
#
SOURCES = dsyevr_ek.f dstegr.f dlarrb.f dlarre.f dlarrf.f dlarrv.f dlar1v.f \
	dlasq2.f dlasq3.f dlasq4.f dlasq5.f dlasq6.f
OBJECTS = dsyevr_ek.o dstegr.o dlarrb.o dlarre.o dlarrf.o dlarrv.o dlar1v.o \
	dlasq2.o dlasq3.o dlasq4.o dlasq5.o dlasq6.o
SUPPORT = ..
#
#  SGI
#
#LIBS =
#DEBUG = -g -c -DEBUG:trap_uninitialized -DEBUG:conform_check=YES \
   #-DEBUG:verbose_runtime=YES -DEBUG:subscript_check=YES \
   #-ansi -fullwarn -woff 878,1438,1584 -Dsgi
#OPT = -O -c -OPT:swp=ON -g3 -Dsgi -ansi -fullwarn -woff 878,1438,1584
#F95 = f90

#
#  Sun
#
#LIBS = 
#DEBUG = -g -c -C -ansi -ftrap=invalid -stackvar -u -w4
#OPT = -O4 -c -ftrap=invalid -stackvar -u
#F95 = f95

#
# Lahey - add --trap for f.p. trapping (but not with these e.v. routines)
#
#  --f95 adds extra checking for nonstandard constructs.  There should be
#  none in this code, except for "call exit" statements (which are de facto
#  standard).
#  Use --info for more details on code optimizations
#  Use --lst for a listing (mostly useful with --lst)
#
LIBS = 
DEBUG = -g -c --trace --chk a,e,s --f95 
OPT = -O -c --trace --f95
F95 = lf95

FFLAGS = $(OPT) 
EVFLAGS= $(DEBUG) -I..
#FFLAGS = $(DEBUG) 

.SUFFIXES: .o .mod .f .f90 .f95 .F90 .F95
.F90.o:
	$(F95)  $(FFLAGS) $<
.f90.mod:
	$(F95)  $(FFLAGS) $<
.f95.mod:
	$(F95)  $(FFLAGS) $<
.f.o:
	$(F95)  $(FFLAGS) $<
.f90.o:
	$(F95)  $(FFLAGS) $<
.f95.o:
	$(F95)  $(FFLAGS) $<

libev.a($(OBJECTS)) : $(OBJECTS)
	cd eispack; make
	ar r libev.a $(OBJECTS)
	cp libev.a ..

(%.o): %.f

all:
dsyevr_ek.o:
dstegr.o:
dlarrb.o:
dlarre.o:
dlarrf.o:
dlarrv.o:
dlar1v.o:
testev: testev.f90 
	$(F95) $(EVFLAGS) testev.f90 
	$(F95) testev.o $(SUPPORT)/ferror.o -L. -lev -llapackmt -lblasmt -o testev
clean:
	cd eispack; make clean
	rm -f libev.a $(OBJECTS)

backup:
	tar cf - $(SOURCES) Makefile | gzip > ev.tar.gz
