#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DPKG_EXPORT_BUILDFLAGS = 1
export PYBUILD_NAME = primer3-py
export PYBUILD_SYSTEM = pyproject
export PYBUILD_TEST_PYTEST = 1
export PYTEST_DISABLE_PLUGIN_AUTOLOAD = 1

include /usr/share/dpkg/default.mk

# Upstream's makefile needs the cross compiler and Debian build flags.
export CC = $(DEB_HOST_GNU_TYPE)-gcc
export AR = $(DEB_HOST_GNU_TYPE)-ar
export RANLIB = $(DEB_HOST_GNU_TYPE)-ranlib

%:
	dh $@ --buildsystem=pybuild

execute_after_dh_auto_clean:
	$(MAKE) -C primer3/src/libprimer3 clean

execute_after_dh_auto_install:
	# Keep the Cython interface, headers and runtime data. Documentation is
	# installed separately under /usr/share/doc.
	find debian/python3-primer3-py/usr/lib -path '*/primer3/*' \
		\( -name '*.c' -o -name '*.txt' -o -name '*.md' \
		-o -name Makefile -o -name .gitignore \) -delete
	# Upstream omits this header from the wheel's package data.
	for package_dir in debian/python3-primer3-py/usr/lib/python*/dist-packages/primer3; do \
		install -m 644 primer3/p3helpers.pxd "$$package_dir/"; \
	done
