#!/usr/bin/make -f
# Based on Josip Rodin's work, which was based on a dh_make example.

howto = usr/share/doc/HOWTO
howto_html = $(howto)/hr-html
howto_txt = $(howto)/hr-txt
mini_howto_html = $(howto_html)/mini
mini_howto_txt = $(howto_txt)/mini

export howto howto_html howto_txt mini_howto_html mini_howto_txt

clean:
	dh_testdir
	dh_testroot
	dh_clean

build:

binary: binary-arch binary-indep

binary-arch:

binary-indep:
	dh_testdir
	dh_testroot
	dh_clean
	dh_installchangelogs
	dh_installdirs $(howto) \
	               $(howto_html) $(howto_txt) \
	               $(mini_howto_html) $(mini_howto_txt)
	dh_installdocs members.xoom.com/markovicr/*
	perl -pi -e 'while(s/(.*)\$$[({](.*?)[)}]/$$1$$ENV{$$2}/){}' \
	         -e 'y/ÈÆ©®èæ¹¾/CCSZccsz/;' \
	         -e 's/Ð(?=[A-ZÐ])/DJ/g;' \
	         -e 's/(?<=[A-Z])Ð(?=[^a-z]|$$)/DJ/g;' \
	         -e 's/Ð/Dj/g;' \
	         -e 's/ð/dj/g;' debian/tmp/usr/share/doc-base/*
	zcat ftp.linux.hr/pub/dokumentacija/KAKO/html/*.html.tar.gz \
	  | tar -C debian/tmp/$(howto_html) -ixf -
	cp -p www.linux.hr/hr.comp.linux-FAQ.html \
	      debian/tmp/$(howto_html)
	cp -p ftp.linux.hr/pub/dokumentacija/KAKO/*.txt.gz \
	      debian/tmp/$(howto_txt)
	cp -p www.linux.hr/ldphr/*-KAKO-* \
	      debian/tmp/$(howto_txt)
	cp -p ftp.linux.hr/pub/dokumentacija/KAKO/mini/html/*.html.gz \
	      debian/tmp/$(mini_howto_html)
	gunzip debian/tmp/$(mini_howto_html)/*.html.gz
	cp -p ftp.linux.hr/pub/dokumentacija/KAKO/mini/*.txt.gz \
	      debian/tmp/$(mini_howto_txt)
	cp -p www.linux.hr/ldphr/*-mini-KAKO \
	      debian/tmp/$(mini_howto_txt)
	find debian/tmp/$(howto) -type f ! -name '*.gz' ! -name '*.html' \
	  | xargs gzip -9
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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