top_srcdir = ..
top_builddir = ..
srcdir = .

subdir = examples

NQ=../bin/aarch64-unknown-linux-gnu-mpicc-default64/nq -S 

all: G1.tst G2.tst G3.tst G4.tst G5.tst

clean:
	rm -f G?.tst  *~

distclean: clean
	rm -f G*.old

G1.tst: G1
	@ echo -n Testing example: $<
	@ $(NQ) $< 18 | grep -v "Time\|time\|size\|Machine\|Input\|Program\|Version" > $@
	@ if diff $<.out $@; then                                     \
	     echo " ok.";                                             \
	     rm $@;                                                   \
	else                                                          \
	     echo " results in an error.";                            \
	     echo Please mail the file $@;                            \
	     echo "    " to max.horn@math.uni-giessen.de;             \
	fi

G2.tst: G2
	@ echo -n Testing example: $<
	@ $(NQ) $< 11 | grep -v "Time\|time\|size\|Machine\|Input\|Program\|Version" > $@
	@ if diff $<.out $@; then                                     \
	     echo " ok.";                                             \
	     rm $@;                                                   \
	else                                                          \
	     echo " results in an error.";                            \
	     echo Please mail the file $@;                            \
	     echo "    " to max.horn@math.uni-giessen.de;             \
	fi

G3.tst: G3
	@ echo -n Testing example: $<
	@ $(NQ) $< 20 | grep -v "Time\|time\|size\|Machine\|Input\|Program\|Version" > $@
	@ if diff $<.out $@; then                                     \
	     echo " ok.";                                             \
	     rm $@;                                                   \
	else                                                          \
	     echo " results in an error.";                            \
	     echo Please mail the file $@;                            \
	     echo "    " to max.horn@math.uni-giessen.de;             \
	fi

G4.tst: G4
	@ echo -n Testing example: $<
	@ $(NQ) $< 12 | grep -v "Time\|time\|size\|Machine\|Input\|Program\|Version" > $@
	@ if diff $<.out $@; then                                     \
	     echo " ok.";                                             \
	     rm $@;                                                   \
	else                                                          \
	     echo " results in an error.";                            \
	     echo Please mail the file $@;                            \
	     echo "    " to max.horn@math.uni-giessen.de;             \
	fi

G5.tst: G5
	@ echo -n Testing example: $<
	@ $(NQ) $< 12 | grep -v "Time\|time\|size\|Machine\|Input\|Program\|Version" > $@
	@ if diff $<.out $@; then                                     \
	     echo " ok.";                                             \
	     rm $@;                                                   \
	else                                                          \
	     echo " results in an error.";                            \
	     echo Please mail the file $@;                            \
	     echo "    " to max.horn@math.uni-giessen.de;             \
	fi

# Recreate the comparison output
recalibrate:
	@ for example in G?.[0-9]*; do                                   \
	    echo making test example `basename $$example`;               \
									 \
	    class=`echo $$example | awk -F. '{print $$2}'`;              \
	    output=`echo $$example | awk -F. '{print $$1}'`;             \
									 \
	    mv -f $$output.out $$output.old;                             \
	    echo "    $(NQ) $$example $$class > $$output.out";           \
	    $(NQ) $$example $$class                                      \
		| grep -v "Time\|time\|size\|Machine\|Input\|Version" > $$output.out;\
	done

.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@

.PHONY: all clean distclean test G1.tst G2.tst G3.tst G4.tst G5.tst recalibrate
