2012-08-25 23:04:20 +00:00
|
|
|
class Ghc < Formula
|
2015-03-28 00:32:51 +00:00
|
|
|
homepage "https://haskell.org/ghc/"
|
2015-03-18 02:38:35 +00:00
|
|
|
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-src.tar.xz"
|
|
|
|
sha256 "92f3e3d67a637c587c49b61c704a670953509eb4b17a93c0c2ac153da4cd3aa0"
|
2010-02-23 19:45:44 +00:00
|
|
|
|
2013-09-20 20:51:19 +00:00
|
|
|
bottle do
|
2015-04-02 05:45:40 +00:00
|
|
|
revision 1
|
|
|
|
sha256 "c2ec277a5445ece878b940838a93feed7a0c7733273ddcb26c07ec434f6ad800" => :yosemite
|
|
|
|
sha256 "1107ca8344e4bf2229d78cee7b3ee7a86f06d950f4a3b6c5c58d66675922935b" => :mavericks
|
|
|
|
sha256 "ad654abb4c2459b6cc764f275d5b6b141669e366f5051c58d871e54cb71a250c" => :mountain_lion
|
2013-09-20 20:51:19 +00:00
|
|
|
end
|
|
|
|
|
2014-03-05 19:13:08 +00:00
|
|
|
option "32-bit"
|
2015-01-31 19:52:27 +00:00
|
|
|
option "with-tests", "Verify the build using the testsuite."
|
|
|
|
|
|
|
|
deprecated_option "tests" => "with-tests"
|
2012-09-14 16:07:47 +00:00
|
|
|
|
2014-05-09 12:52:29 +00:00
|
|
|
# http://hackage.haskell.org/trac/ghc/ticket/6009
|
|
|
|
depends_on :macos => :snow_leopard
|
2014-09-08 20:25:39 +00:00
|
|
|
depends_on "gcc" if MacOS.version == :mountain_lion
|
2012-04-17 13:50:31 +00:00
|
|
|
|
2015-04-01 13:55:35 +00:00
|
|
|
resource "gmp" do
|
|
|
|
url "http://ftpmirror.gnu.org/gmp/gmp-6.0.0a.tar.bz2"
|
|
|
|
mirror "ftp://ftp.gmplib.org/pub/gmp/gmp-6.0.0a.tar.bz2"
|
|
|
|
mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.0.0a.tar.bz2"
|
|
|
|
sha256 "7f8e9a804b9c6d07164cf754207be838ece1219425d64e28cfa3e70d5c759aaf"
|
|
|
|
end
|
|
|
|
|
2014-09-08 20:25:39 +00:00
|
|
|
if build.build_32_bit? || !MacOS.prefer_64_bit?
|
|
|
|
resource "binary" do
|
2015-01-06 18:44:01 +00:00
|
|
|
url "https://downloads.haskell.org/~ghc/7.4.2/ghc-7.4.2-i386-apple-darwin.tar.bz2"
|
2014-09-08 20:25:39 +00:00
|
|
|
sha256 "80c946e6d66e46ca5d40755f3fbe3100e24c0f8036b850fd8767c4f9efd02bef"
|
|
|
|
end
|
|
|
|
elsif MacOS.version <= :lion
|
|
|
|
# https://ghc.haskell.org/trac/ghc/ticket/9257
|
|
|
|
resource "binary" do
|
2015-01-06 18:44:01 +00:00
|
|
|
url "https://downloads.haskell.org/~ghc/7.6.3/ghc-7.6.3-x86_64-apple-darwin.tar.bz2"
|
2014-09-08 20:25:39 +00:00
|
|
|
sha256 "f7a35bea69b6cae798c5f603471a53b43c4cc5feeeeb71733815db6e0a280945"
|
|
|
|
end
|
|
|
|
else
|
2015-03-29 17:20:32 +00:00
|
|
|
# there is currently no 7.10.1 binary download for darwin,
|
|
|
|
# so we use the one for 7.8.4 instead
|
2014-09-08 20:25:39 +00:00
|
|
|
resource "binary" do
|
2015-03-18 02:38:35 +00:00
|
|
|
url "https://downloads.haskell.org/~ghc/7.8.4/ghc-7.8.4-x86_64-apple-darwin.tar.xz"
|
|
|
|
sha256 "ebb6b0294534abda05af91798b43e2ea02481edacbf3d845a1e5925a211c67e3"
|
2014-03-05 19:13:08 +00:00
|
|
|
end
|
2014-05-09 12:52:29 +00:00
|
|
|
end
|
2014-03-05 19:13:08 +00:00
|
|
|
|
2015-01-31 19:52:27 +00:00
|
|
|
stable do
|
|
|
|
resource "testsuite" do
|
2015-03-18 02:38:35 +00:00
|
|
|
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-testsuite.tar.xz"
|
|
|
|
sha256 "33bbdfcfa50363526ea9671c8c1f01b7c5dec01372604d45cbb53bb2515298cb"
|
2015-01-31 19:52:27 +00:00
|
|
|
end
|
2014-09-08 20:25:39 +00:00
|
|
|
end
|
|
|
|
|
2015-03-08 12:43:06 +00:00
|
|
|
fails_with :llvm do
|
|
|
|
cause <<-EOS.undent
|
|
|
|
cc1: error: unrecognized command line option "-Wno-invalid-pp-token"
|
|
|
|
cc1: error: unrecognized command line option "-Wno-unicode"
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2014-09-08 20:25:39 +00:00
|
|
|
if build.build_32_bit? || !MacOS.prefer_64_bit? || MacOS.version < :mavericks
|
2014-03-08 18:13:03 +00:00
|
|
|
fails_with :clang do
|
|
|
|
cause <<-EOS.undent
|
|
|
|
Building with Clang configures GHC to use Clang as its preprocessor,
|
|
|
|
which causes subsequent GHC-based builds to fail.
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-24 07:48:30 +00:00
|
|
|
def install
|
2015-04-01 13:55:35 +00:00
|
|
|
ENV.m32 if build.build_32_bit?
|
|
|
|
|
|
|
|
# Build a static gmp (to avoid dynamic linking to ghc)
|
|
|
|
gmp_prefix = buildpath/"gmp-static"
|
|
|
|
resource("gmp").stage do
|
|
|
|
gmp_args = ["--prefix=#{gmp_prefix}", "--enable-cxx", "--enable-shared=no"]
|
|
|
|
gmp_args << "ABI=32" if build.build_32_bit?
|
|
|
|
|
|
|
|
# https://github.com/Homebrew/homebrew/issues/20693
|
|
|
|
gmp_args << "--disable-assembly" if build.build_32_bit? || build.bottle?
|
|
|
|
|
|
|
|
system "./configure", *gmp_args
|
|
|
|
system "make"
|
|
|
|
system "make", "check"
|
|
|
|
ENV.deparallelize
|
|
|
|
system "make", "install"
|
|
|
|
end
|
2015-03-08 10:16:59 +00:00
|
|
|
|
2012-08-25 23:04:20 +00:00
|
|
|
# Move the main tarball contents into a subdirectory
|
2014-03-08 15:22:27 +00:00
|
|
|
(buildpath+"Ghcsource").install Dir["*"]
|
2012-08-25 23:04:20 +00:00
|
|
|
|
2014-09-08 20:25:39 +00:00
|
|
|
resource("binary").stage do
|
2013-08-24 07:48:30 +00:00
|
|
|
# Define where the subformula will temporarily install itself
|
2014-03-08 15:22:27 +00:00
|
|
|
subprefix = buildpath+"subfo"
|
2013-08-24 07:48:30 +00:00
|
|
|
|
|
|
|
# ensure configure does not use Xcode 5 "gcc" which is actually clang
|
2014-09-08 20:25:39 +00:00
|
|
|
system "./configure", "--prefix=#{subprefix}", "--with-gcc=#{ENV.cc}"
|
2013-08-24 07:48:30 +00:00
|
|
|
|
2014-09-08 20:25:39 +00:00
|
|
|
if MacOS.version <= :lion
|
2014-03-05 19:13:08 +00:00
|
|
|
# __thread is not supported on Lion but configure enables it anyway.
|
|
|
|
File.open("mk/config.h", "a") do |file|
|
|
|
|
file.write("#undef CC_SUPPORTS_TLS")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-08 15:22:27 +00:00
|
|
|
# -j1 fixes an intermittent race condition
|
|
|
|
system "make", "-j1", "install"
|
|
|
|
ENV.prepend_path "PATH", subprefix/"bin"
|
2012-08-25 23:04:20 +00:00
|
|
|
end
|
|
|
|
|
2014-03-08 15:22:27 +00:00
|
|
|
cd "Ghcsource" do
|
2012-08-25 23:04:20 +00:00
|
|
|
# Fix an assertion when linking ghc with llvm-gcc
|
2013-12-14 18:13:11 +00:00
|
|
|
# https://github.com/Homebrew/homebrew/issues/13650
|
2014-03-08 15:22:27 +00:00
|
|
|
ENV["LD"] = "ld"
|
2012-08-25 23:04:20 +00:00
|
|
|
|
2014-05-09 12:52:29 +00:00
|
|
|
if build.build_32_bit? || !MacOS.prefer_64_bit?
|
2014-03-08 15:22:27 +00:00
|
|
|
arch = "i386"
|
2014-05-09 12:52:29 +00:00
|
|
|
else
|
|
|
|
arch = "x86_64"
|
2012-08-25 23:04:20 +00:00
|
|
|
end
|
|
|
|
|
2014-10-28 23:43:27 +00:00
|
|
|
# These will find their way into ghc's settings file, ensuring
|
|
|
|
# that ghc will look in the Homebrew lib dir for native libs
|
|
|
|
# (e.g., libgmp) even if the prefix is not /usr/local. Both are
|
|
|
|
# necessary to avoid problems on systems with custom prefixes:
|
|
|
|
# ghci fails without the first, compiling packages that depend
|
|
|
|
# on native libs fails without the second.
|
|
|
|
ENV["CONF_CC_OPTS_STAGE2"] = "-B#{HOMEBREW_PREFIX}/lib"
|
|
|
|
ENV["CONF_GCC_LINKER_OPTS_STAGE2"] = "-L#{HOMEBREW_PREFIX}/lib"
|
|
|
|
|
2013-08-24 07:48:30 +00:00
|
|
|
# ensure configure does not use Xcode 5 "gcc" which is actually clang
|
2014-09-08 20:25:39 +00:00
|
|
|
system "./configure", "--prefix=#{prefix}",
|
|
|
|
"--build=#{arch}-apple-darwin",
|
2015-03-08 10:16:59 +00:00
|
|
|
"--with-gcc=#{ENV.cc}",
|
2015-04-01 13:55:35 +00:00
|
|
|
"--with-gmp-includes=#{gmp_prefix}",
|
|
|
|
"--with-gmp-libraries=#{gmp_prefix}"
|
2014-03-08 15:22:27 +00:00
|
|
|
system "make"
|
|
|
|
|
2015-01-31 19:52:27 +00:00
|
|
|
if build.with? "tests"
|
2014-03-08 15:22:27 +00:00
|
|
|
resource("testsuite").stage do
|
2014-04-11 18:25:21 +00:00
|
|
|
cd "testsuite" do
|
|
|
|
(buildpath+"Ghcsource/config").install Dir["config/*"]
|
|
|
|
(buildpath+"Ghcsource/driver").install Dir["driver/*"]
|
|
|
|
(buildpath+"Ghcsource/mk").install Dir["mk/*"]
|
|
|
|
(buildpath+"Ghcsource/tests").install Dir["tests/*"]
|
|
|
|
(buildpath+"Ghcsource/timeout").install Dir["timeout/*"]
|
|
|
|
end
|
2014-03-08 15:22:27 +00:00
|
|
|
cd (buildpath+"Ghcsource/tests") do
|
|
|
|
system "make", "CLEANUP=1", "THREADS=#{ENV.make_jobs}", "fast"
|
2012-08-25 23:04:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-03-08 15:22:27 +00:00
|
|
|
|
|
|
|
system "make"
|
|
|
|
# -j1 fixes an intermittent race condition
|
|
|
|
system "make", "-j1", "install"
|
2014-09-08 20:25:39 +00:00
|
|
|
# use clang, even when gcc was used to build ghc
|
|
|
|
settings = Dir[lib/"ghc-*/settings"][0]
|
|
|
|
inreplace settings, "\"#{ENV.cc}\"", "\"clang\""
|
2012-08-25 23:04:20 +00:00
|
|
|
end
|
2011-03-28 09:37:52 +00:00
|
|
|
end
|
2010-06-29 04:42:12 +00:00
|
|
|
|
2014-03-06 04:39:25 +00:00
|
|
|
test do
|
|
|
|
hello = (testpath/"hello.hs")
|
|
|
|
hello.write('main = putStrLn "Hello Homebrew"')
|
|
|
|
output = `echo "main" | '#{bin}/ghci' #{hello}`
|
|
|
|
assert $?.success?
|
|
|
|
assert_match /Hello Homebrew/i, output
|
|
|
|
end
|
2010-02-23 19:45:44 +00:00
|
|
|
end
|