#!/usr/bin/make -f

include /usr/share/dpkg/default.mk
EXTRA_CMAKE_VARIABLES += \
	LOTTIE_MODULE_PATH=/usr/lib/$(DEB_HOST_MULTIARCH)/rlottie/image-loader.so \
	LIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH)

ifeq ($(filter nocheck, $(DEB_BUILD_OPTIONS)),)
 EXTRA_CMAKE_VARIABLES += LOTTIE_TEST=ON
endif

export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow

# Silence assert failures in LottieParser that may be raised due to unexpected
# input data. See Telegram build scripts: https://github.com/desktop-app/cmake_helpers/blob/ac193a597d6b953f9869a240e21e275ce6e388cb/external/rlottie/CMakeLists.txt#L116
export DEB_CPPFLAGS_MAINT_APPEND = -DRAPIDJSON_ASSERT=\(void\)

%:
	dh $@

override_dh_auto_configure:
# blhc, build log analyser, fires on CMake invocation due to .so suffix in the
# variable value. Emit a regexp to ignore this false positive, it's not linking.
	@echo blhc: ignore-line-regexp: '^\s*(?:env\b.*\b)?cmake\b.*\s-DLOTTIE_MODULE_PATH=.*'

	dh_auto_configure -- $(EXTRA_CMAKE_VARIABLES:%=-D%)

# Do not collect exported symbols from the private plugin.
override_dh_makeshlibs:
	dh_makeshlibs -X image-loader.so
