#!/usr/bin/make -f

# Enable hardening build flags
export DEB_BUILD_MAINT_OPTIONS=hardening=+all

CFLAGS += $(CPPFLAGS)

include /usr/share/dpkg/pkg-info.mk

UPSTREAM_VERSION = $(shell echo $(DEB_VERSION_UPSTREAM) | sed -e 's/\+.*//')

%:
	dh $@ --with python3 --buildsystem=cmake --sourcedirectory=saga-gis --without autoreconf

override_dh_clean:
	dh_clean src/saga_core/saga_api/saga_api.py saga_cmd.1 saga_gui.1

override_dh_auto_configure:
	dh_auto_configure -- \
		-DWITH_SYSTEM_SVM=on \
		-DWITH_SYSTEM_DXF=on \
		-DWITH_TRIANGLE=off \
		-DWITH_FIRE_SPREADING=off

override_dh_auto_build:
	pod2man --section=1 --release=$(UPSTREAM_VERSION) --center " " debian/saga_gui.pod > saga_gui.1
	pod2man --section=1 --release=$(UPSTREAM_VERSION) --center " " debian/saga_cmd.pod > saga_cmd.1
	dh_auto_build

override_dh_auto_install:
	dh_auto_install

	# Remove executable bit from resource files
	chmod -x debian/*/usr/share/saga/*.*

	# Explicitly remove files not to be installed
	find $(CURDIR)/debian/tmp/usr/lib -name "*.pyc" -delete
	find $(CURDIR)/debian/tmp/usr/lib -name "*.pyo" -delete

override_dh_python3:
	dh_python3 --no-ext-rename

override_dh_makeshlibs:
	dh_makeshlibs -Xpython3-saga
