class Swig < Formula homepage "http://www.swig.org/" url "https://downloads.sourceforge.net/project/swig/swig/swig-3.0.3/swig-3.0.3.tar.gz" sha1 "e68e1fbdf92ae34c0949c9babef10c8800377b93" bottle do sha1 "ede5284bbc1b78187bb8fbbddfbc60e055dd73ef" => :yosemite sha1 "71e032fd9ee5f9aa96339e3c23d814e171215671" => :mavericks sha1 "de538a05a03ac2e7e8e5028eaf8f3242c77801d7" => :mountain_lion end option :universal depends_on "pcre" def install ENV.universal_binary if build.universal? system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}" system "make" system "make", "install" end test do (testpath/"test.c").write <<-EOS.undent int add(int x, int y) { return x + y; } EOS (testpath/"test.i").write <<-EOS.undent %module test %inline %{ extern int add(int x, int y); %} EOS (testpath/"run.rb").write <<-EOS.undent require "./test" puts Test.add(1, 1) EOS system "#{bin}/swig", "-ruby", "test.i" system ENV.cc, "-c", "test.c" system ENV.cc, "-c", "test_wrap.c", "-I/System/Library/Frameworks/Ruby.framework/Headers/" system ENV.cc, "-bundle", "-flat_namespace", "-undefined", "suppress", "test.o", "test_wrap.o", "-o", "test.bundle" assert_equal "2", shell_output("ruby run.rb").strip end end