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

export LC_ALL := C.UTF-8
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

#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

ifneq ($(CI),)
	export CI=--werror
endif

%:
	dh $@ --with gir,systemd

override_dh_auto_clean:
	rm -fr debian/build

override_dh_auto_configure:
	if pkg-config --exists fwup; then \
		export UEFI="-Dplugin_uefi=true"; \
	else \
		export UEFI="-Dplugin_uefi=false"; \
	fi; \
	if pkg-config --exists libsmbios_c; then \
		export DELL="-Dplugin_dell=true -Dplugin_synaptics=true"; \
	else \
		export DELL="-Dplugin_dell=false -Dplugin_synaptics=false"; \
	fi; \
	dh_auto_configure -- $$UEFI $$DELL $$CI -Dplugin_dummy=true --libexecdir=/usr/lib

override_dh_install:
	find debian/tmp/usr -type f -name "*a" -print | 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

	#this is placed in fwupd-tests
	rm -f debian/fwupd/usr/lib/*/fwupd-plugins-3/libfu_plugin_test.so

override_dh_strip_nondeterminism:
	dh_strip_nondeterminism -Xfirmware-example.xml.gz

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