#
#  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
OBJECTS = dsyevr_ek.o dstegr.o dlarrb.o dlarre.o dlarrf.o dlarrv.o dlar1v.o

SUPPORTDIR = $$HOME/lekf/support
LIB = $(SUPPORTDIR)/libev.a
#
#  SGI
#
#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
#
#DEBUG = -g -c -C -ansi -ftrap=invalid -stackvar -u -w4
#OPT = -O4 -c -ftrap=invalid -stackvar -u
#F95 = f95

#
#  Lahey - Do NOT --trap for f.p. trapping with these e.v. routines.
#
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) $<

all: $(OBJECTS)
	ar r $(LIB) $(OBJECTS)

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 $(SUPPORTDIR)/ferror.o -L$(SUPPORTDIR) \
	   -lev -llapackmt -lblasmt -o testev
clean:
	rm -f $(OBJECTS) core a.out libev.a
