#!/usr/bin/make -f
# Sample debian/rules that uses debhelper.
# GNU copyright 1997 by Joey Hess.

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

export VER=8.5
export TCLVER=8.5.0-1
export TKVER=8.5.0-1
export COMPATVER=8.5.0-1

DOCS = tcltk-policy.html tcltk-policy.txt tcltk-policy.pdf

#
# A new policy should be get manually and only after agreement
#
POLICY = 0.2.0
get-policy:
	svn export svn://svn.debian.org/svn/pkg-tcltk/policy/tags/$(POLICY)/tcltk-policy.sgml

tcltk-policy.html: tcltk-policy.sgml
	LANG=C debiandoc2html -1 -x tcltk-policy.sgml
	mv tcltk-policy.html/index.html index.html
	rm -rf tcltk-policy.html
	mv index.html tcltk-policy.html 

tcltk-policy.txt: tcltk-policy.sgml
	LANG=C debiandoc2text tcltk-policy.sgml

tcltk-policy.pdf: tcltk-policy.sgml
	LANG=C debiandoc2pdf tcltk-policy.sgml 
	rm -f tcltk-policy.tpt

build-policy: $(DOCS)

debian/control: debian/control.in
	sed -e "s/@VER@/$(VER)/g" \
	    -e "s/@TCLVER@/$(TCLVER)/g" \
	    -e "s/@TKVER@/$(TKVER)/g" \
		<debian/control.in >debian/control

%:
	dh $@

override_dh_clean: debian/control
	dh_testdir
	dh_testroot
	rm -f *-stamp
	rm -f debian/tcltk-depends
	rm -f debian/*.postinst
	rm -f debian/*.prerm
	rm -f $(DOCS)
	dh_clean

build: debian/control build-policy

override_dh_installdirs:
	dh_installdirs
	for f in debian/*.p*.in debian/tcltk-depends.in; do \
	    sed -e "s/@VER@/$(VER)/g" \
	    	-e "s/@COMPATVER@/$(COMPATVER)/g" \
		<$$f >$${f%%.in} ; \
	done

override_dh_installdocs:
	dh_installdocs -A debian/README.Debian -Ntk-doc

override_dh_installchangelogs:
	dh_installchangelogs -Ntk-doc

override_dh_compress:
	dh_compress -X.pdf

.PHONY: build get-policy build-policy
