#!/usr/bin/make -f

%:
	dh $@

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
#fix FTBFS with binutils-gold
export DEB_LDFLAGS_MAINT_APPEND = -lm

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

# If it's a linux OS use alsa, else use oss.
ifeq ($(DEB_BUILD_ARCH_OS),linux)
AUDIO=alsa
else
AUDIO=oss
endif

override_dh_auto_clean:
	dh_update_autotools_config
	[ ! -f config.log ] || dh_auto_clean

override_dh_auto_configure:
	dh_auto_configure -- --with-audio=$(AUDIO) \
		--with-vox=cmu_us_kal16 --enable-shared

override_dh_auto_build:
	$(MAKE)
	(set -e; cd doc; $(MAKE) flite.pdf flite.html; makeinfo flite.texi)

override_dh_install:
	dh_install
	dh_install -plibflite1 build/*/lib/*.so.* usr/lib/$(DEB_HOST_MULTIARCH)
	rm -f build/*/lib/*.shared.a
	dh_install -pflite1-dev build/*/lib/*.so build/*/lib/*.a usr/lib/$(DEB_HOST_MULTIARCH)
