#!/usr/bin/make -f

LDFLAGS+=-Wl,--as-needed

include /usr/share/dpkg/architecture.mk

# possible guest wrapper binary locations
GUEST_WRAPPER_BINARY_LIBEXEC="/usr/libexec/lightdm/lightdm-guest-session"
GUEST_WRAPPER_BINARY_M_LIB="/usr/lib/$(DEB_HOST_MULTIARCH)/lightdm/lightdm-guest-session"
GUEST_WRAPPER_BINARY_LIB="/usr/lib/lightdm/lightdm-guest-session"

%:
	dh $@ --with autoreconf

override_dh_autoreconf:
	if [ ! -e po/arctica-greeter.pot.bak ]; then \
	    cp po/arctica-greeter.pot po/arctica-greeter.pot.bak; \
	fi
	NOCONFIGURE=1 dh_autoreconf ./autogen.sh

override_dh_auto_configure:
	set -x; if [ -x "$(GUEST_WRAPPER_BINARY_LIBEXEC)" ]; then \
	    dh_auto_configure -- --libexecdir=/usr/libexec GUEST_WRAPPER_BINARY=/usr/libexec/lightdm/lightdm-guest-session; \
	elif [ -x "${GUEST_WRAPPER_BINARY_M_LIB}" ]; then \
	    dh_auto_configure -- --libexecdir=/usr/libexec GUEST_WRAPPER_BINARY=/usr/lib/$(DEB_HOST_MULTIARCH)/lightdm/lightdm-guest-session; \
	elif [ -x "${GUEST_WRAPPER_BINARY_LIB}" ]; then \
	    dh_auto_configure -- --libexecdir=/usr/libexec GUEST_WRAPPER_BINARY=/usr/lib/lightdm/lightdm-guest-session; \
	else \
	    echo "Error: GUEST_WRAPPER_BINARY (lightdm-guest-session executable from LightDM) not found!"; \
	    exit 1; \
	fi

override_dh_auto_build:
	dh_auto_build

override_dh_missing:
	dh_missing --fail-missing

override_dh_auto_clean:
	dh_auto_clean
	if [ -e po/arctica-greeter.pot.bak ]; then \
	    mv -f po/arctica-greeter.pot.bak po/arctica-greeter.pot; \
	fi
	rm -f src/arctica_greeter_vala.stamp
	rm -f src/logo_generator_vala.stamp
	rm -f tests/arctica_greeter_test_vala.stamp
	rm -f src/*.c
	rm -f tests/*.c

override_dh_auto_test:
