#!/usr/bin/make -f

#export DH_VERBOSE = 1

export PYBUILD_NAME=python-jq

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

oniguruma_version = "6.9.4"
jq_version = "1.6"

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

override_dh_auto_configure:
	mkdir -p $(CURDIR)/_deps
	wget https://github.com/kkos/oniguruma/releases/download/v$(oniguruma_version)/onig-$(oniguruma_version).tar.gz -O $(CURDIR)/_deps/onig-$(oniguruma_version).tar.gz
	cd _deps && tar -xzvf onig-$(oniguruma_version).tar.gz
	cd _deps/onig-$(oniguruma_version) && ./configure CFLAGS=-fPIC --prefix=$(CURDIR)/_deps/onig-install-$(oniguruma_version)
	cd _deps/onig-$(oniguruma_version) && make
	cd _deps/onig-$(oniguruma_version) && make install

	wget https://github.com/stedolan/jq/releases/download/jq-$(jq_version)/jq-$(jq_version).tar.gz -O $(CURDIR)/_deps/jq-$(jq_version).tar.gz
	cd _deps && tar -xzvf jq-$(jq_version).tar.gz
	cd _deps/jq-$(jq_version) && ./configure CFLAGS="-fPIC -pthread" --disable-maintainer-mode --with-oniguruma=$(CURDIR)/_deps/onig-install-$(oniguruma_version)
	cd _deps/jq-$(jq_version) && make

	cython3 jq.pyx

	dh_auto_configure
