#!/usr/bin/make -f

# See debhelper(7) (uncomment to enable).
# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1

# See FEATURE AREAS in dpkg-buildflags(1).
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# See ENVIRONMENT in dpkg-buildflags(1).
# Package maintainers to append CFLAGS.
export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic -I/usr/include/tcl
# Package maintainers to append LDFLAGS.
#export DEB_LDFLAGS_MAINT_APPEND = -Wl
DIR = $(shell pwd)/debian/tcl-syslog

%:
	dh $@

override_dh_gencontrol:
	tcltk-depends
	dh_gencontrol

override_dh_auto_configure:
	autoupdate
	dh_auto_configure -- 		\
	--with-tcl=/usr/lib/tcl8.6 	\
	--prefix=/usr 			\
	--libdir=/usr/lib/tcltk 	\
	--libexecdir=/usr/lib/tcltk

override_dh_auto_test:

#override_dh_install:
#	VERSION="1.2" \
#	dh_install

#override_dh_installman:
#	echo "mangling manual page name and section" ; \
#	cat doc/tcl-syslog.n | sed -e 's/"tcl-syslog" "n"/"tcl-syslog" "3tcl"/g' > doc/tcl-syslog.3tcl ; \
#	rm -v doc/tcl-syslog.n
#	dh_installman

override_dh_auto_install:
	dh_auto_install
	mkdir $(DIR)/usr/share/man/man3
	# Fix up the manpages.
	echo "mangling names in tcl-syslog.n"
	cd $(DIR)/usr/share/man/mann && \
	cat tcl-syslog.n | sed -e 's/"tcl-syslog" "n"/"tcl-syslog" "3tcl"/g' > tcl-syslog.3tcl ; \
	mv tcl-syslog.3tcl ../man3/ ; \
	rm tcl-syslog.n; \
	find $(DIR) -empty -prune -exec rmdir \{\} \; ;
