# Makefile for hyperplane fit driver program

#  g95 is the GNU f95 compiler
FC=g95


# utilities
RM=/bin/rm -f

# define lapack libraries and includes.  lapack is a standard fedora
# rpm.  There is a lapack95 available at netlib but the gain is not that
# significant, and by sticking with plain lapack I hope portability
# will be aided.
LIBLAPACK= -llapack -lblas

F90FLAGS=


.SUFFIXES: .f90


.f90.o:
	$(FC) $(F90FLAGS) -c $<


HFITOBJS= precision_module.o hyperplane-newton.o hyperplane-main.o

PROG=hyperplane

DATASETS= york syn-plane syn-4plane

prog: $(PROG)

hyperplane: $(HFITOBJS)
	$(FC) -o $(PROG)  $(HFITOBJS) $(LIBLAPACK)

test: $(PROG)
	@for set in $(DATASETS) ; \
	do \
	  echo "Testing with data set $$set ..." ; \
	  (cat test-params.dat ; echo $$set.dat) | ./$(PROG) > $$set.tmp ; \
	  if cmp $$set.tmp $$set.out ; \
	  then \
		echo " ... passed" ; \
		$(RM) $$set.tmp ; \
	  else \
		echo " ... FAILED" ; \
		echo "Compare file $$set.tmp with original $$set.out." ; \
	  fi ; \
	done

clean:
	$(RM) *.o *.mod \#*

tidy: clean
	$(RM) *~

clobber:
	$(RM) $(PROG)

