#!/usr/bin/make -f
# debian.rules file for the Debian/GNU Linux doc-linux package
# Copyright 1995-96 by Dirk Eddelbuettel <edd@debian.org>

# 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

# There used to be `source' and `diff' targets in this file, and many
# packages also had `changes' and `dist' targets.  These functions
# have been taken over by dpkg-source, dpkg-genchanges and
# dpkg-buildpackage in a package-independent way, and so these targets
# are obsolete.                       

package=doc-linux
docdir=debian/tmp/usr/doc/$(package)
debtmp=debian/tmp
# these two are necessarily local to my machine  --edd
#  faqloc=/mirror/sunsite/faqs/linux-faq
#  howloc=/mirror/sunsite/HOWTO
# this time, I simply untar the howto and mini-howto tar.gz files from the
# LDP; and copy the FAQ from the last release as it rarely changes anyhow as
# Ian J. is so busy
faqloc=/usr/doc/FAQ
howloc=/home/edd

build:
	$(checkdir)
	# nothing to be made here  -$(MAKE)
	echo "As long as the mirror of sunsite is recent..."
	touch build

clean:
	$(checkdir)
	# no target clean in makefile  -$(MAKE) -i clean
	-rm -rf *~ debian/tmp debian/*~ debian/files* build  

binary-indep:	checkroot build
	$(checkdir)
	-rm -rf $(debtmp)
	install -d $(debtmp)/DEBIAN $(docdir)	   
	install -c -m 0755 debian/{postinst,postrm} $(debtmp)/DEBIAN/.	    
	install -d -m 0755 $(debtmp)/usr/doc/FAQ
	install -c -m 0644 $(faqloc)/linux-faq.ascii.gz $(debtmp)/usr/doc/FAQ
	install -c -m 0644 $(faqloc)/linux-faq.ps.gz $(debtmp)/usr/doc/FAQ
	install -c -m 0644 $(faqloc)/linux-faq.README $(debtmp)/usr/doc/FAQ
	install -d -m 0755 $(debtmp)/usr/info
	# install -c -m 0644 $(faqloc)/linux-faq.info.gz $(debtmp)/usr/info
	install -c -m 0644 /usr/info/linux-faq.info.gz $(debtmp)/usr/info
	install -d -m 0755 $(debtmp)/usr/doc/HOWTO
	# (cd $(howloc); tar cf - *) | (cd $(debtmp)/usr/doc/HOWTO; tar xvf -) 
	(cd $(debtmp)/usr/doc/HOWTO; tar xvfz $(howloc)/Linux-HOWTOs.tar.gz) 
	install -d -m 0755 $(debtmp)/usr/doc/HOWTO/mini
	(cd $(debtmp)/usr/doc/HOWTO/mini; \
	   tar xvfz $(howloc)/Linux-mini-HOWTOs.tar.gz) 
	(cd $(debtmp)/usr/doc/HOWTO; \
	   find . -type f ! -name COPYRIGHT ! -name INDEX\* ! -name README | \
	   xargs gzip -9v)
	install -c -m 0644 debian/changelog $(docdir)/.
	gzip -9v $(docdir)/*  
	install -c -m 0644 debian/README.debian $(docdir)/.
	install -c -m 0644 debian/copyright $(docdir)/.
	# dpkg-shlibdeps $(package)
	dpkg-gencontrol
	chown -R root.root debian/tmp
	chmod -R g-ws debian/tmp
	dpkg --build debian/tmp ..  

binary-arch:	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.

define checkdir
	# test -f $(package).c doesn't work here: package name != command name
	test -f debian/rules
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                  
