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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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

# the build system silences build flags without this set
export V=1

%:
	dh $@

override_dh_autoreconf:
	dh_autoreconf autoreconf -- -f -i -I m4

override_dh_auto_configure:
	dh_auto_configure -- \
		--docdir=/usr/share/doc/atheme-services/ \
		--sysconfdir=/etc/atheme \
		--disable-rpath \
		--enable-contrib \
		--enable-fhs-paths \
		--enable-reproducible-builds \
		--with-libmowgli=no \
		--without-cracklib \
		--without-ldap \
		--without-perl

override_dh_auto_clean:
	[ ! -f buildsys.mk ] || make clean
	# Manually remove files, due to authors distclean not safe
	find -name .deps -type f -delete
	[ ! -f buildsys.mk ] || rm buildsys.mk
	[ ! -f config.sub ] || rm config.sub
	[ ! -f config.guess ] || rm config.guess
	[ ! -f config.log ] || rm config.log
	[ ! -f config.status ] || rm config.status
	[ ! -f dist/atheme.conf.operserv-example ] || rm dist/atheme.conf.operserv-example
	[ ! -f dist/atheme.conf.userserv-example ] || rm dist/atheme.conf.userserv-example
	[ ! -f extra.mk ] || rm extra.mk
	[ ! -f include/sysconf.h ] || rm include/sysconf.h

override_dh_install:
	dh_install -p atheme-services -X/contrib/
	dh_install --remaining-packages

	# atheme-services allows wide configure latitude, so we want to make sure the user
	# reads the config files...
	rm -f $(CURDIR)/debian/atheme-services/etc/atheme/*example

	# shut lintian up by not installing the LICENSE...
	rm -f $(CURDIR)/debian/atheme-services/usr/share/doc/atheme-services/LICENSE
	rm -f $(CURDIR)/debian/atheme-services/usr/share/doc/atheme/LICENSE

	# shut lintian up by removing the run folder.
	rm -rf $(CURDIR)/debian/atheme-services/var/run

override_dh_installinit:
	dh_installinit --no-enable

override_dh_missing:
	dh_missing --fail-missing
