aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/pike.rb
blob: b6bc6e8745eee50c494e581b1d439c76068e9d57 (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
118
119
require 'formula'

class Pike < Formula
  homepage 'http://pike.lysator.liu.se'
  url 'http://pike.lysator.liu.se/pub/pike/all/7.8.866/Pike-v7.8.866.tar.gz'
  sha1 'f3d6cc21e302576c3ac4bb5a525705dbeee2d060'
  revision 1

  bottle do
    sha256 "e1c276b7fdf4ce90cb6f512d6c93f494a56432e878567d05a63f63657cbba7d6" => :yosemite
    sha256 "baad545207c59dbd86f57ed20155f4c0ef0aaa1f3b3291adc1eb304c4d66e987" => :mavericks
    sha256 "3240c7771fad0948975677e1553bf5cc4b48ec7541efe42ca838576f90a66113" => :mountain_lion
  end

  depends_on "nettle"
  depends_on "gmp"
  depends_on "pcre"
  depends_on :x11 => :optional
  depends_on 'libtiff' => :recommended

  # optional dependencies
  depends_on 'gettext'       if build.with? "gettext" or build.with? "all"
  depends_on 'gdbm'          if build.with? "gdbm"    or build.with? "all"
  depends_on 'gtk+'          if build.with? "gtk2"    or build.with? "all"
  depends_on 'mysql'         if build.with? "mysql"   or build.with? "all"
  depends_on 'sdl'           if build.with? "sdl"     or build.with? "all"
  depends_on 'sane-backends' if build.with? "sane"    or build.with? "all"
  depends_on 'pdflib-lite'   if build.with? "pdf"     or build.with? "all"
  depends_on 'mesalib-glw'   if build.with? "gl"      or build.with? "all"

  option 'with-gettext', 'Include Gettext support'
  option 'with-gdbm', 'Include Gdbm support'
  option 'with-gtk2', 'Include GTK2 support'
  option 'with-mysql', 'Include Mysql support'
  option 'with-pcre', 'Include Regexp.PCRE support'
  option 'with-sdl', 'Include SDL support'
  option 'with-sane', 'Include Sane support'
  option 'with-pdf', 'Include PDF support'
  option 'with-gl', 'Include GL support'
  option 'with-all', 'Include all features'
  option 'with-machine-code', 'Enables machine code'

  fails_with :llvm do
    build 2335
    cause "Fails to build multiset.c, results in a Abort trap being caught."
  end

  def install
    args = ["--prefix=#{prefix}", "--without-bundles"]

    if MacOS.prefer_64_bit? and not build.build_32_bit?
      ENV.append 'CFLAGS', '-m64'
      args << "--with-abi=64"
    else
      ENV.append 'CFLAGS', '-m32'
      args << "--with-abi=32"
    end

    if build.without? "machine-code"
      args << "--without-machine-code"
    end

    ENV.j1

    system "make", "CONFIGUREARGS='" + args.join(' ') + "'"

    # installation is complicated by some of brew's standard patterns.
    # hopefully these notes explain the reasons for diverging from
    # the path that most other formulae use.
    #
    # item 1
    #
    # basically, pike already installs itself naturally as brew would want
    # it; that is, if prefix=/Cellar, installation would create
    # /Cellar/pike/ver/bin and so forth. We could just go with that, but it's
    # possible that homebrew might change its layout and then the formula
    # would no longer work.
    #
    # so, rather than guessing at it, we do this alternate gyration, forcing
    # pike to install in a slightly nonstandard way (for pike, at least)
    #
    # item 2
    #
    # a second problem crops up because the during installation, the link
    # function tries to pull in stuff from lib/, which is really more like
    # what one would expect share or libexec in homebrew might be: pike
    # specific files, rather than shared libraries. we could approach this
    # in a similar fashion, but the result would be a really odd arrangement
    # for anyone remotely familar with standard pike installs.
    #
    # because there's no way to override the keg.link command, this formula
    # installs the whole pike install into prefix/libexec and then links the
    # man page and binary back into prefix/share and prefix/bin. not so
    # elegant, but that's the way brew works.
    system "make",  "install",
                    "prefix=#{libexec}",
                    "exec_prefix=#{libexec}",
                    "share_prefix=#{libexec}/share",
                    "lib_prefix=#{libexec}/lib",
                    "man_prefix=#{libexec}/man",
                    "include_path=#{libexec}/include",
                    "INSTALLARGS=--traditional"

    bin.install_symlink "#{libexec}/bin/pike"
    share.install_symlink "#{libexec}/share/man"
  end

  test do
    path = testpath/"test.pike"
    path.write <<-EOS.undent
      int main() {
        for (int i=0; i<10; i++) { write("%d", i); }
        return 0;
      }
    EOS

    assert_equal "0123456789", shell_output("#{bin}/pike #{path}").strip
  end
end