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

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

ifeq (linux,$(DEB_HOST_ARCH_OS))
	# Setting no would also disable support in the rpcbind executable.
	CONFIGURE_EXTRA_FLAGS += --with-systemdsystemunitdir=/unused
else
	CONFIGURE_EXTRA_FLAGS += --with-systemdsystemunitdir=no
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- --sbindir=/sbin --enable-warmstarts --enable-libwrap --with-statedir=/run/rpcbind --with-rpcuser=_rpc --enable-debug $(CONFIGURE_EXTRA_FLAGS)

execute_after_dh_auto_install:
	rm -Rf debian/rpcbind/unused

override_dh_installinit:
	dh_installinit
	install -d debian/rpcbind/etc/insserv.conf.d
	cp debian/insserv.conf debian/rpcbind/etc/insserv.conf.d/rpcbind

override_dh_installsystemd:
	dh_installsystemd --no-restart-after-upgrade

ifeq (linux,$(DEB_HOST_ARCH_OS))
execute_before_dh_link:
	dh_link $$(test -d debian/rpcbind/usr/lib/systemd && echo usr/)lib/systemd/system/rpcbind.service $$(test -d debian/rpcbind/usr/lib/systemd && echo usr/)lib/systemd/system/portmap.service
endif
