#!/usr/bin/make -f
# -*- makefile -*-

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

PYVERS=$(shell pyversions -vr)

# do not add +all because pie causes a FTBFS with cmake
export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

# CMake doesn't respect CPPFLAGS.
CFLAGS += $(CPPFLAGS)

%:
	dh $@ --with=python2

override_dh_auto_build: $(PYVERS:%=build-python%)

build-python%:
	make BUILD_DIR="build$*" PREFIX=/usr CMAKE_EXTRA_OPTIONS="-DPython_ADDITIONAL_VERSIONS=$* -DPythonInterp_FIND_VERSION=$*"
	touch $@

override_dh_auto_clean:
	rm -f build-python2.*
	rm -rf build build2.[67]
	dh_auto_clean

override_dh_auto_install: $(PYVERS:%=install-python%)

install-python%:
	$(MAKE) -C build$* DESTDIR=$(CURDIR)/debian/tmp install
	chrpath -d $(CURDIR)/debian/tmp/usr/lib/python2.*/*/*.so

