#!/usr/bin/make -f
# $Id: rules,v 1.4 2004/07/19 19:25:14 john Exp $
# Made with the aid of dh_make, by Craig Small
# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
# Some lines taken from debmake, by Cristoph Lameter.

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

build: build-stamp
build-stamp:
	dh_testdir

	# Add here commands to compile the package.
	#$(MAKE)

	po4a man/po4a.cfg
	po/update.sh

	LANGUAGES=""
	for FILE in po/*.po; do LANG=$$(basename $$FILE .po); \
	LANGUAGES="$$LANGUAGES $$LANG"; \
	done; \
	for F in $${LANGUAGES}; do \
	  msgfmt -o po/$$F.mo po/$$F.po; \
	done

	touch build-stamp

clean:
	dh_testdir
	dh_testroot
	rm -f build-stamp install-stamp

	# Add here commands to clean up after the build process.
	#-$(MAKE) clean
	rm -f po/*.mo
	po4a --rm-translations man/po4a.cfg
	dh_clean

install: install-stamp
install-stamp: build-stamp
	dh_testdir
	dh_testroot
	dh_prep
	dh_installdirs

	# Add here commands to install the package into debian/pppconfig.
	#$(MAKE) install DESTDIR=`pwd`/debian/pppconfig
	install -g root -o root -m 700 pppconfig `pwd`/debian/pppconfig/usr/sbin
	LANGUAGES=""
	for FILE in po/*.mo; do LANG=$$(basename $$FILE .mo); \
	LANGUAGES="$$LANGUAGES $$LANG"; \
	done; \
	for F in $${LANGUAGES}; do \
	  mkdir -p `pwd`/debian/pppconfig/usr/share/locale/$$F/LC_MESSAGES && cp po/$$F.mo `pwd`/debian/pppconfig/usr/share/locale/$$F/LC_MESSAGES/pppconfig.mo; \
	done
	touch install-stamp

# Build architecture-independent files here.
binary-indep: build install
# We have nothing to do by default.
	dh_testdir
	dh_testroot
	dh_installdocs
	dh_installexamples
	dh_installmenu --noscripts
	dh_installcron --noscripts
	dh_lintian
	dh_installman man/pppconfig.8 man/pppconfig.fr.8 man/pppconfig.de.8
	dh_installchangelogs
	cp 0dns-up debian/pppconfig/etc/ppp/ip-up.d/
	cp 0dns-down debian/pppconfig/etc/ppp/ip-down.d/
	cp dns-clean debian/pppconfig/etc/init.d/
	cp dns-clean.service debian/pppconfig/lib/systemd/system/
	dh_systemd_enable
	dh_systemd_start
	dh_compress
	dh_fixperms
	chmod 755 debian/pppconfig/etc/ppp/ip-down.d/0dns-down
	chmod 755 debian/pppconfig/etc/init.d/dns-clean
	chmod 755 debian/pppconfig/etc/ppp/ip-up.d/0dns-up
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb
# Build architecture-dependent files here.
binary-arch: build install

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

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