#!/usr/bin/make -f

# DH_VERBOSE := 1
export LC_ALL=C.UTF-8

include /usr/share/dpkg/default.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# Avoid section conflict on parisc, see #1044139.
ifneq (,$(filter $(DEB_HOST_ARCH),hppa))
export DEB_CXXFLAGS_MAINT_APPEND += -ffunction-sections
endif

%:
	dh $@ --sourcedirectory=src

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	cd src && python3 run_tests.py
endif

override_dh_auto_install:
	mkdir -p $(CURDIR)/debian/$(DEB_SOURCE)/usr/bin
	dh_auto_install -- PREFIX=$(CURDIR)/debian/$(DEB_SOURCE)/usr
	#echo "#!/usr/bin/python3" > $(CURDIR)/debian/$(DEB_SOURCE)/usr/bin/Phyx_Gui
	#cat src/Phyx_Gui.py >> $(CURDIR)/debian/$(DEB_SOURCE)/usr/bin/Phyx_Gui

override_dh_compress:
	dh_compress --exclude=.pdf

override_dh_auto_clean:
	rm -rf src/phyx.logfile
	if [ -r src/Makefile ]; then \
	  $(MAKE) -C src distclean; \
	fi
