#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

# Disable lto here regardless of whether we enable the configure flag
# https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1070
export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto

export PYTHON=/usr/bin/python3

PPPD_PLUGIN_DIR := $(shell dh_ppp --plugin-dir)

%:
	dh $@ --with ppp --without autoreconf --buildsystem=meson

override_dh_auto_configure:
	dh_auto_configure -- \
		-Druntime_dir=/run \
		-Dpppd_plugin_dir=$(PPPD_PLUGIN_DIR) \
		-Dpppd=/usr/sbin/pppd \
		-Dresolvconf=/usr/sbin/resolvconf \
		-Dmodprobe=/usr/sbin/modprobe \
		-Ddhcpcanon=false \
		-Ddhcpcd=false \
		-Diptables=/usr/sbin/iptables \
		-Dnft=/usr/sbin/nft \
		-Ddnsmasq=/usr/sbin/dnsmasq \
		-Dpolkit_agent_helper_1=/usr/lib/policykit-1/polkit-agent-helper-1 \
		-Dsystemdsystemunitdir=/usr/lib/systemd/system \
		-Dudev_dir=/usr/lib/udev \
		-Ddbus_conf_dir=/usr/share/dbus-1/system.d \
		-Dcrypto=gnutls \
		-Dsession_tracking=systemd \
		-Dsuspend_resume=systemd \
		-Dmodem_manager=true \
		-Dnmtui=true \
		-Dnmcli=true \
		-Dselinux=true \
		-Dsystemd_journal=true \
		-Dlibaudit=yes \
		-Dwext=true \
		-Dwifi=true \
		-Diwd=true \
		-Dppp=true \
		-Dpolkit=true \
		-Dintrospection=true \
		-Ddocs=true \
		-Dconcheck=true \
		-Dteamdctl=true \
		-Dbluez5_dun=true \
		-Dvapi=true \
		-Difupdown=true \
		-Difcfg_rh=false \
		-Dnm_cloud_setup=false \
		-Dmodify_system=false \
		-Dovs=false \
		-Dqt=false \
		-Debpf=false \
		-Dofono=false

override_dh_makeshlibs:
	dh_makeshlibs -X/usr/lib/$(DEB_HOST_MULTIARCH)/NetworkManager/ -X/usr/lib/pppd/

override_dh_installsystemd:
	dh_installsystemd -pnetwork-manager --no-start NetworkManager-dispatcher.service NetworkManager-wait-online.service nm-priv-helper.service
	dh_installsystemd -pnetwork-manager --no-also NetworkManager.service

override_dh_ppp:
	dh_ppp --breaks
