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

LANG_HR=usr/share/doc/LANG/hr
FAQ=$(LANG_HR)/FAQ
HOWTO=$(LANG_HR)/HOWTO
MINI_HOWTO=$(HOWTO)/mini

export LANG_HR FAQ HOWTO MINI_HOWTO

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 $(FAQ) \
	               $(HOWTO) \
	               $(MINI_HOWTO)
	dh_installdocs members.xoom.com/markovicr/*
	cp -p ftp.linux.hr/pub/dokumentacija/KAKO/*.txt.gz \
	      debian/tmp/$(HOWTO)
	gunzip -c ftp.linux.hr/pub/dokumentacija/KAKO/html/*.html.tar.gz \
	  | tar -C debian/tmp/$(HOWTO) -f - -ix
	mv debian/tmp/$(HOWTO)/Linux-FAQ* \
	   debian/tmp/$(FAQ)
	cp -p ftp.linux.hr/pub/dokumentacija/KAKO/mini/*.txt.gz \
	      ftp.linux.hr/pub/dokumentacija/KAKO/mini/html/*.html.gz \
	      debian/tmp/$(MINI_HOWTO)
	gunzip debian/tmp/$(MINI_HOWTO)/*.html.gz
	cp -p www.linux.hr/hr.comp.linux-FAQ.html \
	      debian/tmp/$(FAQ)
	cp -p www.linux.hr/ldphr/*-KAKO-* \
	      debian/tmp/$(HOWTO)
	cp -p www.linux.hr/ldphr/*-mini-KAKO \
	      debian/tmp/$(MINI_HOWTO)
	find debian/tmp/$(LANG_HR) \
	     -type f ! -name '*.gz' ! -name '*.html' | xargs gzip -9
	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/*
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

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