#!/usr/bin/make -f

# DH_VERBOSE := 1

include /usr/share/dpkg/default.mk

BUILD_DIR := obj-$(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
BUILD_DATE := $(shell TZ=UTC LC_ALL=C dpkg-parsechangelog | grep Date: | cut -d' ' -f2-7)
export BDATE=$(shell TZ=UTC LC_ALL=C date -d"$(BUILD_DATE)" +'%Y-%m-%d')
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND += -DSIMDE_ENABLE_OPENMP -fopenmp-simd -O3
export DEB_CXXFLAGS_MAINT_APPEND += -DSIMDE_ENABLE_OPENMP -fopenmp-simd -O3

%:
	dh $@ --buildsystem=cmake

override_dh_install-arch:
	dh_install -a
	# install binary
	cp -a $(BUILD_DIR)/bin/*/plast debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)/bin
	# no need for the includes
	rm -rf debian/*/usr/include

override_dh_auto_configure-indep:
override_dh_auto_build-indep:
override_dh_auto_install-indep:
	echo "I: Nothing to do for arch:indep binary"

override_dh_gencontrol-arch:
	dh_gencontrol -- -Vsimde:Built-Using="$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W "libsimde-dev")"

override_dh_auto_test-indep:
override_dh_auto_test-arch:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	scripts/test-plast.sh
endif
