#!/usr/bin/make -f

ifeq (,$(filter terse,${DEB_BUILD_OPTIONS}))
export DH_VERBOSE=1
export V=1
export VERBOSE=1
endif

LC_ALL:=C.UTF-8
export LC_ALL

OUR_CPPFLAGS:=
OUR_CFLAGS:=
OUR_CXXFLAGS:=
OUR_LDFLAGS:=

# added by CMakeLists.txt for (CMAKE_BUILD_TYPE MATCHES Debug)
OUR_CPPFLAGS+=	-DDEBUG

dpkgbuildflagsmkescape=$(subst \,\\\,$(1))
export DEB_BUILD_MAINT_OPTIONS:=hardening=+all
export DEB_CPPFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CPPFLAGS})
export DEB_CFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CFLAGS})
export DEB_CXXFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_CXXFLAGS})
export DEB_LDFLAGS_MAINT_APPEND:=$(call dpkgbuildflagsmkescape,${OUR_LDFLAGS})
include /usr/share/dpkg/buildflags.mk
include /usr/share/dpkg/buildtools.mk
include /usr/share/dpkg/pkg-info.mk

%:
	dh $@ --buildsystem=cmake

CMAKE_DEFS:=	-DSPECTRUM_VERSION="${DEB_VERSION_UPSTREAM}"
CMAKE_DEFS+=	-DENABLE_QT4=OFF
# Tests are FTBFS -- TODO to fix that.
CMAKE_DEFS+=	-DENABLE_TESTS=OFF
# Frotz is removed due to license concerns.
CMAKE_DEFS+=	-DENABLE_FROTZ=OFF
CMAKE_DEFS+=	-DCMAKE_VERBOSE_MAKEFILE=On
# incompatible license. (uses mongoose, which is incompatible with some parts of the remaining source.)
CMAKE_DEFS+=    -DENABLE_WEBUI=Off

override_dh_auto_configure:
	exec dh_auto_configure -- ${CMAKE_DEFS}

execute_after_dh_auto_install:
	mkdir -p debian/tmp/usr/share debian/tmp/var/lib/spectrum2
