TESTS=file.testapp crc32.testapp foreach.testapp process.testapp argumentparser.testapp daemon.testapp pt_map.testapp transaction_map.testapp xml.testapp alphanum.testapp persistent_map.testapp getfacility.testapp cpuinfo.testapp path.testapp triemap.testapp string.testapp syslog.testapp signalhandler.testapp # fd_copy.testapp tuplewriter.testapp

all:
	$(MAKE) -C .. $@

clean:
	-$(RM) *~ a.out core *.testapp
	-$(RM) *.o
	-$(RM) *.obj
	-$(MAKE) -C unix $@
	-$(MAKE) -C win $@
	-$(MAKE) -C test $@

dojlibtest: $(TESTS)
	$(MAKE) -C test $@

releasepre:
	find . -exec touch -a -d "1971-01-01" {} ';'

releasepost:
	find . -atime +1 -delete
	-rmdir CVS
	-rmdir test/CVS
	-rmdir test
	-rmdir unix/CVS
	-rmdir unix
	-rmdir win/CVS
	-rmdir win

%.testapp : %.c
	cc $(shell perl -e '$$ARGV[0]=~/^(.+)\.testapp/;print uc "-DTEST$$1"' $@) -g -Wall -I. -o $@ $^
	./$@

%.testapp : %.cpp
	c++ $(CXXFLAGS) $(shell perl -e '$$ARGV[0]=~/^(.+)\.testapp/;print uc "-DTEST$$1"' $@) -g -Wall -I. -o $@ $^
	./$@

%.testapp : %.hpp
	rm -f /tmp/$*.cpp
	ln -s $(shell pwd)/$< /tmp/$*.cpp
	c++ $(CXXFLAGS) $(shell perl -e '$$ARGV[0]=~/^(.+)\.testapp/;print uc "-DTEST$$1"' $@) -g -Wall -I. -o $@ /tmp/$*.cpp
	./$@

%.testapp : %.h
	rm -f /tmp/$*.cpp
	ln -s $(shell pwd)/$< /tmp/$*.cpp
	c++ $(CXXFLAGS) $(shell perl -e '$$ARGV[0]=~/^(.+)\.testapp/;print uc "-DTEST$$1"' $@) -g -Wall -I. -o $@ /tmp/$*.cpp
	./$@

xml.testapp : xml.cpp xml.hpp xml_boost.cpp
	c++ $(CXXFLAGS) $(shell perl -e '$$ARGV[0]=~/^(.+)\.testapp/;print uc "-DTEST$$1"' $@) -g -Wall -I. -o $@ $< -lboost_iostreams-mt
	./$@

rscode.testapp:	rscode.cpp
	c++ $(CXXFLAGS) -DTESTRSCODE -g -Wall -I. -o $@ $<
	./$@ -e < $< > /tmp/rscode.test.1
	./$@ -d < /tmp/rscode.test.1 > /tmp/rscode.test.2
	cmp $< /tmp/rscode.test.2
