#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

# Optional local sysroot when lib66-dev / liboblibs-dev are not installed.
OBLIBS_ROOT ?=

MESON_EXTRA =
ifneq ($(wildcard $(OBLIBS_ROOT)/usr/include/66/config.h),)
MESON_EXTRA += -Dwith-include-dir=$(OBLIBS_ROOT)/usr/include
MESON_EXTRA += -Dwith-dynamiclib-dir=$(OBLIBS_ROOT)/usr/lib/$(DEB_HOST_MULTIARCH)
export LD_LIBRARY_PATH := $(OBLIBS_ROOT)/usr/lib/$(DEB_HOST_MULTIARCH)$(if $(LD_LIBRARY_PATH),:$(LD_LIBRARY_PATH))
endif

%:
	dh $@

override_dh_auto_configure:
	dh_auto_configure -- \
		-Denable-shared=true \
		-Denable-static=false \
		-Denable-static-deps=false \
		-Denable-static-executable=false \
		-Denable-pie=true \
		-Dwith-doc=false \
		-Dtest=false \
		-Duserd-pam-dir=/usr/lib/$(DEB_HOST_MULTIARCH)/security \
		$(MESON_EXTRA)

override_dh_auto_test:
	@echo "Skipping upstream tests (disabled at configure time)."

override_dh_auto_install:
	dh_auto_install --destdir=debian/tmp
