#! /usr/bin/make -f
#   -*- mode: makefile; -*-
#
# Last updated: Sat Dec 17 10:52:20 EST 1994 by imurdock.
#
# To make the binary distribution package, the ``Debianized'' source package
# and the context diff to the original package, type `./debian.rules dist'.
# Make sure that `debian.rules' is executable before the final distribution
# is made.
#
# Invoke each target with `./debian.rules <target>'.  All targets should be
# invoked with the package root as the current directory.
#
# The `binary' target must be run as root, as it needs to install files with
# specific ownerships.  The `diff' target assumes that you have the original
# source package available, unpacked, in ../$(p)-$(v).orig, or that you have
# the previous revision of the ``Debianized'' source package and context diff
# in the parent directory.

CC = gcc

package = fakeroot
major=0
minor=0

arch = $(shell dpkg --print-architecture)

build: 
	make -C .
	#Now testing fakeroot:
	make -C test
	touch build


clean:	
	#Undoes the effect of `make -f debian.rules build'.
	#make distclean
	#rm -f docs/Makefile docs/latextut/Makefile
	rm -rf debian/{files,substvars,tmp,shlibs} build 
	make -C . clean

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


binary-arch:
	rm -rf debian/tmp
	install -d -g root -m 755 -o root debian/tmp/DEBIAN\
	  debian/tmp/usr/{bin,lib/libfakeroot,doc/$(package),man/man1}
	#
	install -s -g root -o root -m 755 \
	   fakeroot debian/tmp/usr/bin
	install -s -g root -o root -m 755 \
	   libfakeroot.so.$(major).$(minor)  debian/tmp/usr/lib/libfakeroot
	ln -s libfakeroot.so.$(major).$(minor) \
	   debian/tmp/usr/lib/libfakeroot/libfakeroot.so.$(major)
	strip --strip-unneeded debian/tmp/usr/lib/libfakeroot/libfakeroot.so.$(major).$(minor)
	install  -g root -o root -m 644 \
	   BUGS README debian/copyright \
	    debian/tmp/usr/doc/$(package)/
	install  -g root -o root -m 644 \
	   debian/changelog\
	    debian/tmp/usr/doc/$(package)/changelog.Debian
	install  -g root -o root -m 644 \
	   fakeroot.1 debian/tmp/usr/man/man1/
	gzip -9 debian/tmp/usr/man/man1/fakeroot.1 \
                debian/tmp/usr/doc/$(package)/*
	(echo "/usr/lib/libfakeroot/libfakeroot	0	" ; \
	 dpkg-shlibdeps -O simple | sed s/shlibs:Depends=//) > debian/shlibs
#ifneq ($(arch),alpha)
#	install -g root -o root -m 644 \
#	   debian/shlibs debian/tmp/DEBIAN
#else
#	install -g root -o root -m 644 \
#	   debian/shlibs.alpha debian/tmp/DEBIAN/shlibs
#endif
	install -g root -o root -m 644 \
	   debian/shlibs debian/tmp/DEBIAN
	#
	dpkg-shlibdeps ./fakeroot 
#	dpkg-shlibdeps ./fakeroot ./libfakeroot.so*
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	#/bin/bash #-c "ls debian/tmp"
	#bash -c "dpkg --build debian/tmp .."
	dpkg --build debian/tmp ..

binary:	 binary-indep binary-arch


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