#!/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

package=netbase

export DH_COMPAT=1

export BASEDIR=$(shell pwd)/debian/tmp
export DESTDIR=$(shell pwd)/debian/tmp

ARCH:=$(shell dpkg --print-architecture)

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

	install -o root -g root -m 0755 debian/networking.init.d `pwd`/debian/tmp/etc/init.d/networking
	install -o root -g root -m 0644 etc-gateways `pwd`/debian/tmp/etc/gateways
	install -o root -g root -m 0644 gateways.5 `pwd`/debian/tmp/usr/share/man/man5
	install -o root -g root -m 0644 etc-protocols `pwd`/debian/tmp/etc/protocols
	install -o root -g root -m 0644 etc-rpc `pwd`/debian/tmp/etc/rpc
	install -o root -g root -m 0644 etc-services `pwd`/debian/tmp/etc/services
	install -o root -g root -m 0644 DebianNet.pm `pwd`/debian/tmp/usr/share/perl5/DebianNet.pm
	install -o root -g root -m 0644 DebianNet.3pm `pwd`/debian/tmp/usr/share/man/man3
	install -o root -g root -m 0755 update-inetd `pwd`/debian/tmp/usr/sbin
	install -o root -g root -m 0644 update-inetd.8 `pwd`/debian/tmp/usr/share/man/man8
	install -o root -g root -m 0644 resolv+.8 `pwd`/debian/tmp/usr/share/man/man8

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

binary-arch: build install
	dh_testdir
	dh_testroot
	dh_installdebconf
	dh_installdocs
	dh_installexamples
#	dh_installemacsen
#	dh_installpam
#	dh_installinit (done by hand)
	dh_installcron
# done by hand previously
#	dh_installmanpages
	dh_installinfo
#	dh_undocumented
	dh_installchangelogs
	dh_link
	dh_strip
	dh_compress
	dh_fixperms
#	dh_suidregister
#	dh_makeshlibs
	dh_installdeb
	dh_perl
	dh_shlibdeps
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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 install
