CC       = cc -DIRIX
FC       = f77
AR       = ar
RM       = rm
RANLIB   = ranlib
SHELL    = /bin/sh
LINKER   = f77
# Pick these based on main program language
CLINKER = cc
FLINKER = f77
# -lF77 is needed for linking with some Fortran routines that use things like
# dsign.
SLIB     = -lfpe -lsun -lF77
# Blas libraries
# WARNING: the SGI BLAS libraries MAY require that the multiprocessing 
# libraries ALSO be included!
BLAS1 = -lblas -mp
BLAS2 = -lblas -mp
BLAS3 = -lblas -mp
#BLAS  = /usr/lib/libblas.a -lblas -mp
BLAS  = -lblas -mp
LAPACK = $(ITOOLSDIR)/libs/libs$(BOPT)/IRIX/liblapack.a

libbuild: $(SOURCE)
	for i in $(OBJS); do make libmember LIBMEMBER=$$i ; done
lib: $(SOURCE)
	for i in $(OBJS); do make libmember LIBMEMBER=$$i ; done
# liball is a version that builds the source files all at once and then
# adds them, again all at once, to the archive.  Because of the poor
# performance of some archive programs, this can significantly improve
# the speed of an original installation.
liball: $(SOURCEC) $(SOURCEF)
	if [ "$(SOURCEC)" != "" ] ; then \
	     $(CC) -c $(CFLAGS) $(BASEOPT) $(SOURCEC) ;\
	fi
	if [ "$(SOURCEF)" != "" ] ; then \
	     $(FC) -c $(FFLAGS) $(BASEOPTF) $(SOURCEF) ;\
	fi
	$(AR) clq $(LIBNAME) $(OBJS)
	$(RM) $(OBJS)
	

libmember:    $(LIBNAME)($(LIBMEMBER))

deletelibs:
	if (test -w $(LIBNAME)) then $(RM) $(LIBNAME) ; fi

lint:
	lint -cvhu -DLINT $(SOURCE)

lintlib:
	lint -cvhu -DLINT -Cltmp $(IFLAGS) $(SOURCE)
	mv llib-lltmp.ln $(LIBBASE).ln

.c.a: 
	$(CC) -c $(CFLAGS) $(BASEOPT) $*.c
	$(AR) cr $(LIBNAME) $*.o
	rm $*.o
.c.o: 
	$(CC) -c -DIRIX $(CFLAGS) $(BASEOPT) $*.c
.f.o: 
	$(FC) -c $(FFLAGS) $(BASEOPTF) $*.f

.f.a: 
	$(FC) -c $(FFLAGS) $(BASEOPTF) $*.f
	$(AR) cr $(LIBNAME) $*.o
	rm $*.o

# the IRIX is very picky about static functions they must be declared
# as static functions before being used otherwise it will use the 
# nonstatic one or have an unresolved symbol.

# The following appeared on the network on changing quiet NaNs to 
# signaling NaNs:
#        To do this on the SGI, you need to set the environment and load the
#floating point library.  When you are through, reset the environment.  The 
#following example will work quite nicely.  Refer to the man page for fpe for
#details.
#
##
## Trap floating pointing errors for overflows, invalid operations, and
##   divide by zero.  All underflows will be ignored and set to 0.0.
##
##      Overflow - set to NaN to avoid multiple overflows
##
#setenv TRAP_FPE "DEBUG; OVERFL =INF,COUNT,TRACE(10),EXIT(100); INVALID=IEEE,COUN
#T,TRACE(10),EXIT(100); DIVZERO=INF,COUNT,TRACE(10),EXIT(100)"
##
## compile and load with libfpe.a library
##
#f77 -g -C -o sample sample.f /usr/lib/libfpe.a
##
## execute
##
#sample  
##
## turn off trapping of floating point errors
##
#setenv TRAP_FPE="OFF"

