#!/usr/bin/make -f

# The sipsimple core uses Cython 3 syntax (noexcept), which requires
# Cython >= 0.29.32. Jammy only ships cython3 0.29.28, so this build
# pip-installs Cython 0.29.37 into a private directory and puts it on
# PYTHONPATH so it shadows the system cython3 during dh_auto_build.

export DEB_BUILD_HARDENING = 1
export PYBUILD_NAME = sipsimple

CYTHON_DIR = $(CURDIR)/debian/cython-jammy

%:
	dh $@ --with python3 --buildsystem=pybuild

# Regenerate deps/pjsip from the pristine pjproject tarball + patch series.
# Must run here: during dh_auto_build pybuild points http(s)_proxy at
# 127.0.0.1:9, so the fallback in setup_pjsip.py can't download anything.
override_dh_auto_configure:
	bash ./get_dependencies.sh
	dh_auto_configure

override_dh_auto_build:
	python3 -m pip install --disable-pip-version-check --no-warn-script-location --target=$(CYTHON_DIR) "cython==0.29.37"
	PYTHONPATH=$(CYTHON_DIR) dh_auto_build

override_dh_auto_test:
	# Tests require optional dependencies; skip

override_dh_clean:
	dh_clean
	rm -rf build dist MANIFEST $(CYTHON_DIR) deps/pjsip deps/pjproject-*

