#!/usr/bin/make -f
# -*- makefile -*-

# pie causes build failures
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-pie

#GPGME needs this for proper building on 32 bit archs
ifeq "$(DEB_HOST_ARCH_BITS)" "32"
	export DEB_CFLAGS_MAINT_APPEND = -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
endif

%:
	dh $@ --with gir

override_dh_auto_clean:
	rm -fr debian/build

override_dh_auto_configure:
	if pkg-config --exists fwup; then \
		export UEFI="-Denable-uefi=true"; \
	else \
		export UEFI="-Denable-uefi=false"; \
	fi; \
	if pkg-config --exists libsmbsios_c; then \
		export DELL="-Denable-dell=true"; \
	else \
		export DELL="-Denable-dell=false"; \
	fi; \
	dh_auto_configure -- $$UEFI $$DELL --libexecdir=/usr/lib

override_dh_install:
	find debian/tmp/usr -name "*a" -print -type f | xargs rm -f
	sed -i 's,wheel,sudo,' ./debian/tmp/usr/share/polkit-1/rules.d/org.freedesktop.fwupd.rules
	dh_install
	dh_missing --fail-missing

override_dh_auto_test:
	if [ -x /usr/bin/valgrind ] ; then \
		dh_auto_test; \
	fi
