#!/usr/bin/make -f

export DH_VERBOSE=1

# dh_python3 needs DEB_HOST_ARCH, so ... sledge hammer:
include /usr/share/dpkg/default.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export LIBS="pthread"
export DESTDIR=debian/tmp

DH_FLAGS += --max-parallel=1

%:
	dh $@ --buildsystem=cmake ${DH_FLAGS}

# ON or OFF
BUILD_TESTS=ON

override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) \
		-DCORE_3RD_PARTY_INSTALL_STEP=ON \
		-DCORE_COMPILE_STEP=ON \
		-DCORE_SPDLOG_SUPPORT=OFF \
		-DCORE_WITH_TESTS=$(BUILD_TESTS) \
		-DDEBUG=ON \
		-DDISABLE_DOWNLOADS=ON \
		-DGOOGLE_TEST_FOUND=YES \
		-DGOOGLE_TEST_INCLUDE_DIR:STRING=/usr/include \
		-DGOOGLE_TEST_LIBRARY_DIR:STRING=/usr/lib/$(shell uname -m)-$(shell uname -s | tr '[A-Z]' '[a-z]')-gnu \
		-DPRE_COMPILE_STEP=ON \
		-DPROFILE=OFF \
		-DPYTHON_BINDING:STRING=pyBind \
		-DPYTHON_EXECUTABLE=/usr/bin/python3 \
		-DSPDLOG_INCLUDE_DIR:STRING=/usr/include/spdlog \
		-DWITH_EXAMPLES=OFF \
	       	-DOUTPUT_DIR:STRING=debian/tmp \
	       	-DPROJECT_3RD_LOC:STRING=debian/tmp

ifeq ($(BUILD_TESTS),OFF)
override_dh_auto_test:
	@echo "Build time testing disabled."
endif
