Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
ghc: install static gmp in prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
geoff-nixon committed Apr 27, 2015
1 parent 3d1b2a2 commit 967a7cc
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions Library/Formula/ghc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ class Ghc < Formula
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-src.tar.xz"
sha256 "92f3e3d67a637c587c49b61c704a670953509eb4b17a93c0c2ac153da4cd3aa0"

revision 2

bottle do
revision 1
sha256 "c2ec277a5445ece878b940838a93feed7a0c7733273ddcb26c07ec434f6ad800" => :yosemite
Expand All @@ -20,10 +22,12 @@ class Ghc < Formula
depends_on "gcc" if MacOS.version == :mountain_lion

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"
# Track the main gmp formula so it doesn't have to be updated here.
@gmp = Formulary.factory("gmp").stable

url @gmp.url
mirror @gmp.mirrors[0]
@checksum = @gmp.checksum
end

if build.build_32_bit? || !MacOS.prefer_64_bit?
Expand All @@ -38,11 +42,9 @@ class Ghc < Formula
sha256 "f7a35bea69b6cae798c5f603471a53b43c4cc5feeeeb71733815db6e0a280945"
end
else
# there is currently no 7.10.1 binary download for darwin,
# so we use the one for 7.8.4 instead
resource "binary" do
url "https://downloads.haskell.org/~ghc/7.8.4/ghc-7.8.4-x86_64-apple-darwin.tar.xz"
sha256 "ebb6b0294534abda05af91798b43e2ea02481edacbf3d845a1e5925a211c67e3"
url "https://downloads.haskell.org/~ghc/7.10.1/ghc-7.10.1-x86_64-apple-darwin.tar.xz"
sha256 "bc45de19efc831f7d5a3fe608ba4ebcd24cc0f414cac4bc40ef88a04640583f6"
end
end

Expand Down Expand Up @@ -72,10 +74,12 @@ class Ghc < Formula
def install
ENV.m32 if build.build_32_bit?

# Build a static gmp (to avoid dynamic linking to ghc)
gmp_prefix = buildpath/"gmp-static"
# Build a static gmp (to avoid dynamic linking to ghc). "--with-pic" is
# *required* when building gmp statically, else you'll get
# "illegal text reloc" errors.
gmp_prefix = libexec/"gmp-static"
resource("gmp").stage do
gmp_args = ["--prefix=#{gmp_prefix}", "--enable-cxx", "--enable-shared=no"]
gmp_args = ["--prefix=#{gmp_prefix}", "--disable-shared", "--with-pic"]
gmp_args << "ABI=32" if build.build_32_bit?

# https://github.com/Homebrew/homebrew/issues/20693
Expand All @@ -84,8 +88,7 @@ def install
system "./configure", *gmp_args
system "make"
system "make", "check"
ENV.deparallelize
system "make", "install"
ENV.deparallelize { system "make", "install" }
end

# Move the main tarball contents into a subdirectory
Expand All @@ -105,8 +108,7 @@ def install
end
end

# -j1 fixes an intermittent race condition
system "make", "-j1", "install"
ENV.deparallelize { system "make", "install" }
ENV.prepend_path "PATH", subprefix/"bin"
end

Expand All @@ -121,21 +123,12 @@ def install
arch = "x86_64"
end

# 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"

# ensure configure does not use Xcode 5 "gcc" which is actually clang
system "./configure", "--prefix=#{prefix}",
"--build=#{arch}-apple-darwin",
"--with-gcc=#{ENV.cc}",
"--with-gmp-includes=#{gmp_prefix}",
"--with-gmp-libraries=#{gmp_prefix}"
"--with-gmp-includes=#{gmp_prefix}/include",
"--with-gmp-libraries=#{gmp_prefix}/lib"
system "make"

if build.with? "tests"
Expand All @@ -151,11 +144,10 @@ def install
system "make", "CLEANUP=1", "THREADS=#{ENV.make_jobs}", "fast"
end
end
system "make"
end

system "make"
# -j1 fixes an intermittent race condition
system "make", "-j1", "install"
ENV.deparallelize { system "make", "install" }
# use clang, even when gcc was used to build ghc
settings = Dir[lib/"ghc-*/settings"][0]
inreplace settings, "\"#{ENV.cc}\"", "\"clang\""
Expand Down

0 comments on commit 967a7cc

Please sign in to comment.