Created
May 3, 2015 18:07
-
-
Save geoff-nixon/63a11a7f88c4b1117f4d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ghc < Formula | |
homepage "https://haskell.org/ghc/" | |
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-src.tar.xz" | |
sha256 "92f3e3d67a637c587c49b61c704a670953509eb4b17a93c0c2ac153da4cd3aa0" | |
option "with-tests", "Verify the build using the testsuite." | |
if MacOS.version <= :lion | |
fails_with :clang do | |
cause <<-EOS.undent | |
Fails to bootstrap ghc-cabal. Error is: | |
libraries/Cabal/Cabal/Distribution/Compat/Binary/Class.hs:398:14: | |
The last statement in a 'do' block must be an expression | |
n <- get :: Get Int getMany n | |
EOS | |
end | |
end | |
resource "binary" do | |
if MacOS.version <= :lion | |
url "https://downloads.haskell.org/~ghc/7.6.3/ghc-7.6.3-x86_64-apple-darwin.tar.bz2" | |
sha256 "f7a35bea69b6cae798c5f603471a53b43c4cc5feeeeb71733815db6e0a280945" | |
else | |
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-x86_64-apple-darwin.tar.xz" | |
sha256 "bc45de19efc831f7d5a3fe608ba4ebcd24cc0f414cac4bc40ef88a04640583f6" | |
end | |
end | |
resource "testsuite" do | |
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-testsuite.tar.xz" | |
sha256 "33bbdfcfa50363526ea9671c8c1f01b7c5dec01372604d45cbb53bb2515298cb" | |
end | |
def install | |
(buildpath/"mk/build.mk").write(<<-EOS.undent | |
V = 0 | |
GhcLibWays = v p | |
GhcHcOpts = -O2 -H64m -fasm -Rghc-timing | |
GhcStage1HcOpts = -O2 -H64m -fasm | |
GhcStage2HcOpts = -O2 -H64m -fasm | |
GhcLibHcOpts = -O2 -H64m -fasm | |
SRC_HC_OPTS = -O2 -H64m -fasm | |
DYNAMIC_BY_DEFAULT = NO | |
DYNAMIC_GHC_PROGRAMS = NO | |
INTEGER_LIBRARY = integer-simple | |
EOS | |
) | |
args = ["--with-hs-cpp-flags=-E -undef -traditional -w", | |
"--with-gcc=#{ENV.cc}", "--with-clang=#{ENV.cc}", "--with-ld=ld"] | |
resource("binary").stage do | |
binary = buildpath/"binary" | |
system "./configure", "--prefix=#{binary}", *args | |
ENV.deparallelize { system "make", "install" } | |
ENV.prepend_path "PATH", binary/"bin" | |
end | |
system "./configure", "--prefix=#{prefix}", *args | |
system "make" | |
if build.with? "tests" | |
resource("testsuite").stage { buildpath.install Dir["*"] } | |
cd "testsuite" do | |
system "make", "clean" | |
system "make", "CLEANUP=1", "THREADS=#{ENV.make_jobs}", "fast" | |
end | |
end | |
ENV.deparallelize { system "make", "install" } | |
end | |
test do | |
(testpath/"hello.hs").write('main = putStrLn "Hello Homebrew"') | |
system "runghc", testpath/"hello.hs" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment