#!/usr/bin/make -f
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Ithird_party/md5 -Iinclude -fPIC
DEB_CXXFLAGS_MAINT_APPEND = -Ithird_party/md5 -I/usr/include/nlohmann -Iinclude -fPIC -DNDEBUG -DC4CORE_NO_FAST_FLOAT=1
DEB_CXXFLAGS_MAINT_APPEND += $(shell dpkg-buildflags --get CPPFLAGS)
export DEB_CXXFLAGS_MAINT_APPEND

include /usr/share/dpkg/pkg-info.mk
DEB_UPSTREAM_VERSION=$(shell sh -c 'printf "$${1%%+ds*}"' -- "$(DEB_VERSION_UPSTREAM)")

export PYBUILD_NAME = $(DEB_SOURCE)

%:
	dh $@ -Scmake --with python3

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_MAN_PAGES=ON \
		-DUSE_SYSTEM_GTEST=ON \
		-DUSE_SYSTEM_JSON=ON \
		-DUSE_SYSTEM_RAPIDYAML=ON \
		-DBUILD_JSONNET=ON \
		-DBUILD_TESTS=ON

override_dh_auto_build:
	dh_auto_build
	rm -f python/__init__.py
	dh_auto_build --buildsystem=pybuild

override_dh_auto_install:
	dh_auto_install
	dh_auto_install --buildsystem=pybuild
	rm -f $(CURDIR)/debian/tmp/usr/share/doc/jsonnet/html/_layout/base.html

override_dh_auto_clean:
	dh_auto_clean -O-Scmake
	dh_auto_clean -O-Smakefile
	dh_auto_clean --buildsystem=pybuild

override_dh_makeshlibs:
	dh_makeshlibs -- -c0 -v$(DEB_UPSTREAM_VERSION)

execute_after_dh_installexamples:
	rm -f $(CURDIR)/debian/jsonnet/usr/share/doc/jsonnet/examples/bazel/.gitignore
