#!/usr/bin/make -f
include /usr/share/dpkg/architecture.mk

export DEB_BUILD_MAINT_OPTIONS := hardening=+all
export DEB_LDFLAGS_MAINT_APPEND := -Wl,-z,defs

# Workaround broken 32-bit ARM architecture detection in
# build/cmake/aom_configure.cmake
ifeq ($(DEB_HOST_GNU_CPU),arm)
  CONFIG_EXTRA := -DAOM_TARGET_CPU=arm
endif

# Disable optimizations on x32 which fail to build
ifeq ($(DEB_HOST_ARCH),x32)
  CONFIG_EXTRA := -DAOM_TARGET_CPU=generic
endif

# Disable AltiVec on powerpcspe
ifeq ($(DEB_HOST_ARCH),powerpcspe)
  CONFIG_EXTRA := -DENABLE_VSX=OFF
endif

%:
	dh $@ -Bbuild-debian

# Examples and tools not built because they require various private
#  symbols from libaom.so which we filter out.
# Tests disabled because they require network access to download test
#  data.
# Setting GIT_EXECUTABLE to some invalid file prevents the version
#  being taken from git if we're on a Debian packaging git branch.
override_dh_auto_configure:
	dh_auto_configure -- \
		-DBUILD_SHARED_LIBS=1 \
		-DENABLE_TESTS=0 \
		-DGIT_EXECUTABLE=/nonexistant-binary \
		-DLIB_INSTALL_DIR=/usr/lib/$(DEB_HOST_MULTIARCH) \
		$(CONFIG_EXTRA)

# Do not compress html changelog which breaks documentation
override_dh_compress:
	dh_compress -Xchangelog.html
