#!/usr/bin/make -f
# -*- makefile -*-

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

# parallel build by default on linux
ifeq ($(DEB_HOST_ARCH_OS),linux)
	export DEB_BUILD_OPTIONS+=parallel=$(shell grep -c ^processor /proc/cpuinfo)
endif

#: see http://lists.debian.org/debian-devel-announce/2011/09/msg00001.html
#: Also it does hardening by default, see http://wiki.debian.org/Hardening
DPKG_EXPORT_BUILDFLAGS = 1
-include /usr/share/dpkg/default.mk
#: disabling format hardening due to build problems in some plugins
export DEB_BUILD_MAINT_OPTIONS=hardening=-format

LDFLAGS+= -Wl,--as-needed

series := 2.9
plugins := aiksaurus applix babelfish bmp clarisworks collab command docbook \
	   eml freetranslation garble gdict gimp google grammar hancom \
	   hrtext iscii kword latex loadbindings mathview mht mif mswrite \
	   opendocument openwriter openxml opml ots paint passepartout pdb \
	   pdf presentation s5 sdw t602 urldict wikipedia wmf wml \
	   wordperfect wpg xslfo
# goffice 

%:
	dh $@ --parallel --with autoreconf

override_dh_autoreconf:
	dh_autoreconf -v --as-needed

override_dh_auto_clean:
	dh_auto_clean
	cat debian/patches/series.$(DEB_HOST_ARCH_OS) >> debian/patches/series || return 0
	dh_quilt_patch

#: configure options reference: http://www.abisource.com/wiki/Compiling_AbiWord
override_dh_auto_configure:
	dh_auto_configure -- \
		--without-gnomevfs \
		--with-gio \
		--enable-static \
		--enable-dynamic \
		--enable-clipart \
		--enable-templates \
		--enable-collab-backend-tcp \
		--enable-collab-backend-xmpp \
		--enable-collab-backend-service \
		--enable-shave \
		--disable-silent-rules \
		--enable-plugins="$(plugins)"
## --with-goffice

override_dh_makeshlibs:
	$(RM) debian/abiword/usr/lib/abiword-$(series)/plugins/grammar.*
	$(RM) debian/abiword/usr/lib/abiword-$(series)/plugins/mathview.*
	dh_makeshlibs -V

get-orig-source:
	uscan --noconf --force-download --repack --rename --download-current-version --verbose --destdir=.
