#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1
#
# see FEATURE AREAS in dpkg-buildflags(1)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND =

# Try to export buildflags. No guarantee to be useful yet
DPKG_EXPORT_BUILDFLAGS = 1
include /usr/share/dpkg/default.mk
include /usr/share/dpkg/buildflags.mk


%:
	dh $@ --with python3

ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
TEST_FLAG := ON
else
TEST_FLAG := OFF
endif

# PYTHON_EXECUTABLE: force selection of default python version
#
# UNIT_TESTS: should only be used in debug builds, disable it
# following upstream recommendation.
#
# CMAKE_CXX_STANDARD: set to 20 to enable DataMatrix multi-symbol
# detection (see #1028912). Otherwise default to 17.
#     WARNING: enabling/disabling this flag may break ABI!
#
override_dh_auto_configure:
	dh_auto_configure -- \
	        -DBUILD_BLACKBOX_TESTS=$(TEST_FLAG)  \
	        -DBUILD_UNIT_TESTS=OFF               \
	        -DBUILD_PYTHON_MODULE=ON             \
	        -DBUILD_DEPENDENCIES=LOCAL           \
	        -DCMAKE_CXX_STANDARD=20              \
	        -DPYTHON_EXECUTABLE:FILEPATH=$(shell command -v $$(py3versions -d))

override_dh_auto_test:
	# Exclude tests that needs samples directory
	dh_auto_test -- \
	        ARGS\+=-E \
	        ARGS\+=ReaderTest \
	        $(NULL)
