#!/usr/bin/make -f

# Set additional linker flags for security hardening of libraries:
export DEB_BUILD_MAINT_OPTIONS = hardening=+all         # best practice
# export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow   # minimal setting to satisfy lintian on --pedantic setting

# The main loop that passes control to debhelper
%:
	dh $@

# Override dh_auto_configure to run the configuration pass for the shared and static library, with relevant cmake options
override_dh_auto_configure:
	# 1. Configure the static library build into a separate directory
	dh_auto_configure --builddirectory=build-static -- \
		-DBUILD_SHARED_LIBS=OFF \
		-DCMAKE_BUILD_TYPE=Release \
		-DOPENXLSX_LOCAL_PACKAGES_ONLY=ON \
		-DOPENXLSX_BUILD_SAMPLES=OFF \
		-DOPENXLSX_INSTALL_SAMPLE_SOURCES=OFF \
		-DOPENXLSX_ENABLE_LIBZIP=ON

	# 2. Configure the standard shared library build into the default directory
	dh_auto_configure --builddirectory=build-shared -- \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=Release \
		-DOPENXLSX_LOCAL_PACKAGES_ONLY=ON \
		-DOPENXLSX_BUILD_SAMPLES=OFF \
		-DOPENXLSX_INSTALL_SAMPLE_SOURCES=ON \
		-DOPENXLSX_ENABLE_LIBZIP=ON

# Override dh_auto_build to compile both targets
override_dh_auto_build:
	dh_auto_build --builddirectory=build-static
	dh_auto_build --builddirectory=build-shared

# Override dh_auto_test to test both targets (comprehensive piuparts tests)
override_dh_auto_test:
	dh_auto_test --builddirectory=build-static
	dh_auto_test --builddirectory=build-shared

# Override dh_auto_install to stage both library assets into debian/tmp
override_dh_auto_install:
	dh_auto_install --builddirectory=build-static
	dh_auto_install --builddirectory=build-shared
