# Executables are relinked only if you make a "make clean"
# Most of the time it is not necessary to relink them.

default: test

include ../../Makefile.config

.SUFFIXES:.sgml .exe .regtest

ZMW_LOOP=zmw_make() { [ -f Makefile ] && for I in */. ; do ( I=`dirname $$I` ; if [ "$$1" = "clean" ] ; then TARGET="$$1" ; else TARGET="$$I.$$1" ; fi ; cd $$I ; $(MAKE) -f ../Makefile $$TARGET ) ; done || true ; } ; zmw_make



.o.exe:
	echo "Link example $*"
	$(CC) $*.o $(ZMW_OBJS) -o $*.exe

.c.regtest:
	../regression_test

start_xvfb:
	. utilities ; start_xvfb

stop_xvfb:
	. utilities ; stop_xvfb


test::start_xvfb ask regtest stop_xvfb
testwithoutquestion:start_xvfb noforall regtest stop_xvfb

regtest:
	$(ZMW_LOOP) $@
	A=`fgrep fail */regteststatus` ; \
	if [ "" = "$$A" ] ; \
		then echo "All tests are fine" ; \
	else \
		echo "================ List of failed tests ==============" ; \
		echo "$$A" | sed 's/\/.*//' ; \
	fi

ask:
	echo "" >xxx.replace

noforall:
	echo "noforall" >xxx.replace

exe::
	$(ZMW_LOOP) $@

clean::
	rm -f xvfb.pid */*.sgml */*.exe */*.eps */xxx* 2>/dev/null
	if [ -f "Makefile" ] ; then $(ZMW_LOOP) $@ ; fi

# DO NOT DELETE
