#!/usr/bin/make -f

include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/rules/patchsys-quilt.mk
include /usr/share/cdbs/1/class/gnome.mk

# workaround for http://bugs.debian.org/526392
QUILT_PATCH_DIR := debian/patches
QUILT_STAMPFN := patch
-include /usr/share/topgit/tg2quilt.mk

series := 2.9

plugins := aiksaurus applix babelfish bmp clarisworks collab command docbook \
	   eml freetranslation gdict gimp goffice 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 \
	   garble

DEB_CONFIGURE_EXTRA_FLAGS := --enable-static --enable-dynamic \
			     --enable-clipart --enable-templates \
			     --enable-collab-backend-xmpp \
			     --enable-collab-backend-tcp \
			     --enable-collab-backend-service \
			     --enable-shave \
			     --enable-plugins="$(plugins)" --without-gnomevfs \
			     --with-gio --with-goffice
DEB_INSTALL_DOCS_ALL := $(CURDIR)/AUTHORS
DEB_INSTALL_DOCS_abiword := $(CURDIR)/user/wp/readme.txt $(CURDIR)/user/wp/readme.abw
DEB_DH_MAKESHLIBS_ARGS_libabiword-2.9 := -V "libabiword-2.9 (= $(DEB_VERSION))"

# --as-needed needs to be in front of all library flags. a small hack to
# achieve this
CC := gcc -Wl,--as-needed
CXX := g++ -Wl,--as-needed

# handle DEB_BUILD_OPTIONS
# noopt is handled by cdbs' langcore.mk
# nostrip is handled by dh_strip

ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
	MAKEFLAGS += -j$(NUMJOBS)
endif

binary-install/abiword::
	rm -f $(CURDIR)/debian/abiword/usr/lib/abiword-$(series)/plugins/grammar.*
	rm -f $(CURDIR)/debian/abiword/usr/lib/abiword-$(series)/plugins/mathview.*
	install -m 644 $(CURDIR)/debian/misc/abiword.xpm $(CURDIR)/debian/abiword/usr/share/pixmaps

