#!/usr/bin/make -f
# -*- makefile -*-

export DEB_BUILD_MAINT_OPTIONS=hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND = -D_FILE_OFFSET_BITS=64

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

CMAKE_EXTRA_FLAGS := -DBUILD_EXPERIMENTAL:BOOL=OFF
CMAKE_EXTRA_FLAGS += -DENABLE_FINAL:BOOL=ON
CMAKE_EXTRA_FLAGS += -DCMAKE_EXE_LINKER_FLAGS:STRING="$(LDFLAGS) -Wl,--as-needed"
CMAKE_EXTRA_FLAGS += -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(LDFLAGS) -Wl,--as-needed"
CMAKE_EXTRA_FLAGS += -DLIB_INSTALL_DIR:PATH="/usr/lib/$(DEB_HOST_MULTIARCH)/"
CMAKE_EXTRA_FLAGS += -DPKGCFG_INSTALL_DIR:PATH="/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig"

binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep:
	dh $@ --parallel --list-missing

get-orig-source:
	$(CURDIR)/debian/get-orig-source.sh

override_dh_auto_configure:
	dh_auto_configure -- $(CMAKE_EXTRA_FLAGS)

override_dh_strip:
	dh_strip -a --ddeb-migration='s3d-dbg (<< 0.2.2-14~)'

override_dh_installdocs:
	dh_installdocs -A README Documentation/RelNotes*

.PHONY: binary binary-arch binary-indep build build-arch build-indep clean install install-arch install-indep \
	get-orig-source override_dh_auto_configure override_dh_strip override_dh_installdocs
