# New ports collection makefile for: pandoc
# Date created:                      9 February 2007
# Whom:                              John MacFarlane <jgm@berkeley.edu>
#
# $FreeBSD: ports/textproc/hs-pandoc/Makefile,v 1.18 2010/05/24 21:52:37 pgj Exp $
#

PORTNAME=	pandoc
PORTVERSION=	1.5.1.1
CATEGORIES=	textproc haskell

MAINTAINER=	haskell@FreeBSD.org

CABAL_SETUP=	Setup.hs
USE_HACKAGE=	utf8-string>=0.3 zip-archive>=0.1.1.4 xml>=1.3.5 texmath HTTP>=4000.0.5

PORTDATA=	*

OPTIONS=	HIGHLIGHTING "Compile in support for syntax highlighting" off \
		CITEPROC     "Compile in support for citeproc-hs" off

.if defined(APPLICATION)
COMMENT=		A general markup converter
BUILDING_EXECUTABLE=	1
WITH_EXECUTABLE=	yes
PKGNAMEPREFIX=
OPTIONS+=	WRAPPERS     "Build the wrappers (markdown2pdf)" on
.else
COMMENT=		Haskell library for pandoc
BUILDING_EXECUTABLE=	0
WITH_LIBRARY=		yes
NOPORTDATA=		yes
.endif

.include "${.CURDIR}/../../lang/ghc/bsd.cabal.options.mk"
.include <bsd.port.options.mk>


.if defined(WITH_HIGHLIGHTING)
CONFIGURE_ARGS+=	--flags="highlighting"
USE_HACKAGE+=		highlighting-kate
.else
CONFIGURE_ARGS+=	--flags="-highlighting"
.endif

.if defined(WITH_EXECUTABLE)
CONFIGURE_ARGS+=	--flags="exectuable"
EXECUTABLE+=		pandoc
MAN1=			pandoc.1 markdown2pdf.1
PLIST_SUB+=		MAYBE_EXECUTABLE=""
.else
CONFIGURE_ARGS+=	--flags="-executable"
PLIST_SUB+=		MAYBE_EXECUTABLE="@comment "
.endif

.if defined(WITH_WRAPPERS)
CONFIGURE_ARGS+=	--flags="wrappers"
EXECUTABLE+=		markdown2pdf
PLIST_SUB+=		MAYBE_WRAPPERS=""

.else
CONFIGURE_ARGS+=	--flags="-wrappers"
PLIST_SUB+=		MAYBE_WRAPPERS="@comment "
.endif

.if defined(WITH_LIBRARY)
CONFIGURE_ARGS+=	--flags="library"
PLIST_SUB+=		MAYBE_LIBRARY=""
.else
CONFIGURE_ARGS+=	--flags="-library"
PLIST_SUB+=		MAYBE_LIBRARY="@comment "
STANDALONE=		yes
.endif

.if defined(WITH_CITEPROC)
CONFIGURE_ARGS+=	--flags="citeproc"
USE_HACKAGE+=		citeproc-hs
PLIST_SUB+=		MAYBE_CITEPROC=""
.else
CONFIGURE_ARGS+=	--flags="-citeproc"
PLIST_SUB+=		MAYBE_CITEPROC="@comment "
.endif

post-patch:
	@${REINPLACE_CMD} 's|%%BUILDING_EXECUTABLE%%|${BUILDING_EXECUTABLE}|g' \
		${WRKSRC}/Setup.hs

.include "${.CURDIR}/../../lang/ghc/bsd.cabal.mk"
.include <bsd.port.mk>
