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

package = doc-debian-ko

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

build: stamp-build
stamp-build:
	test -d FAQ -a -f debian/rules
	cd FAQ && $(MAKE) html txt 
	cd FAQ && gzip -9 debian-faq.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: build 
#	dh_installdocs
	dh_installchangelogs

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/$(package)
	cp -p doc/* $(docdir)
	cd FAQ && install -m 644 debian-faq.txt.gz \
                    debian-faq.html/* $(docdir)/FAQ

	install -m 755 debian/prerm debian/postinst $(tmp)/DEBIAN
	install -m 644 debian/copyright $(tmp)/usr/share/doc/$(package)
#	ln -s $(tmp)/usr/share/doc/debian/ko/copyright $(tmp)/usr/doc/debian/ko/copyright	
	gzip -c9 debian/changelog > $(tmp)/usr/share/doc/$(package)/changelog.gz
	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 ../
#	dpkg-distaddfile debian-faq.html.tar.gz byhand -
#	dpkg-distaddfile debian-faq.txt.gz byhand -

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