#!/usr/bin/make -f

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
DPKG_EXPORT_BUILDFLAGS = 1

include /usr/share/dpkg/buildflags.mk

include /usr/share/dpkg/architecture.mk

CFLAGS += -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/tirpc
ifeq ($(DEB_HOST_ARCH),powerpc)
CFLAGS += -D__BYTEORDER_HAS_U64__
endif

override_dh_auto_configure:
	LIBS="-ltirpc"; dh_auto_configure -- --enable-rpcsetquota=yes

override_dh_installsystemd:
	dh_installsystemd quota.service
	dh_installsystemd --name=quotarpc quotarpc.service

override_dh_installinit:
	dh_installinit --no-start
	dh_installinit --name=quotarpc
	#
	# dh_installinit cannot be configured to not install the defaults
	# file for quotarpc, so we have to manually delete it
	#
	-rm -rf `pwd`/debian/quota/etc/default/quotarpc

override_dh_installman:
	dh_installman
	# remove man pages already in libc
	-rm -rf `pwd`/debian/quota/usr/share/man/man2

override_dh_install:
	dh_install
	# remove include files already in libc-dev
	-rm -rf `pwd`/debian/quota/usr/include
	# set permission of scripts
	-chmod 755 `pwd`/debian/quota/usr/share/quota/ldap/setquota-ldap.pl
	-chmod 755 `pwd`/debian/quota/usr/share/quota/*.sh

%:
	dh $@
