homebrew-core/Formula/ghc@8.6.rb

113 lines
3.9 KiB
Ruby
Raw Normal View History

2019-09-13 12:13:35 +00:00
require "language/haskell"
class GhcAT86 < Formula
include Language::Haskell::Cabal
desc "Glorious Glasgow Haskell Compilation System"
homepage "https://haskell.org/ghc/"
url "https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-src.tar.xz"
sha256 "4d4aa1e96f4001b934ac6193ab09af5d6172f41f5a5d39d8e43393b9aafee361"
2019-09-15 14:38:03 +00:00
bottle do
sha256 "0aaed7d9ff0734d21611b8987796238e60288c87435eac3a834464471f3c14e0" => :mojave
sha256 "5af541eb9720ef526d3ac96a5f81b36ad21983c845ff228c79687ea1f2d4013a" => :high_sierra
sha256 "34a9a1e3a59b2adec9ab6cab93f36fcf459e8ed2dc90b845aca6245c703d66c2" => :sierra
end
2019-09-13 12:13:35 +00:00
keg_only :versioned_formula
depends_on "python" => :build
depends_on "sphinx-doc" => :build
resource "gmp" do
url "https://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz"
mirror "https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz"
mirror "https://ftpmirror.gnu.org/gmp/gmp-6.1.2.tar.xz"
sha256 "87b565e89a9a684fe4ebeeddb8399dce2599f9c9049854ca8c0dfbdea0e21912"
end
# https://www.haskell.org/ghc/download_ghc_8_6_5#macosx_x86_64
# "This is a distribution for Mac OS X, 10.7 or later."
resource "binary" do
url "https://downloads.haskell.org/~ghc/8.6.5/ghc-8.6.5-x86_64-apple-darwin.tar.xz"
sha256 "dfc1bdb1d303a87a8552aa17f5b080e61351f2823c2b99071ec23d0837422169"
end
def install
ENV["CC"] = ENV.cc
ENV["LD"] = "ld"
# Build a static gmp rather than in-tree gmp, otherwise all ghc-compiled
# executables link to Homebrew's GMP.
gmp = libexec/"integer-gmp"
# GMP *does not* use PIC by default without shared libs so --with-pic
# is mandatory or else you'll get "illegal text relocs" errors.
resource("gmp").stage do
system "./configure", "--prefix=#{gmp}", "--with-pic", "--disable-shared",
"--build=#{Hardware.oldest_cpu}-apple-darwin#{`uname -r`.to_i}"
system "make"
system "make", "check"
system "make", "install"
end
args = ["--with-gmp-includes=#{gmp}/include",
"--with-gmp-libraries=#{gmp}/lib"]
# As of Xcode 7.3 (and the corresponding CLT) `nm` is a symlink to `llvm-nm`
# and the old `nm` is renamed `nm-classic`. Building with the new `nm`, a
# segfault occurs with the following error:
# make[1]: * [compiler/stage2/dll-split.stamp] Segmentation fault: 11
# Upstream is aware of the issue and is recommending the use of nm-classic
# until Apple restores POSIX compliance:
# https://ghc.haskell.org/trac/ghc/ticket/11744
# https://ghc.haskell.org/trac/ghc/ticket/11823
# https://mail.haskell.org/pipermail/ghc-devs/2016-April/011862.html
# LLVM itself has already fixed the bug: llvm-mirror/llvm@ae7cf585
# rdar://25311883 and rdar://25299678
if DevelopmentTools.clang_build_version >= 703 && DevelopmentTools.clang_build_version < 800
args << "--with-nm=#{`xcrun --find nm-classic`.chomp}"
end
resource("binary").stage do
binary = buildpath/"binary"
system "./configure", "--prefix=#{binary}", *args
ENV.deparallelize { system "make", "install" }
ENV.prepend_path "PATH", binary/"bin"
end
if build.head?
resource("cabal").stage do
system "sh", "bootstrap.sh", "--sandbox"
(buildpath/"bootstrap-tools/bin").install ".cabal-sandbox/bin/cabal"
end
ENV.prepend_path "PATH", buildpath/"bootstrap-tools/bin"
cabal_sandbox do
cabal_install "--only-dependencies", "happy", "alex"
cabal_install "--prefix=#{buildpath}/bootstrap-tools", "happy", "alex"
end
system "./boot"
end
system "./configure", "--prefix=#{prefix}", *args
system "make"
ENV.deparallelize { system "make", "install" }
Dir.glob(lib/"*/package.conf.d/package.cache") { |f| rm f }
end
def post_install
system "#{bin}/ghc-pkg", "recache"
end
test do
(testpath/"hello.hs").write('main = putStrLn "Hello Homebrew"')
system "#{bin}/runghc", testpath/"hello.hs"
end
end