PortSystem 1.0
name		abiword
version		2.4.5
revision    1
description	A word processor with gnome support.
long_description        A word processor with gnome support.
license         GPL-3
maintainers	nomaintainer
categories	editors textproc aqua
platforms	darwin 
homepage	http://www.abisource.com/
master_sites    http://www.abisource.org/downloads/abiword/${version}/source \
		http://www.nl.abisource.org/downloads/abiword/${version}/source
checksums	md5 e018669a154164d31c768f773a1c95b4 \
		sha1 bca02a8beb490246f785518fc82c6c557a77a88d \
		rmd160 f0de27f97135f8fff9b4400b05d74a27eee348cd
distname	abiword-${version}
use_bzip2	yes

if {![variant_isset use_source]} {
    default_variants	+use_binary
}

pre-fetch {
	if {! [variant_isset use_binary] && ! [variant_isset use_source]} {
		return -code 1 "Please select either use_binary or use_source variant"
	}
}

variant use_binary conflicts use_source {
	distname AbiWord-${version}-10.2
	extract.suffix .dmg.gz
	master_sites    http://www.abisource.org/downloads/abiword/${version}/MacOSX \
			http://www.nl.abisource.org/downloads/abiword/${version}/MacOSX \
			http://os.cqu.edu.au/macosx/office/abiword
	checksums	md5 13d249d7f0181a5c44e7342b302b19ae
	use_bzip2	no
	extract.post_args > ${workpath}/${distname}.dmg
	post-extract {
		file mkdir /tmp/${name}-${version}
		system "hdiutil attach ${workpath}/${distname}.dmg -private -nobrowse -mountpoint /tmp/${name}-${version}"
	}
	patchfiles
	use_configure	no
	build {}
	destroot {
		file mkdir ${destroot}${applications_dir}
		file copy /tmp/${name}-${version}/AbiWord.app ${destroot}${applications_dir}
	}
	post-destroot {
		system "hdiutil detach /tmp/${name}-${version}"
		file delete -force /tmp/${name}-${version}
	}
}

variant use_source {
	depends_build	\
		port:pkgconfig

	depends_lib	\
		port:zlib \
		port:libpng \
		port:fribidi \
		port:fontconfig \
		port:ImageMagick

	patchfiles	\
		configure.patch \
		abi-detect-platform.m4.patch \
		patch-wv-magick-png.c.diff

	configure.dir	${worksrcpath}/abi

	build.dir	${configure.dir}
	build.target

	configure.cppflags -I. -I${prefix}/include

	configure.args	\
		--enable-Cocoa \
		--mandir=${prefix}/share/man \
		--with-zlib=${prefix} \
		--with-libpng=${prefix} \
		--with-popt=${prefix} \
		--without-epath \
		--disable-gnome
}
