#!/usr/bin/make -f

%:
	dh $@ --parallel --with autoreconf

no_hardening_all_archs = mips mipsel

ifeq (,$(filter $(DEB_HOST_ARCH),$(no_hardening_all_archs)))
  export DEB_BUILD_MAINT_OPTIONS = hardening=+all
endif

DPKG_EXPORT_BUILDFLAGS = 1

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

export LIBS := -lgl2ps -lGL -lGLU -lglut

include /usr/share/dpkg/buildflags.mk

override_dh_auto_configure:
	dh_auto_configure -- --prefix=/usr

override_dh_auto_build-indep:
	$(MAKE) doxygen
	$(MAKE) pydoc
	#Clean some unneeded files and fix permissions
	find ./tools -name '*.pyc' -print0 | xargs -0 rm -f
	rm ./tools/contributed/sumoplayer/LICENSE
	rm ./tools/contributed/traci4j/COPYING
	rm ./tools/contributed/trafficmodeler/src/resources/icons/Thumbs.db
	rm ./tools/contributed/traci4j/.gitignore
	find ./tools -name '*.java' -print0 | xargs -0 chmod -x
	find ./tools/contributed/traci4j -type f -print0 | xargs -0 chmod -x
	chmod -x ./tools/projects/TaxiFCD_Krieg/src/backup/BackupFolder.pyw
	chmod -x ./tools/build/dailyBuildMSVC8.bat

override_dh_auto_build-arch:
	dh_auto_build -a
	$(MAKE) man
	
override_dh_auto_test-arch:
	mkdir $(CURDIR)/tests
	cd $(CURDIR)/tests; cp ../docs/examples/sumo/visualization/parade/* ./; ../bin/sumo -b 0 -e 10000 -n net.net.xml -r input_routes.rou.xml -c parade.sumocfg  --summary-output sum.out
	cat $(CURDIR)/tests/sum.out
	rm -rf $(CURDIR)/tests
