#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
BUILDDIR = $(CURDIR)/debian/build
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
	dh $@ --builddirectory=$(BUILDDIR) --with python3

no_debug_info = mips64el mipsel

ifneq (,$(filter $(DEB_HOST_ARCH),$(no_debug_info)))
  # no debug info to avoid running
  # out of address space when linking
	export DEB_CXXFLAGS_MAINT_APPEND += -g0
endif

# If SALSABUILD is set we want to drop debug info as well
ifneq ($(SALSABUILD),)
  export DEB_CXXFLAGS_MAINT_APPEND += -g0
endif

DPKG_EXPORT_BUILDFLAGS = 1

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic

include /usr/share/dpkg/buildflags.mk

execute_after_dh_auto_build-arch:
	cd $(BUILDDIR) && $(MAKE) man

execute_after_dh_auto_build-indep:
	cd $(BUILDDIR) && $(MAKE) doxygen

execute_after_dh_auto_install:
	find . -type d -name "__pycache__" -exec rm -r {} +
	find $(CURDIR)/debian/tmp/usr/share -type f -name "*.so" -exec rm -r {} +
	rm -rf $(CURDIR)/debian/tmp/usr/bin/start-command-line.bat

override_dh_auto_test-arch:
	mkdir $(CURDIR)/tests_auto
	cd $(CURDIR)/tests_auto; cp $(CURDIR)/debian/tests/hokkaido/* ./; SUMO_HOME=$(CURDIR) ../bin/sumo -b 0 -e 10000 -n net.net.xml -r input_routes.rou.xml --summary-output sum.out
	cat $(CURDIR)/tests_auto/sum.out
	rm -rf $(CURDIR)/tests_auto

override_dh_auto_test-indep:
