#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-

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

DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)

PREPROCESS_FILES := $(wildcard debian/*.in)

$(PREPROCESS_FILES:.in=): %: %.in
	sed 's,/@DEB_HOST_MULTIARCH@,$(DEB_HOST_MULTIARCH:%=/%),g' $< > $@

# Ignore test failure on mipsen, see #1030674
IGNORE_TEST_FAILURE=
ifneq (,$(filter mips%,$(DEB_BUILD_ARCH)))
	IGNORE_TEST_FAILURE=-
endif

override_dh_auto_configure:
	dh_auto_configure -- --with-distro="$(shell dpkg-vendor --query vendor)" --with-dyn-default --without-ffmpeg

# Takes care of postinst-has-useless-call-to-ldconfig for libsox-fmt-*
override_dh_makeshlibs:
	dh_makeshlibs -Xfmt

override_dh_auto_clean:
	dh_auto_clean
	rm -rf $(PREPROCESS_FILES:.in=)

override_dh_auto_test:
	$(IGNORE_TEST_FAILURE)cd src && sh tests.sh
	$(IGNORE_TEST_FAILURE)cd src && sh testall.sh

override_dh_auto_install: $(PREPROCESS_FILES:.in=)
	dh_auto_install
	# Force Ubuntu into installing upstream ChangeLog, it contains the
	# list of past contributors
	dh_installchangelogs ChangeLog

%:
	dh $@ --with autoreconf

