homebrew-core/Formula/gmp.rb
2017-10-18 00:16:00 -07:00

50 lines
1.5 KiB
Ruby

class Gmp < Formula
desc "GNU multiple precision arithmetic library"
homepage "https://gmplib.org/"
url "https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz"
mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
sha256 "87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912"
revision 1
bottle do
cellar :any
sha256 "eadb377c507f5d04e8d47861fa76471be6c09dc54991540e125ee1cbc04fecd6" => :high_sierra
sha256 "90715336080bd2deb92bd74361f50d91fe288d18e4c18a70a8253add6aa13200" => :sierra
sha256 "0e0c340b4c09a4f00daf45890e8f36afa03d251a8ed3bba6ae4876149914b420" => :el_capitan
end
option :cxx11
def install
ENV.cxx11 if build.cxx11?
args = %W[--prefix=#{prefix} --enable-cxx]
args << "--build=core2-apple-darwin#{`uname -r`.to_i}" if build.bottle?
system "./configure", "--disable-static", *args
system "make"
system "make", "check"
system "make", "install"
system "make", "clean"
system "./configure", "--disable-shared", "--disable-assembly", *args
system "make"
lib.install Dir[".libs/*.a"]
end
test do
(testpath/"test.c").write <<-EOS.undent
#include <gmp.h>
#include <stdlib.h>
int main() {
mpz_t i, j, k;
mpz_init_set_str (i, "1a", 16);
mpz_init (j);
mpz_init (k);
mpz_sqrtrem (j, k, i);
if (mpz_get_si (j) != 5 || mpz_get_si (k) != 1) abort();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lgmp", "-o", "test"
system "./test"
end
end