#!/usr/bin/make -f
%:
	dh $@ 

override_dh_auto_build: 
	/usr/bin/docbook-to-man debian/visual-regexp.sgml > \
	debian/visual-regexp.1

override_dh_auto_install:
	install -m 755 $(CURDIR)/visual_regexp.tcl \
	$(CURDIR)/debian/visual-regexp/usr/bin/visual-regexp

PACKAGE = visual-regexp
SRC_VERSION := $(shell dpkg-parsechangelog |\
                sed -ne 's/^Version: \(\([0-9]\+\):\)\?\(.*\)-.*/\3/p')
TARBALL = $(PACKAGE)_$(SRC_VERSION).orig.tar.gz

get-orig-source:
	rm -rf /tmp/get-orig-source $(TARBALL)
	mkdir -p /tmp/get-orig-source/$(PACKAGE)-$(SRC_VERSION)
	wget 'http://laurent.riesterer.free.fr/regexp/visual_regexp-'$(SRC_VERSION)'.tcl'
	mv 'visual_regexp-'$(SRC_VERSION)'.tcl' /tmp/
	dos2unix '/tmp/visual_regexp-'$(SRC_VERSION)'.tcl'
	mv '/tmp/visual_regexp-'$(SRC_VERSION)'.tcl' \
        '/tmp/get-orig-source/'$(PACKAGE)-$(SRC_VERSION)'/visual_regexp.tcl'
	GZIP=--best tar czf '/tmp/'$(TARBALL) -C \
        /tmp/get-orig-source/ $(PACKAGE)-$(SRC_VERSION)
	rm -rf /tmp/get-orig-source	
	echo "  /tmp/"$(TARBALL)" created; move it to the right destination to build the package"

.PHONY: get-orig-source


