#!/usr/bin/make -f
# export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS=hardening=+all reproducible=+all
# Compensate for some insufficiently-fine-grained dependencies
export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- -DBUILD_ALL_EXTENSIONS=ON -DBUILD_LOADER=ON -DBUILD_TESTS=ON -DMANIFEST_SUFFIX=.$(DEB_HOST_MULTIARCH)

override_dh_install:
	# copyright file already included in the package
	rm -f debian/tmp/usr/share/doc/openxr/LICENSE > /dev/null
	cp CHANGELOG.SDK.md debian/tmp/usr/share/doc/openxr/changelog
	pandoc -f markdown -t html CHANGELOG.SDK.md > debian/tmp/usr/share/doc/openxr/changelog.html
	dh_install

override_dh_clean:
	dh_clean
	py3clean .

# Use mk-origtargz command to follow Files-Excluded tag in d/copyright to
# repack DFSG tarbll.
get-orig-source:
	set -e;\
	wget --continue \
	        https://github.com/KhronosGroup/OpenXR-SDK-Source/archive/release-$(patsubst %~dfsg1,%,$(patsubst %~ds1,%,$(DEB_VERSION_UPSTREAM))).tar.gz; \
	mk-origtargz --rename --repack --repack-suffix ~dfsg1 --compression xz release-$(patsubst %~dfsg1,%,$(patsubst %~ds1,%,$(DEB_VERSION_UPSTREAM))).tar.gz