PORTNAME=	libslang2
PORTVERSION=	2.3.3
PORTREVISION=	2
CATEGORIES=	devel
MASTER_SITES=	http://www.jedsoft.org/releases/slang/
DISTNAME=	slang-${PORTVERSION}

MAINTAINER=	garga@FreeBSD.org
COMMENT=	Routines for rapid alpha-numeric terminal applications development
WWW=		https://www.jedsoft.org/slang/

LICENSE=	GPLv2

USES=		ncurses tar:bzip2

USE_LDCONFIG=	yes
GNU_CONFIGURE=	yes
GNU_CONFIGURE_MANPREFIX=	${PREFIX}/share
CONFIGURE_ARGS+=	--with-pkgconfigdir=${PREFIX}/libdata/pkgconfig
MAKE_JOBS_UNSAFE=	yes
ALL_TARGET=	all static
INSTALL_TARGET=	install install-static

LDFLAGS+=		-lncurses

CONFLICTS=	libslang-1.*.j[0-9]

DATADIR=	${PREFIX}/share/slsh
DOCSDIR=	${PREFIX}/share/doc/slang

PLIST_SUB+=	SHLIB_VERSION=${PORTVERSION}
PORTDOCS=	*

OPTIONS_DEFINE=		DOCS ICONV ONIG PCRE PNG
OPTIONS_DEFAULT=	ICONV PCRE PNG
OPTIONS_SUB=		yes

ONIG_DESC=	Oniguruma support

ICONV_USES=		iconv
ONIG_LIB_DEPENDS=	libonig.so:devel/oniguruma
ONIG_CONFIGURE_WITH=	onig
PCRE_LIB_DEPENDS=	libpcre.so:devel/pcre
PCRE_CONFIGURE_WITH=	pcre
PNG_LIB_DEPENDS=	libpng.so:graphics/png
PNG_CONFIGURE_WITH=	png

.include <bsd.port.pre.mk>

.if !${PORT_OPTIONS:MICONV} || empty(ICONV_LIB)
CONFIGURE_ARGS+=	--without-iconv
.endif

post-patch:
	@${REINPLACE_CMD} -E 's,doc/slsh,doc/slang/v\@slang_major_version\@,' \
		${WRKSRC}/slsh/Makefile.in

post-install:
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
.for f in NEWS changes.txt
	${INSTALL_DATA} ${WRKSRC}/${f} ${STAGEDIR}${DOCSDIR}
.endfor
	(cd ${WRKSRC}/doc && ${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR})
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/slsh
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/libslang.so.${PORTVERSION}
	${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/slang/v2/modules/*.so

.include <bsd.port.post.mk>
