#! /usr/bin/make -f

DEB_HOST_MULTIARCH=$(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed
# see #789111
export DEB_LDFLAGS_MAINT_STRIP=-Wl,-Bsymbolic-functions
# LFS support and multiarch path to look up 10bit library
export DEB_CPPFLAGS_MAINT_APPEND=$(shell getconf LFS_CFLAGS) \
	-DDEB_HOST_MULTIARCH=\"/usr/lib/$(DEB_HOST_MULTIARCH)/\"

%:
	dh $@ --parallel --buildsystem=cmake \
		--sourcedirectory=source \
		--builddirectory=x265-8bit

override_dh_auto_clean:
	dh_auto_clean --builddirectory=x265-10bit
	dh_auto_clean
	rm -rf doc/reST/build

override_dh_auto_configure:
	dh_auto_configure --builddirectory=x265-10bit -- \
		-DENABLE_PIC=ON \
		-DHIGH_BIT_DEPTH=ON \
		-DENABLE_CLI=OFF \
		-DLIB_INSTALL_DIR=lib/$(DEB_HOST_MULTIARCH)/x265-10bit
	dh_auto_configure -- \
		-DENABLE_PIC=ON \
		-DLIB_INSTALL_DIR=lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_build-arch:
	dh_auto_build --builddirectory=x265-10bit
	dh_auto_build

override_dh_auto_install-arch:
	dh_auto_install --builddirectory=x265-10bit
	dh_auto_install

override_dh_auto_build-indep:
	$(MAKE) -C doc/reST html

override_dh_installdocs-indep:
	dh_installdocs
	dh_sphinxdoc

override_dh_strip:
	dh_strip -plibx265-59 --dbg-package=libx265-59-dbg
	dh_strip --remaining-packages
