#
#	Makefile for the RW Vector and Matrix library, using GNU g++
#
# 
#	Copyright (C) 1988, 1989.
#
#	Dr. Thomas Keffer
#	Rogue Wave Associates
#	P.O. Box 85341
#	Seattle WA 98145-1341
#
#	Permission to use, copy, modify, and distribute this
#	software and its documentation for any purpose and
#	without fee is hereby granted, provided that the
#	above copyright notice appear in all copies and that
#	both that copyright notice and this permission notice
#	appear in supporting documentation.
#	
#	This software is provided "as is" without any
#	expressed or implied warranty.
#
# 
# 	@(#)Makefile	2.2	9/18/89
#
#
###################################################################
#
#	Things to check:
#
#	LIBDIR:		Where to install finished library
#	INCLDIR:	Where to install header files
#	FPFLAG:		Type of floating point flag for Fortran
#	CFPFLAG:	Type of floating point flag for C++
#	CCDEBUG:	Uncomment as necessary for production version
#
###################################################################
#
#		Where the library should be installed:
LIBDIR=		/usr/local/lib

#		Where the include files should be installed:
INCLDIR=	/usr/local/include/rw

#		Fortran Floating Point flag (for mathpack)
FPFLAG=		-f68881

#		Floating point flag for C++
CFPFLAG=	-m68881

#		C++ compiler to use:
CCXX= 		g++

#		CC debug flag. Uncomment -O for production version (not tried)
CCDEBUG=	-g -DDEBUG
#CCDEBUG=	-O -finline-functions

#		Location of include files
INCLFLAGS=	-I./..

#		Rootname of target library
LIB=		RVector
LIBFILE=        lib${LIB}.a

#		Name for the math library
MATHLIB=	libmathpack.a

CXXFLAGS = 	${INCLFLAGS} ${CCDEBUG} $(CFPFLAG)

#		Object files to be made:
OBJECTS=	dblock.o dvec.o dvecio.o dvecop.o\
		dvecmath.o\
		fblock.o fvec.o fvecio.o fvecop.o\
		fvecmath.o\
		cblock.o cvec.o cvecio.o cvecop.o\
		cvecmath.o\
		iblock.o ivec.o ivecio.o ivecop.o\
		ivecmath.o\
		fvecx.o ivecx.o\
		dcosine.o dfft.o cfft.o dmath.o\
		dgemat.o dgematop.o dgematio.o dgematmath.o\
		fgemat.o fgematop.o fgematio.o fgematmath.o\
		cgemat.o cgematop.o cgematio.o cgematmath.o\
		igemat.o igematop.o igematio.o igematmath.o\
		dludecmp.o\
		fludecmp.o\
		timer.o utility.o

#		Derived source files:
DERIVEDSRCS=	dblock.cc dvec.cc dvecio.cc dvecop.cc\
		dvecmath.cc dvectest.cc\
		fblock.cc fvec.cc fvecio.cc fvecop.cc\
		fvecmath.cc fvectest.cc\
		cblock.cc cvec.cc cvecio.cc cvecop.cc\
		cvecmath.cc cvectest.cc\
		iblock.cc ivec.cc ivecio.cc ivecop.cc\
		ivecmath.cc ivectest.cc\
		dgemat.cc dgematop.cc dgematio.cc dgemattest.cc dgematmath.cc\
		fgemat.cc fgematop.cc fgematio.cc fgemattest.cc fgematmath.cc\
		cgemat.cc cgematop.cc cgematio.cc cgemattest.cc cgematmath.cc\
		igemat.cc igematop.cc igematio.cc igemattest.cc igematmath.cc\
		dludecmp.cc dludtest.cc\
		fludecmp.cc fludtest.cc

#		All source files:
SRCS=		${DERIVEDSRCS}\
		fvecx.cc ivecx.cc\
		dcosine.cc dfft.cc cfft.cc dmath.cc\
		timer.cc utility.cc\
		testcfft.cc testdfft.cc testcos.cc

TARGET=		testmath

