#!/usr/bin/make -f

SHELL := /bin/bash

override_dh_auto_configure:
	mkdir -p build
	pushd build && \
		cmake \
			.. \
			-DPYBIND11_INSTALL="ON" \
			-DPYBIND11_TEST="OFF" && \
	popd

override_dh_auto_build:
	pip wheel \
		--no-deps \
		--no-build-isolation \
		--wheel-dir=dist \
		.
	pushd build && \
		cmake \
			--build . \
			--parallel 10 \
			--config Release && \
	popd

override_dh_auto_install:
	pip install \
		--no-deps \
		--ignore-installed \
		--root=debian/tmp \
		--prefix=/usr \
		dist/*.whl
	pushd build && \
		export DESTDIR=../debian/tmp && \
		cmake \
			--install . && \
	popd
	mv debian/tmp/usr/local/* debian/tmp/usr/ || echo $$?
	rm -rf debian/tmp/usr/local || echo $$?
	find debian/tmp/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \;
	fdupes -qnrps debian/tmp/usr/lib/python*/*-packages

override_dh_auto_test:

override_dh_auto_clean:

%:
	dh $@ --with python3
