#!/usr/bin/make -f
# Sample debian.rules file - for GNU Hello (1.3).
# Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)
# This file may have to be extensively modified

#export DH_VERBOSE=1

export D=$(CURDIR)/debian/netbase

build:
	dh_testdir

#	check for duplicate etc-services entries and abort if any found
	@echo Checking for duplicate services:
	@if (sed 's/#.*$$//;s/[[:space:]][[:space:]]*/ /g' etc-services | \
	      while read name serv other; do \
	        for a in $$name $$other; do echo $$a $$serv; done; \
              done | sort | uniq -d | sed 's/^/  /' | grep ^); \
        then \
	  false; \
	else \
	  echo "  None found"; \
	fi

clean:
	dh_testdir
	dh_testroot

	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs etc/ etc/network/ usr/share/perl5/ usr/sbin/

	install -o root -g root -m 0644 etc-protocols $D/etc/protocols
	install -o root -g root -m 0644 etc-rpc $D/etc/rpc
	install -o root -g root -m 0644 etc-services $D/etc/services
	install -o root -g root -m 0644 DebianNet.pm $D/usr/share/perl5/
	install -o root -g root -m 0755 update-inetd $D/usr/sbin/

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installchangelogs
	dh_installdocs
	dh_installdebconf
	dh_installinit --noscripts --init-script=networking
	dh_installman DebianNet.3pm update-inetd.8
	dh_perl
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_shlibdeps
	dh_gencontrol
	dh_builddeb

binary: binary-indep

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