#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
include /usr/share/python3/python.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# export DEB_LDFLAGS_MAINT_APPEND = -Wl,-O1 -Wl,-z,defs

PYVERS := $(shell py3versions --supported -v)
FLAVOURS := $(PYVERS)

%:
	dh $@

override_dh_auto_configure:
	set -e && for x in $(FLAVOURS); do \
	    dh_auto_configure --builddirectory=build-$$x -- \
		-Dauto_features=enabled -Dpython=/usr/bin/python$$x \
	        -Dlibpython-dir="`/usr/bin/python$$x-config --configdir`" ; \
	done

override_dh_auto_build:
	set -e && for x in $(FLAVOURS); do \
	    dh_auto_build --builddirectory=build-$$x; \
	done

override_dh_auto_test:
ifneq ($(DEB_HOST_ARCH_OS),hurd)
	set -e && for x in $(FLAVOURS); do \
			dh_auto_test --builddirectory=build-$$x; \
	done
endif

override_dh_auto_install:
	set -e && for x in $(FLAVOURS); do \
	    INST=debian/install-`echo $$x | sed 's/\.[0-9]*//'`; \
	    dh_auto_install --builddirectory=build-$$x --destdir=$$INST; \
	done

execute_before_dh_auto_clean:
	rm -rf build-*
	rm -rf debian/install-*

override_dh_install:
	dh_install -ppython3-gst-1.0 -pgstreamer1.0-python3-plugin-loader --sourcedir=debian/install-3
