# Tanım: Microsoft Word benzeri basit bir kelime işlemci yazılımı.
# URL: http://www.abisource.com/
# Paketçi: milisarge
# Gerekler: boost cairo aspell fribidi enchant wv icu librsvg gtk2 redland rasqal desktop-file-utils gtk3 goffice
# Grup: ofis

isim=abiword
surum=3.0.2
devir=1
kaynak=(http://www.abisource.com/downloads/$isim/$surum/source/$isim-$surum.tar.gz
		abiword-3.0.0-librevenge.patch
		abiword-3.0.1-libwps-0.4.patch
        aiksaurus-plugin.m4
        command-plugin.m4
        python-override.patch
        bug13815.patch
        enchant-2.1.patch
        libical-deprecated.patch)

derle() {
	cd $isim-$surum
	 # fix build with librevenge based import filters
	patch -Np0 -i ../abiword-3.0.0-librevenge.patch

	# Fix libwpd 0.4 detection
	patch -Np1 -i ../abiword-3.0.1-libwps-0.4.patch

	# Fix python override code to work with Python 3.x
	patch -Np1 -i ../python-override.patch

	# Fix black on black (FS#51667)
	# http://bugzilla.abisource.com/show_bug.cgi?id=13815
	patch -Np1 -i ../bug13815.patch

	# Replace deprecated enchant functions
	patch -Np1 -i ../enchant-2.1.patch

	# Replace deprecated libical functions
	patch -Np1 -i ../libical-deprecated.patch

	# Install missing m4 file
	install -m644 ../aiksaurus-plugin.m4 plugins/aiksaurus/plugin.m4
	install -m644 ../command-plugin.m4 plugins/command/plugin.m4

	# Generate m4 file for configure
	find plugins -name plugin.m4 | xargs cat > plugin-configure.m4

	# enchant-2 naming change
	sed -i 's/enchant >=/enchant-2 >=/' configure.ac

	libtoolize --force
	autoreconf -fi
	export CXXFLAGS="-std=c++0x"
	./configure --prefix=/usr \
    --enable-shared \
    --disable-static \
    --enable-clipart \
    --enable-templates \
    --enable-plugins \
    --enable-introspection
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
	make
	make DESTDIR=$PKG install

	# Başlatıcı
	sed -i 's/^Exec=/Name[tr]=AbiWord \
	GenericName[tr]=Kelime İşlemci \
	Comment[tr]=Microsoft Word benzeri basit bir kelime işlemci yazılımı.\
	&/' $PKG/usr/share/applications/$isim.desktop
	
	cd src/gi-overrides
	sed -i 's/python -c/python2 -c/' Makefile
	make DESTDIR="$PKG" PYTHON=python2 install
}
