#!/usr/bin/make -f
# derived from sample debian/rules file for GNU hello by Ian Jackson.

tmp = $(shell pwd)/debian/tmp
docdir = $(tmp)/usr/share/doc/debian-ja

build: stamp-build
stamp-build:
	test -d FAQ -a -f debian/rules
	cd FAQ && $(MAKE) html txt
	cd FAQ && gzip -9 debian-faq.ja.txt
	touch $@

clean:
	test -d FAQ -a -f debian/rules
	test "`id -u`" -eq 0
	cd FAQ && $(MAKE) clean
	rm -rf $(tmp)
	rm -f FAQ/*.gz stamp-build debian/files `find . -name "*~"`

refresh:
	cd doc && wget -N -R "*keyring*" -R "*INDEX*" \
          ftp://ftp.debian.org/debian/doc/*
	chmod 644 doc/*

binary: binary-indep binary-arch

binary-arch:

binary-indep: build
	test -d FAQ -a -f debian/rules
	test "`id -u`" -eq 0
	rm -rf $(tmp)

	install -m 755 -d $(tmp)/DEBIAN $(docdir)/FAQ \
          $(tmp)/usr/share/doc-base $(tmp)/usr/share/doc/doc-debian-ja
	cp -pr doc/* $(docdir)
	cd FAQ && install -m 644 debian-faq.ja.txt.gz \
                    debian-faq.ja.html/* $(docdir)/FAQ

	install -m 755 debian/prerm debian/postinst $(tmp)/DEBIAN
	install -m 644 doc-base/* $(tmp)/usr/share/doc-base
	install -m 644 debian/copyright $(tmp)/usr/share/doc/doc-debian-ja
	gzip -c9 debian/changelog > $(tmp)/usr/share/doc/doc-debian-ja/changelog.gz
	install -m 644 debian/README* $(tmp)/usr/share/doc/doc-debian-ja
	chown -R root.root $(tmp) && chmod -R go=rX $(tmp)
	dpkg-gencontrol -isp
	dpkg --build $(tmp) ..

# The extra-package files:
#	cd FAQ/debian-faq.html && GZIP=-9 tar czf ../../../debian-faq.html.tar.gz *
#	cp FAQ/debian-faq.txt.gz FAQ/debian-faq.ps.gz ../
#	dpkg-distaddfile debian-faq.html.tar.gz byhand -
#	dpkg-distaddfile debian-faq.txt.gz byhand -
#	dpkg-distaddfile debian-faq.ps.gz byhand -

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