# Template file for 'pandoc'
pkgname=pandoc
version=1.14.0.4
_citeproc_version=0.7.1.1
revision=2
nocross=yes
hostmakedepends="cabal-install"
makedepends="zlib-devel"
short_desc="Universal converter between markup formats (with citeproc support)"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="GPL-2"
homepage="http://johnmacfarlane.net/pandoc/"
distfiles="http://hackage.haskell.org/package/${pkgname}-${version}/${pkgname}-${version}.tar.gz"
checksum=01955bfb1f397ec22bbce10e2df7b4f2214b7289bf79bf51eb7ae0e3b427fadf

do_build() {
	cabal sandbox init
	export PATH="$PWD/.cabal-sandbox/bin:$PATH"
	cabal update
	cabal install ${makejobs} --user hsb2hs
	cabal install ${makejobs} --user --only-dependencies
	cabal configure -v --prefix=/usr --libsubdir='$pkg' \
		--datasubdir='$pkg' --docdir='$datadir/doc/$pkg' \
		--flags="embed_data_files"
	cabal build ${makejobs}
	cabal install ${makejobs} --user pandoc-citeproc-${_citeproc_version} \
		--flags="embed_data_files"
}

do_install() {
	cabal copy --destdir="$DESTDIR/"
	vlicense "$DESTDIR/usr/share/pandoc/COPYRIGHT" LICENSE.pandoc
	for f in .cabal-sandbox/share/doc/*/pandoc-citeproc-*/LICENSE; do
		vlicense $f LICENSE.pandoc-citeproc
	done
	rm -r "$DESTDIR/usr/lib" "$DESTDIR/usr/share/doc/pandoc/COPYING" \
		"$DESTDIR/usr/share/pandoc/COPYRIGHT"
	vbin .cabal-sandbox/bin/pandoc-citeproc
	vman .cabal-sandbox/share/man/man1/pandoc-citeproc.1
	vman man/man1/pandoc.1
	vman man/man5/pandoc_markdown.5
}
