
SHELL=/bin/sh

prefix      = @prefix@
exec_prefix = @exec_prefix@
bindir      = @bindir@

target=

all: update check

update: Makefile

Makefile: Makefile.in
	@echo 
	@echo Please configure the package to generate new makefile ...
	@exit 1

check:  hpf2dep hpfsc dumpdep unparse compare


hpf2dep:
	@echo "----------- Test Compiling ------------"
	@for i in `ls *.f`; do (echo "...Compiling " $$i; \
	if [ -x ${bindir}/hpf2dep ]; then ${bindir}/hpf2dep $$i; \
	else ../../src/hpf2dep/hpf2dep $$i; fi;) done

hpfsc:
	@echo "---------- Test Semantics Checking ------------"
	@for i in `ls *.dep`; do (echo "...Second pass compiling " $$i; \
	if [ -x ${bindir}/hpfsc ]; then ${bindir}/hpfsc $$i 2> $$i.sem; \
	else ../../src/hpfsc/hpfsc $$i 2> $$i.sem; fi;) done
	
dumpdep:
	@echo "---------- Test  Dumping  ------------"
	@for i in `ls *.dep`; do (echo "...Dumping " $$i; \
	if [ -x ${bindir}/dumpdep ]; then ${bindir}/dumpdep $$i > $$i.lnk; \
	else ../../src/tools/dump/dumpdep $$i > $$i.lnk; fi;) done

unparse:
	@echo "---------- Test Unparsing ------------"
	@for i in `ls *.dep`; do (echo "...Unparsing " $$i; \
	if [ -x ${bindir}/unparse ]; then ${bindir}/unparse $$i > $$i.src; \
	else ../../src/tools/unparse/unparse $$i > $$i.src; fi;) done

compare:
	@echo "---------- Comparing dep file results  ----------"
	@for i in `ls *.lnk`; do (echo "...Comparing" $$i; \
	diff $$i.rec $$i;) done
	@echo "---------- Comparing semantics checking results  ----------"
	@for i in `ls *.sem`; do (echo "...Comparing" $$i; \
	diff $$i.rec $$i;) done
	@echo "---------- Comparing unparse results ----------"
	@for i in `ls *.src`; do (echo "...Comparing" $$i; \
	diff $$i.rec $$i;) done

clean:
	rm -f *.dep *.lst *.dep.lnk *.dep.sem *.dep.src core *.rec

record:
	for i in `ls *.lnk`; do (cp $$i  $$i.rec;) done
	for i in `ls *.sem`; do (cp $$i  $$i.rec;) done
	for i in `ls *.src`; do (cp $$i  $$i.rec;) done


test: 
	@echo ${target}
	if [ -x ${bindir}/hpf2dep ]; then ${bindir}/hpf2dep ${target}.f; \
	else ../../src/hpf2dep/hpf2dep ${target}.f; fi
	if [ -x ${bindir}/hpfsc ]; then ${bindir}/hpfsc ${target}.dep 2> ${target}.dep.sem; \
	else ../../src/hpfsc/hpfsc ${target}.dep 2> ${target}.dep.sem; fi
	diff ${target}.dep.sem.rec ${target}.dep.sem
	if [ -x ${bindir}/dumpdep ]; then ${bindir}/dumpdep ${target}.dep > ${target}.dep.lnk; \
	else ../../src/tools/dump/dumpdep ${target}.dep > ${target}.dep.lnk; fi
	diff ${target}.dep.lnk.rec ${target}.dep.lnk
	if [ -x ${bindir}/unparse ]; then ${bindir}/unparse ${target}.dep > ${target}.dep.src; \
	else ../../src/tools/unparse/unparse ${target}.dep > ${target}.dep.src; fi
	diff ${target}.dep.src.rec ${target}.dep.src
	






