#!/usr/bin/make -f
# Build rules for base-passwd (2.0.x).
# Based heavily on Ian Jackson's sample rules file for GNU hello
# 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.)

package=base-passwd

CFLAGS=-O2
LDFLAGS=-s

build:
	$(checkdir)
	make CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
	touch build

clean:
	$(checkdir)
	rm -f build
	make clean
	-rm `find . -name "*~"`
	rm -rf debian/tmp debian/files* debian/substvars core

binary-indep:	checkroot build
	$(checkdir)
# There are no architecture-dependent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:	checkroot build
	$(checkdir)
	rm -rf debian/tmp
	install -d debian/tmp/DEBIAN debian/tmp/usr/share/base-passwd
	install -d debian/tmp/usr/sbin debian/tmp/usr/doc/$(package)
	install -d debian/tmp/usr/man/man8
	cp debian/postinst debian/tmp/DEBIAN
	chmod a+x debian/tmp/DEBIAN/postinst
	cp update-passwd debian/tmp/usr/sbin
	cp {passwd,group}.master debian/tmp/usr/share/base-passwd
	cp update-passwd.8 debian/tmp/usr/man/man8
	gzip -9v debian/tmp/usr/man/man8/update-passwd.8
	cp debian/changelog debian/tmp/usr/doc/${package}/changelog.Debian
	gzip -9v debian/tmp/usr/doc/${package}/changelog.Debian
	cp README debian/tmp/usr/doc/${package}/README
	gzip -9v debian/tmp/usr/doc/${package}/README
	cp debian/copyright debian/tmp/usr/doc/${package}/copyright
	dpkg-shlibdeps debian/tmp/usr/sbin/update-passwd
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R go-ws debian/tmp
	dpkg --build debian/tmp ..

define checkdir
	test -f update-passwd.c
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

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

checkroot:
	$(checkdir)
	#test root = "`whoami`"

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