Verified Commit f851fb37 authored by Houtan Bastani's avatar Houtan Bastani
Browse files

new formulae

parent f960ff80
class Gcc < Formula
desc "GNU compiler collection"
homepage "https://gcc.gnu.org/"
url "https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz"
mirror "https://ftpmirror.gnu.org/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz"
sha256 "ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206"
revision 1
head "https://gcc.gnu.org/git/gcc.git"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "e1a6cd0d52fb715431063657cec4e3578170079168b612a6998d321d778330b1" => :catalina
sha256 "12951cda5ca32814387a1106fdaea9c4d4dd55e9c27f0dc7c044ab5e00dca695" => :mojave
sha256 "fd0945c648c9a6672892a9b17ce3108dd6b8319aaf67c2718290ea0d13e22f1b" => :high_sierra
end
# The bottles are built on systems with the CLT installed, and do not work
# out of the box on Xcode-only systems due to an incorrect sysroot.
pour_bottle? do
reason "The bottle needs the Xcode CLT to be installed."
satisfy { MacOS::CLT.installed? }
end
depends_on "houtanb/dynare-brew/gmp"
depends_on "houtanb/dynare-brew/isl"
depends_on "houtanb/dynare-brew/libmpc"
depends_on "houtanb/dynare-brew/mpfr"
# GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
cxxstdlib_check :skip
# Fix system headers for Catalina SDK
# (otherwise __OSX_AVAILABLE_STARTING ends up undefined)
if DevelopmentTools.clang_build_version >= 1100
patch do
url "https://raw.githubusercontent.com/Homebrew/formula-patches/b8b8e65e/gcc/9.2.0-catalina.patch"
sha256 "0b8d14a7f3c6a2f0d2498526e86e088926671b5da50a554ffa6b7f73ac4f132b"
end
end
def version_suffix
if build.head?
"HEAD"
else
version.to_s.slice(/\d/)
end
end
def install
# GCC will suffer build errors if forced to use a particular linker.
ENV.delete "LD"
# We avoiding building:
# - Ada, which requires a pre-existing GCC Ada compiler to bootstrap
# - Go, currently not supported on macOS
# - BRIG
languages = %w[c c++ objc obj-c++ fortran]
osmajor = `uname -r`.split(".").first
pkgversion = "Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip
args = %W[
--build=x86_64-apple-darwin#{osmajor}
--prefix=#{prefix}
--libdir=#{lib}/gcc/#{version_suffix}
--disable-nls
--enable-checking=release
--enable-languages=#{languages.join(",")}
--program-suffix=-#{version_suffix}
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
--with-mpc=#{Formula["libmpc"].opt_prefix}
--with-isl=#{Formula["isl"].opt_prefix}
--with-system-zlib
--with-pkgversion=#{pkgversion}
--with-bugurl=https://github.com/Homebrew/homebrew-core/issues
]
# Xcode 10 dropped 32-bit support
args << "--disable-multilib" if DevelopmentTools.clang_build_version >= 1000
# Ensure correct install names when linking against libgcc_s;
# see discussion in https://github.com/Homebrew/legacy-homebrew/pull/34303
inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/#{version_suffix}"
mkdir "build" do
if !MacOS::CLT.installed?
# For Xcode-only systems, we need to tell the sysroot path
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=#{MacOS.sdk_path}"
elsif MacOS.version >= :mojave
# System headers are no longer located in /usr/include
args << "--with-native-system-header-dir=/usr/include"
args << "--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
end
system "../configure", *args
# Use -headerpad_max_install_names in the build,
# otherwise updated load commands won't fit in the Mach-O header.
# This is needed because `gcc` avoids the superenv shim.
system "make", "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names"
system "make", "install"
bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran"
end
# Handle conflicts between GCC formulae and avoid interfering
# with system compilers.
# Rename man7.
Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix }
# Even when we disable building info pages some are still installed.
info.rmtree
end
def add_suffix(file, suffix)
dir = File.dirname(file)
ext = File.extname(file)
base = File.basename(file, ext)
File.rename file, "#{dir}/#{base}-#{suffix}#{ext}"
end
test do
(testpath/"hello-c.c").write <<~EOS
#include <stdio.h>
int main()
{
puts("Hello, world!");
return 0;
}
EOS
system "#{bin}/gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c"
assert_equal "Hello, world!\n", `./hello-c`
(testpath/"hello-cc.cc").write <<~EOS
#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
EOS
system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc"
assert_equal "Hello, world!\n", `./hello-cc`
(testpath/"test.f90").write <<~EOS
integer,parameter::m=10000
real::a(m), b(m)
real::fact=0.5
do concurrent (i=1:m)
a(i) = a(i) + fact*b(i)
end do
write(*,"(A)") "Done"
end
EOS
system "#{bin}/gfortran", "-o", "test", "test.f90"
assert_equal "Done\n", `./test`
end
end
class Gettext < Formula
desc "GNU internationalization (i18n) and localization (l10n) library"
homepage "https://www.gnu.org/software/gettext/"
url "https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.xz"
mirror "https://ftpmirror.gnu.org/gettext/gettext-0.20.1.tar.xz"
sha256 "53f02fbbec9e798b0faaf7c73272f83608e835c6288dd58be6c9bb54624a3800"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "107d7f386fbeea6979f9376cdbbcf3f60943caaad61bdc754d3019ce625dffe6" => :catalina
sha256 "fa2096f80238b8f4d9f3724d526626ab4db5c0586f3746ee13fc66e5a625aa1a" => :mojave
sha256 "10dd5c2b9c6613b5310f95931d7233a8b7947c541433fcc5891ce837c45595a0" => :high_sierra
sha256 "85c7bf74ba9b0209a08f2b87d69b54d03ec21985ad0bb7b9aeeda30c195529f8" => :sierra
end
keg_only :shadowed_by_macos,
"macOS provides the BSD gettext library & some software gets confused if both are in the library path"
def install
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--disable-debug",
"--prefix=#{prefix}",
"--with-included-gettext",
# Work around a gnulib issue with macOS Catalina
"gl_cv_func_ftello_works=yes",
"--with-included-glib",
"--with-included-libcroco",
"--with-included-libunistring",
"--with-emacs",
"--with-lispdir=#{elisp}",
"--disable-java",
"--disable-csharp",
# Don't use VCS systems to create these archives
"--without-git",
"--without-cvs",
"--without-xz"
system "make"
ENV.deparallelize # install doesn't support multiple make jobs
system "make", "install"
end
test do
system bin/"gettext", "test"
end
end
class Git < Formula
desc "Distributed revision control system"
homepage "https://git-scm.com"
url "https://www.kernel.org/pub/software/scm/git/git-2.23.0.tar.xz"
sha256 "234fa05b6839e92dc300b2dd78c92ec9c0c8d439f65e1d430a7034f60af16067"
revision 1
head "https://github.com/git/git.git", :shallow => false
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "cb74c5f3a0e89f7415e9846f96e2d4502284281bd0d2c87a0517e57d9c242cb9" => :catalina
sha256 "846c80d096bd49662e34de8144e73b2df017a3acb35a15942429e111951ba343" => :mojave
sha256 "123e7a9eb96d58ebd1100880018e5f99626bb99e751d99fc62a4183d926a4988" => :high_sierra
sha256 "95b84a677d97a9c522ec0e89cde3967a21c795b47181bf6ba20002f1962dd73c" => :sierra
end
depends_on "houtanb/dynare-brew/gettext"
depends_on "houtanb/dynare-brew/pcre2"
if MacOS.version < :yosemite
depends_on "openssl@1.1"
depends_on "curl"
end
resource "html" do
url "https://www.kernel.org/pub/software/scm/git/git-htmldocs-2.23.0.tar.xz"
sha256 "b7959afd19554aeaaa455c88eeed2c164854391f13319bd3fa7df2577c57ddc8"
end
resource "man" do
url "https://www.kernel.org/pub/software/scm/git/git-manpages-2.23.0.tar.xz"
sha256 "9558433f68ff4229bd55e84c4d26b74e5d3518ab0ec30186253b090ea887946a"
end
resource "Net::SMTP::SSL" do
url "https://cpan.metacpan.org/authors/id/R/RJ/RJBS/Net-SMTP-SSL-1.04.tar.gz"
sha256 "7b29c45add19d3d5084b751f7ba89a8e40479a446ce21cfd9cc741e558332a00"
end
def install
# If these things are installed, tell Git build system not to use them
ENV["NO_FINK"] = "1"
ENV["NO_DARWIN_PORTS"] = "1"
ENV["NO_R_TO_GCC_LINKER"] = "1" # pass arguments to LD correctly
ENV["PYTHON_PATH"] = which("python")
ENV["PERL_PATH"] = which("perl")
ENV["USE_LIBPCRE2"] = "1"
ENV["INSTALL_SYMLINKS"] = "1"
ENV["LIBPCREDIR"] = Formula["pcre2"].opt_prefix
ENV["V"] = "1" # build verbosely
perl_version = Utils.popen_read("perl --version")[/v(\d+\.\d+)(?:\.\d+)?/, 1]
ENV["PERLLIB_EXTRA"] = %W[
#{MacOS.active_developer_dir}
/Library/Developer/CommandLineTools
/Applications/Xcode.app/Contents/Developer
].uniq.map do |p|
"#{p}/Library/Perl/#{perl_version}/darwin-thread-multi-2level"
end.join(":")
unless quiet_system ENV["PERL_PATH"], "-e", "use ExtUtils::MakeMaker"
ENV["NO_PERL_MAKEMAKER"] = "1"
end
args = %W[
prefix=#{prefix}
sysconfdir=#{etc}
CC=#{ENV.cc}
CFLAGS=#{ENV.cflags}
LDFLAGS=#{ENV.ldflags}
]
if MacOS.version < :yosemite
openssl_prefix = Formula["openssl@1.1"].opt_prefix
args += %W[NO_APPLE_COMMON_CRYPTO=1 OPENSSLDIR=#{openssl_prefix}]
else
args += %w[NO_OPENSSL=1 APPLE_COMMON_CRYPTO=1]
end
system "make", "install", *args
git_core = libexec/"git-core"
# Install the macOS keychain credential helper
cd "contrib/credential/osxkeychain" do
system "make", "CC=#{ENV.cc}",
"CFLAGS=#{ENV.cflags}",
"LDFLAGS=#{ENV.ldflags}"
git_core.install "git-credential-osxkeychain"
system "make", "clean"
end
# Generate diff-highlight perl script executable
cd "contrib/diff-highlight" do
system "make"
end
# Install the netrc credential helper
cd "contrib/credential/netrc" do
system "make", "test"
git_core.install "git-credential-netrc"
end
# Install git-subtree
cd "contrib/subtree" do
system "make", "CC=#{ENV.cc}",
"CFLAGS=#{ENV.cflags}",
"LDFLAGS=#{ENV.ldflags}"
git_core.install "git-subtree"
end
# install the completion script first because it is inside "contrib"
bash_completion.install "contrib/completion/git-completion.bash"
bash_completion.install "contrib/completion/git-prompt.sh"
zsh_completion.install "contrib/completion/git-completion.zsh" => "_git"
cp "#{bash_completion}/git-completion.bash", zsh_completion
elisp.install Dir["contrib/emacs/*.el"]
(share/"git-core").install "contrib"
# We could build the manpages ourselves, but the build process depends
# on many other packages, and is somewhat crazy, this way is easier.
man.install resource("man")
(share/"doc/git-doc").install resource("html")
# Make html docs world-readable
chmod 0644, Dir["#{share}/doc/git-doc/**/*.{html,txt}"]
chmod 0755, Dir["#{share}/doc/git-doc/{RelNotes,howto,technical}"]
# To avoid this feature hooking into the system OpenSSL, remove it
if MacOS.version >= :yosemite
rm "#{libexec}/git-core/git-imap-send"
end
# git-send-email needs Net::SMTP::SSL
resource("Net::SMTP::SSL").stage do
(share/"perl5").install "lib/Net"
end
# This is only created when building against system Perl, but it isn't
# purged by Homebrew's post-install cleaner because that doesn't check
# "Library" directories. It is however pointless to keep around as it
# only contains the perllocal.pod installation file.
rm_rf prefix/"Library/Perl"
# Set the macOS keychain credential helper by default
# (as Apple's CLT's git also does this).
(buildpath/"gitconfig").write <<~EOS
[credential]
\thelper = osxkeychain
EOS
etc.install "gitconfig"
end
test do
system bin/"git", "init"
%w[haunted house].each { |f| touch testpath/f }
system bin/"git", "add", "haunted", "house"
system bin/"git", "commit", "-a", "-m", "Initial Commit"
assert_equal "haunted\nhouse", shell_output("#{bin}/git ls-files").strip
# Check Net::SMTP::SSL was installed correctly.
%w[foo bar].each { |f| touch testpath/f }
system bin/"git", "add", "foo", "bar"
system bin/"git", "commit", "-a", "-m", "Second Commit"
assert_match "Authentication Required", shell_output(
"#{bin}/git send-email --to=dev@null.com --smtp-server=smtp.gmail.com " \
"--smtp-encryption=tls --confirm=never HEAD^ 2>&1", 255
)
end
end
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 2
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
rebuild 1
sha256 "2409417943fceda33eac12a8229fbf7b990eee18ee341b543be575550a077bb0" => :catalina
sha256 "84f74594086bccc53bdb141f4d06d7847680374e255ebe016654da1e47db2dfc" => :mojave
sha256 "a536c51149806b73b2e1178be94300832b6b151455006bc7f2a32b9dc493c7a3" => :high_sierra
sha256 "ada22a8bbfe8532d71f2b565e00b1643beaf72bff6b36064cbad0cd7436e4948" => :sierra
end
def install
# Work around macOS Catalina / Xcode 11 code generation bug
# (test failure t-toom53, due to wrong code in mpn/toom53_mul.o)
ENV.append_to_cflags "-fno-stack-check"
# Enable --with-pic to avoid linking issues with the static library
args = %W[--prefix=#{prefix} --enable-cxx --with-pic]
args << "--build=#{Hardware.oldest_cpu}-apple-darwin#{`uname -r`.to_i}"
system "./configure", *args
system "make"
system "make", "check"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#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"
# Test the static library to catch potential linking issues
system ENV.cc, "test.c", "#{lib}/libgmp.a", "-o", "test"
system "./test"
end
end
class Isl < Formula
desc "Integer Set Library for the polyhedral model"
homepage "https://isl.gforge.inria.fr/"
# Note: Always use tarball instead of git tag for stable version.
#
# Currently isl detects its version using source code directory name
# and update isl_version() function accordingly. All other names will
# result in isl_version() function returning "UNKNOWN" and hence break
# package detection.
url "http://isl.gforge.inria.fr/isl-0.21.tar.xz"
mirror "https://deb.debian.org/debian/pool/main/i/isl/isl_0.21.orig.tar.xz"
sha256 "777058852a3db9500954361e294881214f6ecd4b594c00da5eee974cd6a54960"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "1f42c08dd84a2f418c8446be2679f027d8b1250d337b5e3135c401eba578cbb7" => :catalina
sha256 "f9188b5d486b2a835cd865f219be1a9848ce3926e27089a1538ee989db65447d" => :mojave
sha256 "d997d49958218e521bc4f73369414ff9fad040d28601d94012e4c68cd090ea93" => :high_sierra
sha256 "d5dc353916cd98da04552a3d7cb86a3203612df422c4e9389e13e12f86945865" => :sierra
end
head do
url "https://repo.or.cz/isl.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "houtanb/dynare-brew/gmp"
def install
system "./autogen.sh" if build.head?
system "./configure", "--disable-dependency-tracking",
"--disable-silent-rules",
"--prefix=#{prefix}",
"--with-gmp=system",
"--with-gmp-prefix=#{Formula["gmp"].opt_prefix}"
system "make", "check"
system "make", "install"
(share/"gdb/auto-load").install Dir["#{lib}/*-gdb.py"]
end
test do
(testpath/"test.c").write <<~EOS
#include <isl/ctx.h>
int main()
{
isl_ctx* ctx = isl_ctx_alloc();
isl_ctx_free(ctx);
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-lisl", "-o", "test"
system "./test"
end
end
class Libmpc < Formula
desc "C library for the arithmetic of high precision complex numbers"
homepage "http://www.multiprecision.org/mpc/"
url "https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz"
sha256 "6985c538143c1208dcb1ac42cedad6ff52e267b47e5f970183a3e75125b43c2e"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "b9491bbc04d1e52dfb8311dc9aa0081fd3041cb6b2f6b59a4104d712d341979d" => :catalina
sha256 "1cb3a09238830d45d64a87f520f06122d24a020403fac1800c831d15c605282e" => :mojave
sha256 "3b28ec506ab53ef5f3163e87fb72ae735b7f91ee2fc20fe184cf1241481b72a5" => :high_sierra
sha256 "18d620a1612bc51b1fbd1b3b62c9c73766b90549c746740c5a27d2ab1ec5ede7" => :sierra
sha256 "6f19f936781dae0db248abdd84a72c3e25451c44379706bc3800760f0aa43888" => :el_capitan
end
depends_on "houtanb/dynare-brew/gmp"
depends_on "houtanb/dynare-brew/mpfr"
def install
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--with-gmp=#{Formula["gmp"].opt_prefix}
--with-mpfr=#{Formula["mpfr"].opt_prefix}
]
system "./configure", *args
system "make"
system "make", "check"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <mpc.h>
#include <assert.h>
#include <math.h>
int main() {
mpc_t x;
mpc_init2 (x, 256);
mpc_set_d_d (x, 1., INFINITY, MPC_RNDNN);
mpc_tanh (x, x, MPC_RNDNN);
assert (mpfr_nan_p (mpc_realref (x)) && mpfr_nan_p (mpc_imagref (x)));
mpc_clear (x);
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["mpfr"].opt_lib}",
"-L#{Formula["gmp"].opt_lib}", "-lmpc", "-lmpfr",
"-lgmp", "-o", "test"
system "./test"
end
end
class Mpfr < Formula
desc "C library for multiple-precision floating-point computations"
homepage "https://www.mpfr.org/"
url "https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz"
mirror "https://ftpmirror.gnu.org/mpfr/mpfr-4.0.2.tar.xz"
sha256 "1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "140d29bfee0c8cf356fbb5391465f781df559e6076988de3ea8bcfd812f3c5bd" => :catalina
sha256 "cfce7ab866e98360c9364cd924da620ae7936d3a224d686aacc209c2107d19aa" => :mojave
sha256 "bf5d21e7e8e549f7e8d07791a90f44a487f4c7151897b7c64d02928b5bd73520" => :high_sierra
sha256 "4fb1860a481e24c70eefc8e5782030612840f1bb8f50586ca76a4c6c53629deb" => :sierra
end
depends_on "houtanb/dynare-brew/gmp"
def install
# Work around macOS Catalina / Xcode 11 code generation bug
# (test failure t-toom53, due to wrong code in mpn/toom53_mul.o)
ENV.append_to_cflags "-fno-stack-check"
system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}",
"--disable-silent-rules"
system "make"
system "make", "check"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include <mpfr.h>
#include <math.h>
#include <stdlib.h>
int main() {
mpfr_t x, y;
mpfr_inits2 (256, x, y, NULL);
mpfr_set_ui (x, 2, MPFR_RNDN);
mpfr_root (y, x, 2, MPFR_RNDN);
mpfr_pow_si (x, y, 4, MPFR_RNDN);
mpfr_add_si (y, x, -4, MPFR_RNDN);
mpfr_abs (y, y, MPFR_RNDN);
if (fabs(mpfr_get_d (y, MPFR_RNDN)) > 1.e-30) abort();
return 0;
}
EOS
system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}",
"-lgmp", "-lmpfr", "-o", "test"
system "./test"
end
end
class Pcre2 < Formula
desc "Perl compatible regular expressions library with a new API"
homepage "https://www.pcre.org/"
url "https://ftp.pcre.org/pub/pcre/pcre2-10.33.tar.bz2"
sha256 "35514dff0ccdf02b55bd2e9fa586a1b9d01f62332c3356e379eabb75f789d8aa"
head "svn://vcs.exim.org/pcre2/code/trunk"
bottle do
root_url "https://homebrew.bintray.com/bottles"
cellar :any
sha256 "7b92993a7ad0487cabc4395e3633d8294896fa9ffa9e46507d9a7ef25a213ab8" => :catalina
sha256 "fb30c3eebba4483a10378bc8df52f96761fed4a1ac5572ad1bf4afbf2f8638c5" => :mojave
sha256 "26b34cf7a846d49cdbdefa853227d7d4b02d6bd97c59dacdb0fb9dcf155444b5" => :high_sierra
sha256 "a712fa6195fd968bae380e54709f46f66a94c69549a77f0836dae43ed95e11dc" => :sierra
end
def install
system "./configure", "--disable-dependency-tracking",