#!/usr/bin/make -f

# Tcl/Tk version this extension is built against.
TCLTK_VERSION = 8.6

include /usr/share/dpkg/architecture.mk

# The module is loaded with [load], so unresolved symbols would otherwise
# only be reported at run time.  Fail the link instead.
export DEB_LDFLAGS_MAINT_APPEND = -Wl,-z,defs -Wl,--no-undefined

%:
	dh $@ --without=single-binary

override_dh_auto_configure:
	dh_auto_configure -- \
		--libdir='$${prefix}/lib/tcltk/$(DEB_HOST_MULTIARCH)' \
		--with-tcl=/usr/lib/tcl$(TCLTK_VERSION) \
		--with-tk=/usr/lib/tk$(TCLTK_VERSION) \
		--with-tclinclude=/usr/include/tcl$(TCLTK_VERSION) \
		--with-tkinclude=/usr/include/tcl$(TCLTK_VERSION) \
		LIBS=-lm

# Upstream ships no test suite: the Makefile's "test" target runs
# tests/all.tcl, which is not part of the tarball.
override_dh_auto_test:

override_dh_auto_install:
	dh_auto_install --destdir=debian/tkpng
	# The upstream install target unconditionally creates $(includedir),
	# which stays empty because the package ships no header files.
	find debian/tkpng -type d -empty -delete
