#!/usr/bin/make -f

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH)

export DEB_BUILD_MAINT_OPTIONS = hardening=+fortify,+stackprotector,+relro,+bindnow,-pie
# older bz comprension
export DEB_DH_BUILDDEB_ARGS = -- -Zbzip2
# avoid useless dependencies
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

override_dh_auto_configure:
	dh_auto_configure -- \
		-DCUSTOM_DOCDIR=/usr/share/doc/multicraft-data \
		-DCUSTOM_LOCALEDIR=/usr/share/locale \
		-DCUSTOM_SHAREDIR=/usr/share/games/multicraft \
		-DBUILD_SERVER=ON \
		-DBUILD_CLIENT=ON \
		-DRUN_IN_PLACE=OFF \
		-DENABLE_CURL=ON \
		-DENABLE_SOUND=ON \
		-DENABLE_LUAJIT=ON \
		-DENABLE_GETTEXT=ON \
		-DENABLE_FREETYPE=ON \
		-DENABLE_SYSTEM_GMP=ON \
		-DENABLE_SYSTEM_JSONCPP=ON \
		-DCMAKE_VERBOSE_MAKEFILE=ON \
		-DENABLE_SPATIAL=ON \
		-DENABLE_LEVELDB=ON \
		-DENABLE_REDIS=ON \
		-DENABLE_POSTGRESQL=ON \
		-DJSON_INCLUDE_DIR=/usr/include/jsoncpp \
		-DFREETYPE_INCLUDE_DIR_freetype2=/usr/include/freetype2 \
		-DFREETYPE_INCLUDE_DIR_ft2build=/usr/include \
		-DLEVELDB_INCLUDE_DIR=/usr/include/leveldb \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo

override_dh_install:
	dh_install --list-missing

override_dh_clean:
	dh_clean
	$(RM) -r bin

override_dh_builddeb:
	dh_builddeb -- -Zgzip

%:
	dh ${@}
