#!/usr/bin/make -f

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

BENTO4_COMPONENT = bento4-embedded
BENTO4_URL = depends/common/bento4/bento4.tar.xz

%:
	dh $@

override_dh_auto_configure:
	#‌ basilgello: Embed Bento4 in more accountable manner,
	#‌ so Debian package follows upstream changes
	# TODO: upstream Kodi patches for Bento4
	tar -cf $(BENTO4_URL) $(BENTO4_COMPONENT)
	# basilgello: -DCMAKE_INSTALL_DIR silences Kodi buildsystem
	# warning triggered by dh_configure unnecessarily overriding
	# install directory
	# -DUSE_LTO=0 disables LTO and makes build reproducible
	dh_auto_configure -- -DCMAKE_BUILD_TYPE=ReleaseWithDebInfo \
            -DBUILD_SHARED_LIBS=1 \
            -DCMAKE_INSTALL_LIBDIR=/usr/lib/$(DEB_HOST_MULTIARCH)/kodi \
            -DENABLE_INTERNAL_BENTO4=1 \
            -DBENTO4_URL=${BENTO4_URL} \
            -DUSE_LTO=0
