# The name of the package (for example, `emacs').
p = adduser
# The version of the package (for example, `19.28').
v = 1.94
# The Debian revision of the package (for example, `2').
d = 3


all: adduser

build: all

bindir=/usr/sbin
etcdir=/etc
mandir=/usr/man

adduser: adduser.pl
	cp adduser.pl adduser
	chmod a+x adduser
	chmod u+w adduser

clean:
	rm -f  adduser
	rm -rf debian-tmp
	rm -rf *~

install: adduser
	install adduser $(bindir)/adduser
	install -m 644 adduser.conf $(etcdir)/adduser.conf
	install -m 644 adduser.8 $(mandir)/man8/adduser.8
	install -m 644 adduser.conf.5 $(mandir)/man5/adduser.conf.5

binary: adduser
	install -d -g root -m 755 -o root debian-tmp
	chmod g-s debian-tmp
	install -d -g root -m 755 -o root debian-tmp/DEBIAN
	install -d -g root -m 755 -o root debian-tmp/etc
	install -g root -m 644 -o root adduser.conf \
	  debian-tmp/etc/adduser.conf
	install -d -g root -m 755 -o root debian-tmp/usr/sbin
	install -g root -m 755 -o root adduser \
	  debian-tmp/usr/sbin/adduser
	(cd debian-tmp/usr/sbin; ln -s adduser addgroup)
	install -d -g root -m 755 -o root debian-tmp/usr/man/man8
	install -g root -m 644 -o root adduser.8 \
	  debian-tmp/usr/man/man8/adduser.8
	(cd debian-tmp/usr/man/man8; ln -s adduser.8 addgroup.8)
	install -d -g root -m 755 -o root debian-tmp/usr/man/man5
	install -g root -m 644 -o root adduser.conf.5 \
	  debian-tmp/usr/man/man5/adduser.conf.5
	install -d -g root -m 755 -o root debian-tmp/usr/doc/copyright
	install -g root -m 644 -o root debian.README \
	  debian-tmp/usr/doc/copyright/adduser
	sed -e '2s/=/$(v)/; 3s/=/$(d)/' \
	debian.control > debian-tmp/DEBIAN/control
	chown root.root debian-tmp/DEBIAN/control
	chmod 644 debian-tmp/DEBIAN/control
	install -g root -m 644 -o root debian.conffiles \
	  debian-tmp/DEBIAN/conffiles
	dpkg --build debian-tmp
	mv debian-tmp.deb ../adduser-$(v)-$(d).deb

diff::

source: clean
# Makes a source package.
	( cd .. && tar cf - $(p)-$(v) | gzip -9f > $(p)-$(v)-$(d).tar.gz )

dist: binary source
