SUMMARY="Command-line driven graphing utility"
DESCRIPTION="Originally created to allow both students and scientists to \
visualize mathematical functions and data interactively, but has grown to \
support many non-interactive uses such as web scripting. It is also used \
as a plotting engine by third-party applications like Octave."
HOMEPAGE="http://www.gnuplot.info/"
COPYRIGHT="1986-1993, 1998, 2004-2018 Thomas Williams, Colin Kelley"
LICENSE="Gnuplot"
REVISION="6"
SOURCE_URI="https://downloads.sourceforge.net/gnuplot/gnuplot-$portVersion.tar.gz"
CHECKSUM_SHA256="039db2cce62ddcfd31a6696fe576f4224b3bc3f919e66191dfe2cdb058475caa"

ARCHITECTURES="all !x86_gcc2 ?x86"
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
fi

commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandBinDir=$prefix/bin
fi

PROVIDES="
	gnuplot$secondaryArchSuffix = $portVersion
	cmd:gnuplot = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libfontconfig$secondaryArchSuffix
	lib:libfreetype$secondaryArchSuffix
	lib:libgd$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libjpeg$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libpng16$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libtiff$secondaryArchSuffix
	lib:libvpx$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libcairo$secondaryArchSuffix
#	devel:libcerf$secondaryArchSuffix
	devel:libgd$secondaryArchSuffix
	devel:libjpeg$secondaryArchSuffix
#	devel:libpango_1.0$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix >= 8
	devel:libvpx$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:automake
	cmd:autoconf
	cmd:awk
	cmd:cmp
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

PATCH()
{
	sed -i 's/-rdynamic/-Wl,-export-dynamic/g' demo/plugin/Makefile.am
	sed -i 's/isnan/std::isnan/g' src/qtterminal/qt_conversion.cpp
}

BUILD()
{
	aclocal
	automake
	runConfigure --omit-dirs binDir ./configure --bindir="$commandBinDir" \
		--without-cairo \

	make $jobArgs
}

INSTALL()
{
	make install-strip
}

TEST()
{
	make check
}
