Info2: <<
Package: gnuplot%type_pkg[-wx]%type_pkg[-qt]

# 5.2.x series needs glib2 >= 2.28 to enable the PDF terminal NEWGLIB24
# Also, build failure with current Fink texinfo (didn't try texinfo-legacy)

Version: 5.0.7
Revision: 5
Distribution: 10.9
Type: v (5.0), -wx (-wxcocoa -wxgtk .), -qt (-qtmac -qtx11 .)
Maintainer: None <fink-devel@lists.sourceforge.net>
Homepage:  http://www.gnuplot.info/
License: Restrictive/Distributable

Conflicts: <<
	%{Ni}, 
	%{Ni}-nox, 
	%{Ni}-nogtk (<< 4.6.1-1),
	%{Ni}-wxcocoa,
	%{Ni}-wxcocoa-qtmac,
	%{Ni}-wxcocoa-qtx11,
	%{Ni}-wxgtk,
	%{Ni}-wxgtk-qtmac,
	%{Ni}-wxgtk-qtx11,
	%{Ni}-qtmac,
	%{Ni}-qtx11,
	%{Ni}-minimal
<<
Replaces: <<
	%{Ni},
	%{Ni}-nox,
	%{Ni}-nogtk (<< 4.6.1-1),
	%{Ni}-wxcocoa,
	%{Ni}-wxcocoa-qtmac,
	%{Ni}-wxcocoa-qtx11,
	%{Ni}-wxgtk,
	%{Ni}-wxgtk-qtmac,
	%{Ni}-wxgtk-qtx11,
	%{Ni}-qtmac,
	%{Ni}-qtx11,
	%{Ni}-minimal
<<
Provides: gnuplot-bin, gnuplot-cairo
Depends: <<
	app-defaults,
	aquaterm,
	(%type_raw[-wx] = -wxgtk) atk1-shlibs (>= 1.28.0-1),
	cairo-shlibs (>= 1.8.8-3),
	emacsen-common,
	gd3-shlibs,
	glib2-shlibs (>= 2.22.0-1),
	(%type_raw[-wx] = -wxgtk) gtk+2-shlibs (>= 2.18.0-1),
	libcerf1-shlibs,
	lua53-shlibs,
	pango1-xft2-ft219-shlibs (>= 1.24.5-4),
	pdflib6-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtcore-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtgui-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtnetwork-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtprintsupport-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtsvg-shlibs,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtwidgets-shlibs,
	(%type_raw[-wx] = -wxcocoa) wxwidgets300-osxcocoa-shlibs (>= 3.0.4-2),
	(%type_raw[-wx] = -wxgtk) wxwidgets300-gtk2-shlibs (>= 3.0.4-2),
	x11-shlibs
<<
BuildDepends: <<
	aquaterm-dev,
	cairo (>= 1.8.8-3),
	fink (>= 0.32),
	fink-package-precedence,
	(%type_raw[-wx] = -wxgtk) fontconfig2-dev,
	(%type_raw[-wx] = -wxgtk) freetype219,
	gd3,
	glib2-dev (>= 2.22.0-1),
	libcerf1,
	libiconv-dev,
	lua53,
	lua53-dev,
	pango1-xft2-ft219-dev (>= 1.24.5-4),
	pdflib6,
	pkgconfig (>= 0.23-1),
	(%type_raw[-wx] = -wxgtk) atk1 (>= 1.28.0-1),
	(%type_raw[-wx] = -wxgtk) gtk+2-dev (>= 2.18.0-1),
	(%type_raw[-wx] = -wxcocoa ) wxwidgets300-osxcocoa (>= 3.0.4-2),
	(%type_raw[-wx] = -wxgtk) wxwidgets300-gtk2 (>= 3.0.4-2),
	(%type_raw[-qt] = -qtmac) qt5-mac-qtbase,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtbase-dev-tools,
	(%type_raw[-qt] = -qtmac) qt5-mac-linguist,
	(%type_raw[-qt] = -qtmac) qt5-mac-qtsvg,
	(%type_raw[-qt] = -qtx11) qt4-base-x11,
	x11-dev