#		Test program suite:
TESTPGMS=	dvectest cvectest fvectest\
		dgemattest fgemattest cgemattest igemattest\
		testcfft testdfft testcos\
		dludtest fludtest

###################   Targets    #################

${LIBFILE}:	${OBJECTS}
	ar rvu ${LIBFILE} $?
	ranlib ${LIBFILE}

${MATHLIB}:
	cd mathpack; make "FPFLAG=${FPFLAG}"

mathpack:	${MATHLIB}

test:
	for pgm in ${TESTPGMS}; do \
		(echo $$pgm; \
		make $$pgm TARGET=$$pgm ); \
	done

verify:
	rm -f cvectest.out	# Complex output differs between gnu & att
	rm -f cgemattest.out
	cp cvectest.gnu cvectest.out
	cp cgemattest.gnu cgemattest.out
	-for pgm in ${TESTPGMS}; do \
		(echo $$pgm; \
		$$pgm | diff -c -b $$pgm.out - ); \
	done

install:	${LIBFILE} ${MATHLIB}
	cp ${LIBFILE} ${LIBDIR}
	ranlib ${LIBDIR}/${LIBFILE}
	cp ${MATHLIB} ${LIBDIR}
	ranlib ${LIBDIR}/${MATHLIB}
	-mkdir ${INCLDIR}
	cp ../rw/*.h ${INCLDIR}

groundtruth:
	for pgm in ${TESTPGMS}; do \
		( echo $$pgm; rm -f $$pgm.out; $$pgm > $$pgm.out ); \
	done
	rm -f cvectest.gnu cgemattest.gnu
	cp cvectest.out cvectest.gnu
	cp cgemattest.out cgemattest.gnu

sources:	${DERIVEDSRCS}

${TARGET}:   ${TARGET}.o ${LIBFILE} ${MATHLIB}
	${CCXX} ${CXXFLAGS} -o ${TARGET} ${TARGET}.o ${LIBFILE} ${MATHLIB} -lm

clean:
	rm -f ${TARGET} *.i *.ixx *.o *.s *.C *.C.o *.cpp
	rm -f core a.out ${TESTPGMS}

realclean:	clean
	rm -f ${DERIVEDSRCS}
	rm -f ${LIBFILE} ${MATHLIB}

#	No makedep in residence.  Have to fake one.
depend:	${SRCS}
	rm -f makedep.gnu
	for file in ${SRCS}; do \
		(echo $$file; \
		${CCXX} -MM ${CXXFLAGS} $$file >> makedep.gnu ); \
	done

#################   Sed scripts    ###############

dblock.cc:	xblock.cc
	maketype Double $? $@

dvec.cc:	xvec.cc
	maketype Double $? $@

dvecio.cc:	xvecio.cc
	maketype Double $? $@

dvecop.cc:	xvecop.cc
	maketype Double $? $@

dvecmath.cc:	xvecmath.cc
	maketype Double $? $@

dvectest.cc:	xvectest.cc
	maketype Double $? $@

#	Float:
fblock.cc:	xblock.cc
	maketype Float $? $@

fvec.cc:	xvec.cc
	maketype Float $? $@

fvecio.cc:	xvecio.cc
	maketype Float $? $@

fvecop.cc:	xvecop.cc
	maketype Float $? $@

fvecmath.cc:	xvecmath.cc
	maketype Float $? $@

fvectest.cc:	xvectest.cc
	maketype Float $? $@

#	DComplex (Double Complex)
cblock.cc:	xblock.cc
	maketype DComplex $? $@

cvec.cc:	xvec.cc
	maketype DComplex $? $@

cvecio.cc:	xvecio.cc
	maketype DComplex $? $@

cvecop.cc:	xvecop.cc
	maketype DComplex $? $@

cvecmath.cc:	xvecmath.cc
	maketype DComplex $? $@

cvectest.cc:	xvectest.cc
	maketype DComplex $? $@

#	Int:
iblock.cc:	xblock.cc
	maketype Int $? $@

ivec.cc:	xvec.cc
	maketype Int $? $@

ivecio.cc:	xvecio.cc
	maketype Int $? $@

ivecop.cc:	xvecop.cc
	maketype Int $? $@

ivecmath.cc:	xvecmath.cc
	maketype Int $? $@

ivectest.cc:	xvectest.cc
	maketype Int $? $@

#	Matrix stuff:
dgemat.cc:	xgemat.cc
	maketype Double $? $@

dgematop.cc:	xgematop.cc
	maketype Double $? $@

dgematio.cc:	xgematio.cc
	maketype Double $? $@

dgemattest.cc:	xgemattest.cc
	maketype Double $? $@

dgematmath.cc:	xgematmath.cc
	maketype Double $? $@

fgemat.cc:	xgemat.cc
	maketype Float $? $@

fgematop.cc:	xgematop.cc
	maketype Float $? $@

fgematio.cc:	xgematio.cc
	maketype Float $? $@

fgemattest.cc:	xgemattest.cc
	maketype Float $? $@

fgematmath.cc:	xgematmath.cc
	maketype Float $? $@

cgemat.cc:	xgemat.cc
	maketype DComplex $? $@

cgematop.cc:	xgematop.cc
	maketype DComplex $? $@

cgematio.cc:	xgematio.cc
	maketype DComplex $? $@

cgemattest.cc:	xgemattest.cc
	maketype DComplex $? $@

cgematmath.cc:	xgematmath.cc
	maketype DComplex $? $@

igemat.cc:	xgemat.cc
	maketype Int $? $@

igematop.cc:	xgematop.cc
	maketype Int $? $@

igematio.cc:	xgematio.cc
	maketype Int $? $@

igemattest.cc:	xgemattest.cc
	maketype Int $? $@

igematmath.cc:	xgematmath.cc
	maketype Int $? $@

#	LU decomposition
dludecmp.cc:	xludecmp.cc
	maketype Double $? $@

dludtest.cc:	xludtest.cc
	maketype Double $? $@
	
fludecmp.cc:	xludecmp.cc
	maketype Float $? $@

fludtest.cc:	xludtest.cc
	maketype Float $? $@
	
#################   Dependencies    ###############

dblock.o : dblock.cc ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
dvec.o : dvec.cc ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
dvecio.o : dvecio.cc ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
dvecop.o : dvecop.cc ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
dvecmath.o : dvecmath.cc ./../rw/DoubleVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
fblock.o : fblock.cc ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
fvec.o : fvec.cc ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
fvecio.o : fvecio.cc ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
fvecop.o : fvecop.cc ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
fvecmath.o : fvecmath.cc ./../rw/FloatVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
cblock.o : cblock.cc ./../rw/DComplexVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
cvec.o : cvec.cc ./../rw/DComplexVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/RComplex.h vecdefs.h ./../rw/DoubleVec.h 
cvecio.o : cvecio.cc ./../rw/DComplexVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
cvecop.o : cvecop.cc ./../rw/DComplexVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h vecdefs.h 
cvecmath.o : cvecmath.cc ./../rw/DComplexVec.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  vecdefs.h 
iblock.o : iblock.cc ./../rw/IntVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
ivec.o : ivec.cc ./../rw/IntVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
ivecio.o : ivecio.cc ./../rw/IntVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
ivecop.o : ivecop.cc ./../rw/IntVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h vecdefs.h 
ivecmath.o : ivecmath.cc ./../rw/IntVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
dgemat.o : dgemat.cc ./../rw/DGEMatrix.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
dgematop.o : dgematop.cc ./../rw/DGEMatrix.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
dgematio.o : dgematio.cc ./../rw/DGEMatrix.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
dgemattest.o : dgemattest.cc ./../rw/DGEMatrix.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
dgematmath.o : dgematmath.cc ./../rw/DGEMatrix.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
fgemat.o : fgemat.cc ./../rw/FGEMatrix.h ./../rw/FloatVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h 
fgematop.o : fgematop.cc ./../rw/FGEMatrix.h ./../rw/FloatVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h \
  ./../rw/DoubleVec.h 
fgematio.o : fgematio.cc ./../rw/FGEMatrix.h ./../rw/FloatVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
fgemattest.o : fgemattest.cc ./../rw/FGEMatrix.h ./../rw/FloatVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
fgematmath.o : fgematmath.cc ./../rw/FGEMatrix.h ./../rw/FloatVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
cgemat.o : cgemat.cc ./../rw/CGEMatrix.h ./../rw/DComplexVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
cgematop.o : cgematop.cc ./../rw/CGEMatrix.h ./../rw/DComplexVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  vecdefs.h 
cgematio.o : cgematio.cc ./../rw/CGEMatrix.h ./../rw/DComplexVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
cgemattest.o : cgemattest.cc ./../rw/CGEMatrix.h ./../rw/DComplexVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  vecdefs.h 
cgematmath.o : cgematmath.cc ./../rw/CGEMatrix.h ./../rw/DComplexVec.h \
  ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/RComplex.h 
igemat.o : igemat.cc ./../rw/IGEMatrix.h ./../rw/IntVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h 
igematop.o : igematop.cc ./../rw/IGEMatrix.h ./../rw/IntVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
igematio.o : igematio.cc ./../rw/IGEMatrix.h ./../rw/IntVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
igemattest.o : igemattest.cc ./../rw/IGEMatrix.h ./../rw/IntVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h vecdefs.h 
igematmath.o : igematmath.cc ./../rw/IGEMatrix.h ./../rw/IntVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
dludecmp.o : dludecmp.cc ./../rw/DLUDecomp.h ./../rw/DGEMatrix.h \
  ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/linpack.h 
dludtest.o : dludtest.cc ./../rw/DLUDecomp.h ./../rw/DGEMatrix.h \
  ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h 
fludecmp.o : fludecmp.cc ./../rw/FLUDecomp.h ./../rw/FGEMatrix.h \
  ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h \
  ./../rw/linpack.h 
fludtest.o : fludtest.cc ./../rw/FLUDecomp.h ./../rw/FGEMatrix.h \
  ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h 
fvecx.o : fvecx.cc ./../rw/FloatVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/DoubleVec.h 
ivecx.o : ivecx.cc ./../rw/IntVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/FloatVec.h ./../rw/DoubleVec.h 
dcosine.o : dcosine.cc ./../rw/DCosineFFT.h ./../rw/DoubleFFT.h \
  ./../rw/DComplexFFT.h ./../rw/DComplexVec.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  ./../rw/mathpack.h 
dfft.o : dfft.cc ./../rw/DoubleFFT.h ./../rw/DComplexFFT.h \
  ./../rw/DComplexVec.h ./../rw/DoubleVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  ./../rw/mathpack.h 
cfft.o : cfft.cc ./../rw/DComplexFFT.h ./../rw/DComplexVec.h \
  ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/RComplex.h ./../rw/mathpack.h 
dmath.o : dmath.cc ./../rw/DComplexVec.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
timer.o : timer.cc ./../rw/Timer.h //usr/include/errno.h 
utility.o : utility.cc ./../rw/vdefs.h ./../rw/compiler.h 
testcfft.o : testcfft.cc ./../rw/DComplexFFT.h ./../rw/DComplexVec.h \
  ./../rw/DoubleVec.h ./../rw/vdefs.h ./../rw/compiler.h \
  //usr/include/errno.h ./../rw/RComplex.h 
testdfft.o : testdfft.cc ./../rw/DoubleFFT.h ./../rw/DComplexFFT.h \
  ./../rw/DComplexVec.h ./../rw/DoubleVec.h ./../rw/vdefs.h \
  ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h 
testcos.o : testcos.cc ./../rw/DCosineFFT.h ./../rw/DoubleFFT.h \
  ./../rw/DComplexFFT.h ./../rw/DComplexVec.h ./../rw/DoubleVec.h \
  ./../rw/vdefs.h ./../rw/compiler.h //usr/include/errno.h ./../rw/RComplex.h \
  ./../rw/Timer.h 

#################   Conversions    ###############

.PRECIOUS: ${LIBFILE}

.SUFFIXES: .cc .o

.cc.o:
	$(CCXX) $(CXXFLAGS) -c $*.cc
