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

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DISTSETUPOPTS="--install-layout=deb"

PY3V := $(shell py3versions -vr)

%:
	dh $@  --with autoreconf,python3

override_dh_auto_configure:
	dh_auto_configure -- --enable-python-bindings --enable-python-plugins \
		--disable-Werror

override_dh_auto_build:
	dh_auto_build -- V=1

override_dh_auto_install:
	dh_auto_install
	rm -f "$(CURDIR)/debian/tmp/usr/lib/*/babeltrace2/plugins/*.a"
	for pv in $(PY3V); do \
	  PYTHON=python$${pv} PYTHON_CONFIG=python$${pv}-config \
	    dh_auto_configure -- --enable-python-bindings --enable-python-plugins \
	      --disable-Werror; \
	  cd src/bindings/python; \
	  make clean; \
	  make install DESTDIR="$(CURDIR)/debian/tmp"; \
	  cd "$(CURDIR)"; \
	done

# The plugins included with the library are not part of the ABI
override_dh_makeshlibs:
	dh_makeshlibs -Xbabeltrace-plugin