<<
RuntimeDepends: <<
	x11
<<

Source: mirror:sourceforge:%{Ni}/%{Ni}-%v.tar.gz
Source-Checksum: SHA256(0ad760ff013b4a9cf29853fa9b50c50030a33cd8fb86220a23abb466655136fc)
Source2: http://deb.debian.org/debian/pool/main/g/gnuplot-mode/gnuplot-mode_0.7.0.orig.tar.gz
Source2-Checksum: SHA256(310018d8c313ebd817e3e6116ab28eb2b848fa0992917b5ee4148d6073f59f3e)

PatchFile: %{Ni}.patch
PatchFile-MD5: 6066b6bae25263e93f4d56db3d3ee28f
#PatchFile2: %{Ni}-fix-docs-emacs26.patch
#PatchFile2-MD5: 2cec5003d6836e69205f5a974e5f95de
PatchScript: <<
sed 's|@PREFIX@|%p|g' < %{PatchFile} | patch -p1
#patch -p1 < %{PatchFile2}
# Upstream is building this .so file simultaneously as a program and a dylib
perl -pi -e 's/shared/bundle/' demo/plugin/Makefile.{in,am}
<<

GCC: 4.0
SetLDFLAGS: -Wl,-dead_strip_dylibs -F%p/Library/Frameworks
SetCPPFLAGS: -F%p/Library/Frameworks

ConfigureParams: <<
 --mandir='${prefix}/share/man' --libexecdir='${prefix}/lib' --infodir='${prefix}/share/info' \
 --without-tutorial --with-readline=builtin \
 --with-texdir=%p/etc/texmf.local/latex/%{Ni} \
 --without-kpsexpand \
 --enable-history-file \
 --x-includes=/opt/X11/include \
 --x-libraries=/opt/X11/lib \
 --with-aquaterm \
 (%type_raw[-wx] = .) --disable-wxwidgets \
 (%type_raw[-qt] = .) --without-qt \
 (%type_raw[-qt] = -qtmac) --with-qt=qt5 \
 (%type_raw[-qt] = -qtx11) --with-qt=qt4 \
 --with-pdf=%p/lib \
 --with-x-app-defaultdir=%p/etc/app-defaults \
 --enable-dependency-tracking
<<
CompileScript: <<
 #!/bin/sh -ev
 export DIST_CONTACT="alexkhansen@users.sourceforge.net"
 export CCACHE_DISABLE=1
 export CPATH=%p/include
 export EMACS=/usr/bin/emacs
 export PKG_CONFIG_PATH=%p/lib/glib-2.0/pkgconfig-strict:$PKG_CONFIG_PATH
 if [ "%type_raw[-qt]" = "-qtmac" ] ; then
    export PKG_CONFIG_PATH=%p/lib/qt5-mac/lib/pkgconfig:$PKG_CONFIG_PATH
    export QT_PATH=%p/lib/qt5-mac
 	export QT_LIBS="-F$QT_PATH/lib -framework QtCore -framework QtGui -framework QtWidgets -framework QtNetwork -framework QtSvg -framework QtPrintSupport"
	export QT_CFLAGS="-F$QT_PATH/lib -I$QT_PATH/lib/QtCore.framework/Headers -I$QT_PATH/lib/QtGui.framework/Headers -I$QT_PATH/lib/QtWidgets.framework/Headers -I$QT_PATH/lib/QtNetwork.framework/Headers -I$QT_PATH/lib/QtSvg.framework/Headers"  
    export CXXFLAGS="$CXXFLAGS -std=c++11"
 elif [ "%type_raw[-qt]" = "-qtx11" ] ; then 
    export PKG_CONFIG_PATH=%p/lib/qt4-x11/lib/pkgconfig:$PKG_CONFIG_PATH
 fi
 if [ "%type_raw[-wx]" = "-wxgtk" ] ; then
    export LIBS=/opt/X11/lib/libX11.dylib
 fi
 %{default_script}
 fink-package-precedence .
