# $Id: Portfile,v 1.17 2006/04/30 05:51:36 pguyot Exp $
PortSystem 1.0

name			gnuplot
version			4.0.0
revision		2
categories		math science
maintainers		darwinports@opendarwin.org
description		A command-driven interactive function plotting program
long_description	Gnuplot is a command-driven interactive function \
					plotting program. Plots any number of functions, \
					built up of C operators, C library functions, and \
					some things C doesn't have like **, sgn(), etc. \
					Also support for plotting data files, to compare \
					actual data to theoretical curves.
platforms		darwin
homepage		http://gnuplot.sourceforge.net/
master_sites	ftp://ftp.gnuplot.info/pub/gnuplot/ sourceforge
patch_sites		http://www.bmsc.washington.edu/people/merritt/gnuplot/
distfiles		${distname}.tar.gz \
				${name}.pdf.gz gpcard.pdf
extract.only	${distname}.tar.gz
checksums		${distname}.tar.gz md5 66258443d9f93cc4f46b147dac33e63a \
				${name}.pdf.gz md5 51c6d737bf76c18db844c96bc27e22c6 \
				gpcard.pdf md5 3042331d0801c31bf423428d9be66924 \
				datastrings_4.0.patch md5 7d2c4015f15f96e3a0f8063c2199ab6f \
				datastrings_4.0.patch sha1 2120db8d3c3ca9f084b46a573e944e06556c855a \
				datastrings_4.0.patch rmd160 600f404d6a46bab736db44b1f99d93443896b0c3 \
				histograms_4.0.patch md5 ba87f28e4aed68637e7b5160e7151919 \
				histograms_4.0.patch sha1 f75be94691af021e9d5eeeaaf707a09eb1d19ae6 \
				histograms_4.0.patch rmd160 ae51ca48deda330953fdb521835601b9e68c544a

depends_lib		lib:libgd.2:gd2 \
				lib:libjpeg.62:jpeg \
				lib:libpdf.5:pdflib \
				lib:libpng12.0:libpng \
				lib:libreadline.5:readline \
				lib:libX11.6:XFree86 \
				lib:libz.1:zlib

patchfiles		patch-term-pdf.trm \
				patch-term-tkcanvas.trm \
				datastrings_4.0.patch  \
				histograms_4.0.patch
patch.pre_args	-p1

# Patches require to run autoconf.
use_autoconf	yes

platform darwin 8 {
	patchfiles-append	patch-src-gplt_x11.c
}

platform darwin {
	depends_lib-append	lib:libaquaterm.1:aquaterm
}

configure.env	LDFLAGS="-L${prefix}/lib" \
				CPPFLAGS="-I${prefix}/include -no-cpp-precomp"
configure.args	--with-readline=gnu --with-gd --with-png --with-pdf --with-x \
				--enable-datastrings --enable-histograms \
				--infodir='\${prefix}/share/info' \
				--mandir='\${prefix}/share/man'

variant no_x11 {
	depends_lib-delete		lib:libX11.6:XFree86
	configure.args-delete	--with-x
	configure.args-append	--without-x
}

destroot.destdir	prefix=${destroot}${prefix}
post-destroot {
	xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
	system "gunzip -v -c ${distpath}/gnuplot.pdf.gz \
		>${destroot}${prefix}/share/doc/${name}/gnuplot.pdf"
	xinstall -m 0644 ${distpath}/gpcard.pdf \
		${destroot}${prefix}/share/doc/${name}
}

