#!/usr/bin/make -f
#export DH_VERBOSE = 1


export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

include /usr/share/dpkg/pkg-info.mk

export PYBUILD_SYSTEM = distutils


%:
	dh $@ --with python3

%-arch:
	dh $@

%-indep:
	dh $@ --with python3

clean:
	dh $@

override_dh_auto_clean-indep:
	dh_auto_clean --buildsystem=pybuild --sourcedirectory=python/
	rm -rf python/qrcodegen.egg-info

override_dh_auto_build-indep:
	dh_auto_build --buildsystem=pybuild --sourcedirectory=python/

override_dh_auto_install-indep:
	dh_auto_install --buildsystem=pybuild --sourcedirectory=python/

override_dh_auto_clean-arch:
	dh_auto_clean --sourcedirectory=c/
	dh_auto_clean --sourcedirectory=cpp/

override_dh_clean-arch:
	dh_clean -a
	rm -rf ./c/libqrcodegen.so.1 ./cpp/libqrcodegencpp.so.1

override_dh_auto_build-arch:
	dh_auto_build --sourcedirectory=c/
	dh_auto_build --sourcedirectory=cpp/

override_dh_auto_test-arch:
	ln -sf libqrcodegen.so ./c/libqrcodegen.so.1
	ln -sf libqrcodegencpp.so ./cpp/libqrcodegencpp.so.1
	cd python && python3 qrcodegen-batch-test.py
	rm -rf ./c/libqrcodegen.so.1 ./cpp/libqrcodegencpp.so.1

override_dh_auto_install-arch:
	dh_auto_install --sourcedirectory=c/ -- QRCODEGEN_VERSION="$(DEB_VERSION_UPSTREAM)"
	dh_auto_install --sourcedirectory=cpp/ -- QRCODEGEN_VERSION="$(DEB_VERSION_UPSTREAM)"