<<
InstallScript: <<
 #!/bin/sh -ev
 make install DESTDIR=%d
 make install-info DESTDIR=%d
 
 # Create executable wrapper
 mv %i/bin/%{Ni} %i/bin/%{Ni}x
 echo '#!/bin/sh' > %i/bin/%{Ni}
 echo 'export AQUATERM_PATH=%p/Applications/AquaTerm.app' >> %i/bin/%{Ni}
 echo 'case ${DISPLAY-0} in' >> %i/bin/%{Ni}
 echo ' 0) export GNUTERM=aqua ;;'  >> %i/bin/%{Ni}
 echo 'esac'  >> %i/bin/%{Ni}
 echo '%p/bin/%{Ni}x "$@"' >> %i/bin/%{Ni}
 chmod 755 %i/bin/%{Ni}
 
 # set up docs and demo
 mkdir -p %i/share/doc/%n
 cp -R demo %i/share/doc/%n
 mkdir %i/share/doc/%n/psdoc
 cp docs/psdoc/*ps %i/share/doc/%n/psdoc

 #emacs
 mkdir -p %i/share/emacs/site-lisp/%{Ni}-mode
 cp docs/*el %i/share/emacs/site-lisp/%{Ni}-mode
 cp ../gnuplot-mode-0.7.0/{gnuplot-context,gnuplot-gui,gnuplot}.el %i/share/emacs/site-lisp/gnuplot-mode
 install -m 755 -d                        %i/etc/emacs/site-start.d
 install -m 644 fink/gnuplot-mode-startup %i/etc/emacs/site-start.d/50%{Ni}.el
 install -m 755 -d                        %i/lib/emacsen-common/packages/{install,remove}
 install -m 755 fink/gnuplot-mode-install %i/lib/emacsen-common/packages/install/%{Ni}
 install -m 755 fink/gnuplot-mode-remove  %i/lib/emacsen-common/packages/remove/%{Ni}

 #app-defaults
 install -d %i/etc
 install -d %i/etc/app-defaults
 cp %i/share/%{Ni}/%type_raw[v]/app-defaults/Gnuplot %i/etc/app-defaults
 
 #TeX
 install -d %i/etc/texmf.local
 install -d %i/etc/texmf.local/latex
 install -d %i/etc/texmf.local/latex/%{Ni}
 install %b/share/LaTeX/%{Ni}.cfg %i/etc/texmf.local/latex/%{Ni}
 rm -rf %i/share/texmf-local
<<
ConfFiles: %p/etc/emacs/site-start.d/50%{Ni}.el %p/etc/app-defaults/Gnuplot
RuntimeVars: <<
 GDFONTPATH: /Library/Fonts
 GNUPLOT_DEFAULT_GDFONT: "Arial"
<<
PostInstScript:<<
 if [ `which kpsexpand` ]; then kpsexpand %p/etc/texmf.local/latex/%{Ni}; fi
 if [ `which texhash` ]; then texhash %p/etc/texmf.local/latex/%{Ni}; fi
 if [ "$1" = "configure" ] && [ -x %p/lib/emacsen-common/emacs-package-install ]
 then
         %p/lib/emacsen-common/emacs-package-install %{Ni}
 fi
<<
PreRmScript:<<
 if [ `which kpsexpand` ]; then kpsexpand %p/etc/texmf.local/latex/%{Ni}; fi
 if [ `which texhash` ]; then texhash %p/etc/texmf.local/latex/%{Ni}; fi
 if [ -x %p/lib/emacsen-common/emacs-package-remove ] ; then
         %p/lib/emacsen-common/emacs-package-remove %{Ni}
 fi
<<

DocFiles: BUGS FAQ.pdf README NEWS ChangeLog Copyright
InfoDocs: %{Ni}.info

Description: Command-driven interactive plotting program
DescDetail: <<
Gnuplot is a portable command-line driven interactive data and function 
plotting utility for UNIX, IBM OS/2, MS Windows, DOS, Macintosh, VMS, Atari 
and many other platforms. The software is copyrighted but freely distributed
(i.e., you don't have to pay for it). It was originally intended as to allow
scientists and students to visualize mathematical functions and data. It 
does this job pretty well, but has grown to support many non-interactive 
uses, including web scripting and integration as a plotting engine for third-
party applications like Octave. Gnuplot has been supported and under 
development since 1986.
Gnuplot supports many types of plots in either 2D and 3D. It can draw using 
lines, points, boxes, contours, vector fields, surfaces, and various 
associated text. It also supports various specialized plot types.
Gnuplot supports many different types of output: interactive screen terminals
(with mouse and hotkey functionality), direct output to pen plotters or modern
printers, and output to many file formats (eps, fig, jpeg, LaTeX, metafont, 
pbm, pdf, png, postscript, svg, ...). Gnuplot is easily extensible to include
new output modes. 
<<
DescUsage: <<
The base 'gnuplot' package has many of the available terminal options 
included, but doesn't build the wx terminal as of version 4.6.0-3.  
It is essentially the same as the 'gnuplot-nogtk' package, version 4.6.0-2
and earlier.

If you want the wx terminal, install 'gnuplot-wxcocoa*' for an Aqua-based wxt
or 'gnuplot-wxgtk*' for one that is GTK-based (X11).

If you want the Qt terminal, install 'gnuplot*-qtx11' for an Qt4-based X11 
terminal, 'gnuplot*-qtmac' for an for Qt5-based Aqua terminal.  

Upstream's default font choice doesn't work on case-sensitive filesystems, 
so we set the GDFONTDIR environment variable to /Library/Fonts, and the
GNUPLOT_DEFAULT_GDFONT environment variable to be "Arial".  If you want 
a different setup, you can set these yourself in your startup files, or in
your invocation of gnuplot, e.g.

env GNUPLOT_DEFAULT_GDFONT="Verdana" gnuplot
<<
DescPackaging: <<
'gnuplot' is a shell script that sets Fink's environment variables and 
invokes the real gnuplot binary (renamed to gnuplotx).

Set DIST_CONTACT to mark Fink maintainer as contact person as per the license.
(that plus our revision tag suffices)

Install the configuration for epslatex terminal manually in the
PostInstScript because the upstream build system will run
kpsexpand and texhash if those are present and thereby create .debs 
that are different depending on whether or not a TeX distro is installed,
and we don't want to force a dependency.

PDF documentation has been moved to a separate package to avoid having to
BuildDepend on tetex or texlive.

Remove %i/share/texmf-local to avoid interfering with texlive or tetex.

Rather than use the "arial" font by default as upstream would 
have us do (from msttcorefonts), set environment variables to use 
"Arial" from /Library/Fonts.

Use the builtin "readline" because gnuplot's license isn't GPL2 compatible,
and we can't distribute it if it links to a GNU readline.
If there are any license issues those are upstream's fault!

There appears to be an inherited Bdep on Fink's libiconv.

Special thanks to Nunzio Losacco for the tweaks to allow building
against Fink's Qt4/5. This now requires -std=c++11 in the CXXFLAGS
for the -qtmac variants per
https://github.com/fink/fink-distributions/issues/154

Plugin build appears to be confused as to whether it's a program or a
shared lib, so make it a bundle.

Former Maintainer:  Alexander Hansen <alexkhansen@users.sourceforge.net>
Older versions included gnuplot.el (emacs mode), but newer versions
have dropped it and other distros have a stand-alone package for
it. To maintain functionality and avoid circular dependencies, we
include Debian's gnuplot-mode package here within gnuplot itself.
See: https://github.com/fink/fink-distributions/issues/523
<<
DescPort: <<
We have to provide X11.dylib explicitly for the wx terminal to build
against wxwidgets300-gtk2.

Remove the VMS/vws terminal because it causes FTBFS when building the
docs with emacs26-nox. See
https://github.com/fink/fink-distributions/issues/619
Upstream commit (from much later is f5688a08c9781ea76917a42ef48f34d553377124)
10.9-10.14.5 use /usr/bin/emacs instead of patching.
<<
<<