aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/gnuplot.rb
blob: 076d19f8e40426605c0508d43b1c8a58268deb8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
require 'formula'

class LuaRequirement < Requirement
  fatal true
  default_formula 'lua'

  satisfy { which 'lua' }
end

class Gnuplot < Formula
  homepage 'http://www.gnuplot.info'
  url 'http://downloads.sourceforge.net/project/gnuplot/gnuplot/4.6.3/gnuplot-4.6.3.tar.gz'
  sha256 'df5ffafa25fb32b3ecc0206a520f6bca8680e6dcc961efd30df34c0a1b7ea7f5'

  head do
    url 'cvs://:pserver:anonymous:@gnuplot.cvs.sourceforge.net:/cvsroot/gnuplot:gnuplot'

    depends_on :autoconf
    depends_on :automake
    depends_on :libtool
  end

  option 'pdf',    'Build the PDF terminal using pdflib-lite'
  option 'wx',     'Build the wxWidgets terminal using pango'
  option 'with-x', 'Build the X11 terminal'
  option 'qt',     'Build the Qt4 terminal'
  option 'cairo',  'Build the Cairo based terminals'
  option 'nolua',  'Build without the lua/TikZ terminal'
  option 'nogd',   'Build without gd support'
  option 'tests',  'Verify the build with make check (1 min)'
  option 'without-emacs', 'Do not build Emacs lisp files'
  option 'latex',  'Build with LaTeX support'
  option 'without-aquaterm', 'Do not build AquaTerm support'

  depends_on 'pkg-config' => :build
  depends_on LuaRequirement unless build.include? 'nolua'
  depends_on 'readline'
  depends_on 'pango'       if build.include? 'cairo' or build.include? 'wx'
  depends_on :x11          if build.include? 'with-x' or MacOS::X11.installed?
  depends_on 'pdflib-lite' if build.include? 'pdf'
  depends_on 'gd'          unless build.include? 'nogd'
  depends_on 'wxmac'       if build.include? 'wx'
  depends_on 'qt'          if build.include? 'qt'
  depends_on :tex          if build.include? 'latex'

  def install
    if build.with? "aquaterm"
      # Add "/Library/Frameworks" to the default framework search path, so that an
      # installed AquaTerm framework can be found. Brew does not add this path
      # when building against an SDK (Nov 2013).
      ENV.prepend "CPPFLAGS", "-F/Library/Frameworks"
      ENV.prepend "LDFLAGS", "-F/Library/Frameworks"

      unless build.head?
        # Fix up Gnuplot v4.6.x to accommodate framework style linking. This is
        # required with a standard install of AquaTerm 1.1.1 and is supported under
        # earlier versions of AquaTerm. Refer:
        # https://github.com/AquaTerm/AquaTerm/blob/v1.1.1/aquaterm/ReleaseNotes#L1-11
        # https://github.com/AquaTerm/AquaTerm/blob/v1.1.1/aquaterm/INSTALL#L7-15
        inreplace "configure", "-laquaterm", "-framework AquaTerm"
        inreplace "term/aquaterm.trm", "<aquaterm/AQTAdapter.h>", "<AquaTerm/AQTAdapter.h>"
      end
    elsif !build.head?
      inreplace "configure", "-laquaterm", ""
    end

    # Help configure find libraries
    readline = Formula.factory 'readline'
    pdflib = Formula.factory 'pdflib-lite'
    gd = Formula.factory 'gd'

    args = %W[
      --disable-dependency-tracking
      --prefix=#{prefix}
      --with-readline=#{readline.opt_prefix}
    ]

    args << "--with-pdf=#{pdflib.opt_prefix}" if build.include? 'pdf'
    args << '--with' + ((build.include? 'nogd') ? 'out-gd' : "-gd=#{gd.opt_prefix}")
    args << '--disable-wxwidgets' unless build.include? 'wx'
    args << '--without-cairo'     unless build.include? 'cairo'
    args << '--enable-qt'             if build.include? 'qt'
    args << '--without-lua'           if build.include? 'nolua'
    args << '--without-lisp-files'    if build.include? 'without-emacs'
    args << (build.with?('aquaterm') ? '--with-aquaterm' : '--without-aquaterm')

    if build.include? 'latex'
      args << '--with-latex'
      args << '--with-tutorial'
    else
      args << '--without-latex'
      args << '--without-tutorial'
    end

    system './prepare' if build.head?
    system "./configure", *args
    ENV.j1 # or else emacs tries to edit the same file with two threads
    system 'make'
    system 'make check' if build.include? 'tests' # Awesome testsuite
    system "make install"
  end

  def test
    system "#{bin}/gnuplot", "--version"
  end

  def caveats
    if build.with? "aquaterm"
      <<-EOS.undent
        AquaTerm support will only be built into Gnuplot if the standard AquaTerm
        package from SourceForge has already been installed onto your system.
        If you subsequently remove AquaTerm, you will need to uninstall and then
        reinstall Gnuplot.
      EOS
    end
  end
end