#!/usr/bin/make -f
#export DH_VERBOSE=1

%:
	dh $@

CONFIG_ARGS = --libexecdir=lib --bindir=/usr/bin --sbindir=/usr/sbin -Dpam=true -Dsysvinit=true -Drc_path=/etc/rc,/usr/lib/rc,/etc

override_dh_auto_configure:
	dh_auto_configure -- $(CONFIG_ARGS)

override_dh_install:
	# These are symlinks for compatibility reasons, and we don't want
	# them in Debian.
	for file in runscript rc service ; do \
		rm -f $(CURDIR)/debian/tmp/usr/sbin/$${file} ; \
	done

	# These need to be removed, the same way as other stuff above
	for file in service.8 service.8.gz start-stop-daemon.8 start-stop-daemon.8.gz ; do \
		rm -f $(CURDIR)/debian/tmp/usr/share/man/man8/$${file} ; \
	done

	# These are Gentoo specific stuff, we don't want them
	set -e && for i in sysctl.d local.d ; do \
		rm -rf $(CURDIR)/debian/tmp/etc/$${i} ; \
	done

	# We don't want any Gentoo init scripts. Debian native scripts are in d/src/{init,conf}.d.
	find $(CURDIR)/debian/tmp/etc/init.d/ $(CURDIR)/debian/tmp/etc/conf.d/ \
		\! -type d -delete

	# Or runlevel symlinks
	for dir in boot default sysinit shutdown; do \
		rm -f $(CURDIR)/debian/tmp/etc/runlevels/$${dir}/* ; \
	done

	# Use Debian's default pam config.
	rm -rf $(CURDIR)/debian/tmp/etc/pam.d/

	dh_install
