#!/usr/bin/make -f

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

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

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

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

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-DLIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		-DCMAKE_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)/cmake/libkml \
		-DBUILD_TESTING=OFF \
		-DBUILD_EXAMPLES=OFF \
		-DINSTALL_EXAMPLES=OFF

execute_after_dh_auto_install:
	# Remove autotools stuff
	find $(CURDIR)/examples/ -type f \( -name "Makefile*" -or -name "CMakeLists.txt" \) -delete

override_dh_makeshlibs:
	dh_makeshlibs -- -c0 -v$(UPSTREAM_VERSION)
