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

#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

export COLORHUG="--disable-colorhug"
COLORHUG_VERSION=$(shell dpkg-query -W libcolorhug-dev | awk '{ print $$2 }' | sed 's,-.*,,')
ifeq "1.2.12" "$(word 1, $(sort 1.2.12 $(COLORHUG_VERSION)))"
       export COLORHUG="--enable-colorhug"
endif

%:
	dh $@ --with autoreconf

override_dh_autoreconf:
	NOCONFIGURE=1 dh_autoreconf ./autogen.sh

override_dh_auto_configure:
	if pkg-config --exists fwup; then \
		export UEFI="--enable-uefi"; \
	else \
		export UEFI="--disable-uefi"; \
	fi; \
	dh_auto_configure -- --with-systemdunitdir=/lib/systemd/system \
				$(COLORHUG) $$UEFI

override_dh_install:
	find debian/tmp/usr -name "*a" | xargs rm -f
	dh_install --fail-missing
