# This Makefile is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.

JAVA=@JAVA@

tests: slowtests fasttests 

slowtests:
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS FilesMissingInWindowsProjects.o

fasttests:
	rm -rf ../src/NONE
	sh testtabs.sh
	sh testresourcenumbers.sh
	sh testmenus.sh
	@TESTICONSIZE@ node_icons.bmp node_icons_bw.bmp
	@TESTICONSIZE2@ node_icons.bmp node_icons2.bmp
	@TESTICONSIZE@ standard_toolbar.bmp standard_toolbar_bw.bmp
	@TESTICONSIZE2@ standard_toolbar.bmp standard_toolbar2.bmp
	@TESTICONSIZE@ vcr.bmp vcr_bw.bmp
	@TESTICONSIZE2@ vcr.bmp vcr2.bmp
	sh testprotos.sh > testprotos.cpp
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS testprotos
	./dune_testprotos
	rm -f ./dune_testprotos ./dune_testprotos.exe testprotos.cpp
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS selftest
	./dune_selftest > allNodesTest.cpp
	./dune_selftest -x3d > allNodesTestX3d.cpp
	rm -f ./dune_selftest dune_selftest.exe
	sh -c "cd ../src;ls Node*.h | \
             awk '{print \"#include \\\"\" \$$0 \"\\\"\"}' > ../test/AllNodes.h"
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS allNodesTest
	./dune_allNodesTest > allNodesTest.wrl
	rm -f dune_allNodesTest dune_allNodesTest.exe
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS allNodesTestX3d
	./dune_allNodesTestX3d > allNodesTestX3d.x3dv
	cp allNodesTestX3d.x3dv /tmp
	rm -f dune_allNodesTestX3d dune_allNodesTestX3d.exe
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS selftest
	./dune_selftest allNodesTestX3d.x3dv 2>/dev/null >/dev/null
	$(MAKE) clean
	cd ../src/swt && $(MAKE) $$DUNEMAKEFLAGS test
	cd ../src/swt && $(MAKE) $$DUNEMAKEFLAGS testclean
	cd .. && $(MAKE)
	cd ../docs/export_example_c && $(MAKE)
	../docs/export_example_c/helloWorld
	cd ../docs/export_example_c && $(MAKE) clean
	cd ../docs/export_example_c++ && $(MAKE)
	../docs/export_example_c++/helloWorld
	cd ../docs/export_example_c++ && $(MAKE) clean
	cd ../docs/export_example_java && $(MAKE)
	$(JAVA) -cp ../docs/export_example_java/classes helloWorld
	cd ../docs/export_example_java && $(MAKE) clean

realclean: clean
	rm -f /tmp/allNodesTestX3d.x3dv

clean:
	rm -f dune_selftest dune_selftest.exe \
              printFieldType printFieldType.exe \
              printNodeType printNodeType.exe\
	      *allNodesTest* ../src/allNodesTest* AllNodes.h \
	      dune_testprotos dune_testprotos.exe testprotos.cpp \
	      testzeroclass testzeroclass.exe testzeroclass.cpp

testzeroclass:
	sh testzeroclass.sh > testzeroclass.cpp
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS testzeroclass
	./testzeroclass

printFieldType:
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS ../test/printFieldType

printNodeType:
	cd ../src && $(MAKE) $$DUNEMAKEFLAGS ../test/printNodeType

