#!/usr/bin/make -f

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

# SOURCE_DATE_EPOCH set by dh
export DEB_CPPFLAGS_MAINT_APPEND = -Wno-error=date-time -Wno-error=maybe-uninitialized -Wno-error=stringop-overflow

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --with python3 --builddirectory=$(CURDIR)

override_dh_auto_configure:
	dh_auto_configure -- -DFLATBUFFERS_BUILD_SHAREDLIB=ON

override_dh_auto_build-arch:
	dh_auto_build --arch

# Python3 build
override_dh_auto_build-indep:
	dh_auto_build --indep
	set -e; cd python && for pv in $(shell py3versions -vr); do \
		VERSION=$(DEB_VERSION) python$$pv setup.py build; \
	done

override_dh_auto_install-arch:
	dh_auto_install --arch

# Python3 install.
override_dh_auto_install-indep:
	dh_auto_install --indep
	set -e; \
	cd python && for pv in $(shell py3versions -vr); do \
		VERSION=$(DEB_VERSION) python$$pv setup.py install \
			--install-layout=deb --no-compile \
			--root=$(CURDIR)/debian/python3-flatbuffers; \
	done
	find $(CURDIR)/debian/python3-flatbuffers -name 'flatbuffers-*-nspkg.pth' -delete
