aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/r3.rb
blob: f9540aaecaec751d7abab3447c0c8a170f5bfd20 (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
require "formula"

class R3 < Formula
  homepage "https://github.com/c9s/r3"
  url "https://github.com/c9s/r3/archive/1.3.3.tar.gz"
  sha1 "2626e78e5d5afb64561b6c468e357db14597aef6"

  bottle do
    cellar :any
    sha1 "bf1eec1e94c0ef4f7862621277bda3d9456cf70f" => :mavericks
    sha1 "690d863995532a33917a867bbc616887c542ba57" => :mountain_lion
    sha1 "5d9e530068824ce31352258bbd826dfbb520e40a" => :lion
  end

  option :universal
  option "with-graphviz", "Enable Graphviz functions"

  head "https://github.com/c9s/r3.git"

  depends_on "autoconf" => :build
  depends_on "automake" => :build
  depends_on "libtool" => :build
  depends_on "pkg-config" => :build
  depends_on "pcre"
  depends_on "graphviz" => :optional
  depends_on "jemalloc" => :recommended

  def install
    ENV.universal_binary if build.universal?

    system "./autogen.sh"

    args = %W{
      --disable-debug
      --disable-dependency-tracking
      --disable-silent-rules
      --prefix=#{prefix}
    }

    args << "--enable-graphviz" if build.with? "graphviz"
    args << "--with-malloc=jemalloc" if build.with? "jemalloc"

    system "./configure", *args
    system "make install"
  end

  test do
    (testpath/"test.cpp").write <<-EOS.undent
      #include "r3.h"
      int main() {
          node * n = r3_tree_create(1);
          r3_tree_free(n);
          return 0;
      }
    EOS
    system ENV.cc, "test.cpp", "-o", "test",
                  "-lr3", "-I#{include}/r3"
    system "./test"
  end
end