#!/usr/bin/make -f

DEB_HOST_MULTIARCH  ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@  --with autoreconf,python2

override_dh_auto_configure:
	dh_auto_configure -- --includedir=\$${prefix}/include/$(DEB_HOST_MULTIARCH)

# Ignore testsuite failure on big-endian archs
ifeq (big,$(shell dpkg-architecture -qDEB_BUILD_ARCH_ENDIAN)))
override_dh_auto_test:
	-dh_auto_test
endif

override_dh_auto_install:
	dh_auto_install
	for file in $$(find debian/tmp/usr/lib/ -name "*.la" -o -name _sphinxbase.a); do \
		rm $$file ; \
	done
	# sphinx_config.h is installed alongside the other header files. Make sure
	# it can be found.
	# https://bugs.launchpad.net/ubuntu/+bug/1648877
	sed --in-place s#sphinx_config\.h#sphinxbase/sphinx_config.h# \
		include/sphinxbase/ad.h \
		include/sphinxbase/prim_type.h \
		include/sphinxbase/sbthread.h
