#!/usr/bin/make -f
# Made with the aid of debmake, by Christoph Lameter,
# based on the sample debian/rules file for GNU hello by Ian Jackson.

# This is the debhelper compatability version to use.
export DH_COMPAT=1

# This has to be exported to make some magic below work.
export DH_OPTIONS

INST = install -p
package = opennap-ng
installprefix = $(PWD)/debian/tmp


build:
	$(checkdir)
	@echo ".: Configuring packages :."
	@./configure -q --prefix=/usr --sysconfdir=/etc --localstatedir=/var --datadir=/var/lib --with-gid=nogroup
	@echo ".: Building packages :."
	$(MAKE) -s
	touch build

clean:
	$(checkdir)
	@echo ".: Cleaning up :."
	@dh_clean
	@if [ -f Makefile ]; then $(MAKE) distclean ; fi
	@rm -f build
	@echo ".: End cleaning up :."

binary-indep: checkscripts build
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch: checkscripts build
	$(checkdir)
	@echo ".: Preparing packages :."
	@dh_testdir
	@dh_testroot
	@dh_installdirs

	@make -s DESTDIR=$(installprefix) install
	@rm -f $(installprefix)/usr/sbin/setup
	
	@dh_installdocs -Xsample*
	@dh_installchangelogs -k ChangeLog
	@dh_installmanpages
	@dh_installexamples doc/examples/*
	@touch $(installprefix)/var/lib/opennap-ng/users
	@cp doc/examples/sample.motd $(installprefix)/etc/opennap-ng/motd
	@dh_fixperms
	@chown -R nobody:nogroup $(installprefix)/etc/opennap-ng
	@chown -R nobody:nogroup $(installprefix)/var/lib/opennap-ng

	@dh_compress
	@dh_strip
	@dh_shlibdeps
	@dh_makeshlibs -V
	@dh_gencontrol
	@dh_installdeb
	@dh_md5sums
	@dh_builddeb -v
	@echo ".: Done! :."

define checkdir
	@test -f debian/rules
endef

binary: binary-indep binary-arch

checkscripts:
	@echo ".: Checking scripts :."

.PHONY: binary binary-arch binary-indep clean checkscripts
