#!/usr/bin/make -f
# -*- makefile -*-
#export DH_VERBOSE=1
export deb_systemdsystemunitdir = $(shell pkg-config --variable=systemdsystemunitdir systemd | sed s,^/,,)

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with=ppp \
	      --builddir build \
	      --as-needed

override_dh_auto_configure:
	dh_auto_configure -- \
		--runstatedir='/run' \
		--enable-debug \
		--enable-iwd \
		--enable-l2tp \
		--enable-openconnect \
		--enable-openvpn \
		--enable-pie \
		--enable-polkit \
		--enable-pptp \
		--enable-selinux \
		--enable-threads \
		--enable-test \
		--with-openconnect=/usr/sbin/openconnect \
		--with-openvpn=/usr/sbin/openvpn \
		--with-systemdunitdir=/$(deb_systemdsystemunitdir) \
		--with-tmpfilesdir=/usr/lib/tmpfiles.d

override_dh_install:
	find $(CURDIR) -name "*.la" -print -delete
	dh_install

override_dh_installinit:
	cp -a build/scripts/connman debian/connman.init
	dh_installinit --restart-after-upgrade

override_dh_auto_clean:
	$(RM) debian/connman.init
	$(RM) -r build
	dh_auto_clean

override_dh_clean:
	dh_clean aclocal.m4 config.h.in configure ltmain.sh

override_dh_ppp:
	dh_ppp --breaks

override_dh_python3:
	# Upstream claims that these scripts are compatible with python3, see 55965561d3
	dh_python3 /usr/share/connman/test/ --shebang=/usr/bin/python3
