#!/usr/bin/make -f

PACKAGE=tcl-tclex
DIR=$(shell pwd)/debian/$(PACKAGE)

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -Dsrc -- --prefix=/usr

override_dh_auto_build:
	$(MAKE) -C src

override_dh_auto_clean:
	[ ! -f src/Makefile ] || $(MAKE) -C src distclean

override_dh_auto_install:
	$(MAKE) -C src install TCL_PREFIX=$(DIR)/usr
	mv $(DIR)/usr/lib/tcLex* $(DIR)/usr/lib/tcltk/

override_dh_installdocs:
	dh_installdocs
	# be an irritating wise-a** and change .htm in .html where possible
	for a in `cd doc/en; ls *.htm`; do \
	    cat doc/en/$$a | perl -pe 's/("\w+)\.htm\b/\1.html/g' \
		>$(DIR)/usr/share/doc/$(PACKAGE)/html/$${a}l ; \
	done

override_dh_gencontrol:
	tcltk-depends
	dh_gencontrol

.PHONY: override_dh_auto_configure override_dh_auto_build \
	override_dh_auto_clean override_dh_auto_install \
	override_dh_installexamples override_dh_gencontrol
