#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk
ifneq ($(DEB_HOST_GNU_TYPE),$(DEB_BUILD_GNU_TYPE))
  CC=$(DEB_HOST_GNU_TYPE)-gcc
else
  CC=gcc
endif

DEB_BUILD_MAINT_OPTIONS := hardening=+all
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/pkg-info.mk

export DEB_CFLAGS_MAINT_APPEND := -gdwarf-4
export DEB_CXXFLAGS_MAINT_APPEND := -gdwarf-4

%:
	dh $@ --buildsystem=cmake

override_dh_auto_configure:
	dh_auto_configure \
		-- -DBUILD_SHARED_LIBS=YES

	dh_auto_configure --builddirectory=static \
		-- -DBUILD_SHARED_LIBS=NO

override_dh_auto_build:
	dh_auto_build
	dh_auto_build --builddirectory=static

override_dh_auto_install:
	dh_auto_install
	dh_auto_install --builddirectory=static --destdir=debian/tmp-static
	cp debian/tmp-static/usr/lib/${DEB_HOST_MULTIARCH}/*.a debian/tmp/usr/lib/${DEB_HOST_MULTIARCH}/
