#! /usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS?=hardening=-pie

export DEB_LDFLAGS_MAINT_APPEND=-Wl,--as-needed
# LFS support
export DEB_CPPFLAGS_MAINT_APPEND=$(shell getconf LFS_CFLAGS)

include /usr/share/dpkg/architecture.mk

I=$(CURDIR)/debian/install
PKGL=libsvt-hevc-1

%:
	dh $@ --buildsystem=cmake

override_dh_auto_clean:
	dh_auto_clean
	rm -rf bin Build/linux/release debian/install debian/$(PKGL)*.install

# -arch bits

override_dh_auto_configure-arch:

override_dh_auto_build-arch:
	# Static build
	cd $(CURDIR)/Build/linux && ./build.sh --prefix /usr --static release && cd Release && make install DESTDIR=$(I)
	# Dynamic build
	cd $(CURDIR)/Build/linux && ./build.sh --prefix /usr release && cd Release && make install DESTDIR=$(I)
	# Sometimes it multilib, sometimes not
	# Workaround for multi-arch paths
	SUFF=noma; [ -n "$(DEB_HOST_MULTIARCH)" -a -d $(I)/usr/lib/$(DEB_HOST_MULTIARCH) ] && SUFF=ma; \
	cd debian && cp -v $(PKGL)-dev.install.$${SUFF} $(PKGL)-dev.install && cp -v $(PKGL).install.$${SUFF} $(PKGL).install;

override_dh_auto_install-arch:

override_dh_install:
	dh_install --sourcedir=$(I) -a
	dh_install -i

# -indep bits

# no configure, test and install for indep
override_dh_auto_configure-indep override_dh_auto_test-indep override_dh_auto_install-indep:

override_dh_auto_build-indep:

override_dh_auto_test:
