#!/usr/bin/make -f

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

TCLVERSIONS = 8.6 9.0
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/buildflags.mk

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
BUILDROOT = $(CURDIR)/debian/build

%:
	dh $@

override_dh_auto_configure:
	for v in $(TCLVERSIONS) ; do \
		BUILD_DIR="$(BUILDROOT)/tcl$$v" ;   \
		dh_auto_configure --builddir=$$BUILD_DIR --	\
				  --with-tcl=/usr/lib/tcl$$v	\
				  --prefix=/usr			\
				  --mandir=/usr/share/man	\
				  --infodir=/usr/share/info	\
				  --libdir=/usr/lib/tcltk/$(DEB_HOST_MULTIARCH)     \
				  --libexecdir=/usr/lib/tcltk/$(DEB_HOST_MULTIARCH) ; \
	done

override_dh_auto_build:
	for v in $(TCLVERSIONS) ; do \
		BUILD_DIR="$(BUILDROOT)/tcl$$v" ;   \
		echo "Building tclcurl-ng for Tcl$$v in $$BUILD_DIR" ; \
		dh_auto_build --builddir=$$BUILD_DIR --; \
	done

override_dh_auto_install:
	for v in $(TCLVERSIONS) ; do \
		BUILD_DIR="$(BUILDROOT)/tcl$$v" ;   \
		echo "Install tclcurl-ng files for Tcl$$v version from $$BUILD_DIR" ; \
		dh_auto_install --builddir=$$BUILD_DIR  -- ; \
	done

override_dh_auto_test:

override_dh_makeshlibs:
	dh_makeshlibs
	tcltk-depends

.PHONY: override_dh_auto_install override_dh_auto_configure
