1PORTNAME=	gnuplot
2PORTVERSION=	5.4.1
3PORTREVISION=	3
4CATEGORIES=	math graphics
5MASTER_SITES=	SF
6
7MAINTAINER=	ports@MidnightBSD.org
8COMMENT?=	Command-line driven graphing utility
9WWW=		http://www.gnuplot.info/
10
11LICENSE=	Gnuplot
12LICENSE_NAME=	Gnuplot license
13LICENSE_FILE=	${WRKSRC}/Copyright
14LICENSE_PERMS=	dist-mirror pkg-mirror auto-accept
15
16CONFLICTS_INSTALL?=	gnuplot-lite
17
18USES+=		compiler:c++11-lang cpe groff iconv pkgconfig readline
19CPE_VENDOR=	gnuplot_project
20GNU_CONFIGURE=	yes
21LDFLAGS+=	-L${LOCALBASE}/lib ${ICONV_LIB}
22CONFIGURE_ARGS+=--with-readline=gnu \
23		--without-linux-vga \
24		--without-lisp-files \
25		--without-tutorial \
26		--with-bitmap-terminals \
27		--with-qt=no
28
29.if defined(LITE)
30CONFIGURE_ARGS+=--disable-x11-mbfonts \
31		--disable-x11-external \
32		--disable-wxwidgets \
33		--without-x \
34		--without-ggi \
35		--without-gd \
36		--without-caca \
37		--without-wx \
38		--without-gpic \
39		--without-mif \
40		--without-cairo \
41		--without-lua \
42		--without-latex \
43		--without-kpsexpand
44PLIST_SUB+=	X11="@comment "
45.else
46USES+=		gnome jpeg lua:53 ncurses tex xorg
47USE_TEX=	kpathsea
48USE_GNOME+=	atk cairo gtk30 gdkpixbuf
49USE_WX=		3.0+
50USE_XORG+=	x11
51LIB_DEPENDS+=	libfontconfig.so:x11-fonts/fontconfig \
52		libfreetype.so:print/freetype2 \
53		libharfbuzz.so:print/harfbuzz \
54		libgd.so:graphics/gd \
55		libpng.so:graphics/png \
56		libwebp.so:graphics/webp \
57		libtiff.so:graphics/tiff
58CONFIGURE_ARGS+=--with-gd=${LOCALBASE} \
59		--with-gpic \
60		--with-mif \
61		--with-kpsexpand \
62		--with-latex \
63		ac_cv_prog_KPSEXPAND=${LOCALBASE}/bin/kpsexpand \
64		ac_cv_prog_PLAINTEX=${LOCALBASE}/bin/tex \
65		ac_cv_prog_LATEX=${LOCALBASE}/bin/latex \
66		ac_cv_prog_PDFLATEX=${LOCALBASE}/bin/pdflatex
67PLIST_SUB+=	X11=""
68.endif
69
70NO_TEST=	yes
71PORTDOCS=	*
72PORTEXAMPLES=	*
73
74OPTIONS_DEFINE=	DOCS EXAMPLES GRIDBOX
75GRIDBOX_DESC=		Use the gridbox optimization for hidden3d
76
77GRIDBOX_CONFIGURE_OFF=	--disable-h3d-quadtree --enable-h3d-gridbox
78
79post-patch:
80	@${REINPLACE_CMD} -e \
81		'/^install:/s/install-am//' ${WRKSRC}/share/LaTeX/Makefile.in
82	@${REINPLACE_CMD} -e \
83		's|)/@PACKAGE@/@PKG_MAJOR@|)|g' ${WRKSRC}/src/Makefile.in
84	@${REINPLACE_CMD} -e \
85		's|luaL_checkint(|(int)luaL_checkinteger(|' ${WRKSRC}/term/lua.trm
86
87post-build-DOCS-on:
88	@cd ${WRKSRC}/docs && ${MAKE} groff
89
90pre-install:
91	${MKDIR} ${DATADIR}/5.4 ; \
92		${INSTALL_DATA} ${WRKSRC}/share/gnuplotrc \
93		${DATADIR}/5.4/gnuplotrc.sample
94
95post-install:
96	@${MKDIR} ${FAKE_DESTDIR}${EXAMPLESDIR}
97	cd ${WRKSRC}/demo && ${COPYTREE_SHARE} . ${FAKE_DESTDIR}${EXAMPLESDIR}
98
99post-install-DOCS-on:
100	@${MKDIR} ${FAKE_DESTDIR}${DOCSDIR}/psdoc
101	cd ${WRKSRC}/docs && ${INSTALL_DATA} gnuplot.txt gnuplot.dvi \
102		gnuplot.ps ${FAKE_DESTDIR}${DOCSDIR}
103	cd ${WRKSRC}/docs/psdoc && ${INSTALL_DATA} README ps_* ${FAKE_DESTDIR}${DOCSDIR}/psdoc
104
105.if defined(LITE)
106post-fake:
107	@cd ${FAKE_DESTDIR}${PREFIX} && ${RMDIR} libexec/gnuplot/5.4 libexec/gnuplot
108.endif
109
110.include <bsd.port.mk>
111