Merge pull request #207012 from Homebrew/bump-tailwindcss-4.0.5
[Homebrew/homebrew-core.git] / Formula / g / ghc@9.2.rb
blob0f1d30a4c7844fd73bff8c6dd1c40f3dd359f54c
1 class GhcAT92 < Formula
2   desc "Glorious Glasgow Haskell Compilation System"
3   homepage "https://haskell.org/ghc/"
4   url "https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-src.tar.xz"
5   sha256 "5f13d1786bf4fd12f4b45faa37abedb5bb3f36d5e58f7da5307e8bfe88a567a1"
6   # We build bundled copies of libffi and GMP so GHC inherits the licenses
7   license all_of: [
8     "BSD-3-Clause",
9     "MIT", # libffi
10     any_of: ["LGPL-3.0-or-later", "GPL-2.0-or-later"], # GMP
11   ]
13   bottle do
14     rebuild 1
15     sha256 cellar: :any,                 arm64_sonoma:   "655bbab689b52ce774c6d02a43eb33ce53592b06440a088cedcee758876c50a7"
16     sha256 cellar: :any,                 arm64_ventura:  "8cf37ef16647a516f9f32f35eb2919250d0042e0a7b9f8866095e295ac2fdedc"
17     sha256 cellar: :any,                 arm64_monterey: "9bb8bc86992b9377bff2d36bc6b58b382a5145d5c77ee5a5e2c949b26157c439"
18     sha256 cellar: :any,                 sonoma:         "a5753c516c679fb18679fa9e51ae53266629c1af6acc4a38afdc3db5bb03e2f7"
19     sha256 cellar: :any,                 ventura:        "ec0c7dcb8324e4dc98ee7109504445f6ae8373f9bd582d9401ae09f0ea54c97d"
20     sha256 cellar: :any,                 monterey:       "d10b5a289d3128529285ade5780d117c9e7e259eaa85b9379e5c74463a77e212"
21     sha256 cellar: :any_skip_relocation, x86_64_linux:   "aacd44c8dff96335cc9af1c8e0e1f789fcb39c5124ac700143718bba1ed54973"
22   end
24   keg_only :versioned_formula
26   # No longer maintained. 9.2 was removed from current releases on 2023-11-10 with 9.4.8 release.
27   # Ref: https://gitlab.haskell.org/ghc/homepage/-/commit/f8e37fc84e6bc3b72e651bc778a1d6a7f2614e4b
28   deprecate! date: "2024-08-15", because: :unmaintained
30   depends_on "autoconf" => :build
31   depends_on "automake" => :build
32   depends_on maximum_macos: [:sonoma, :build]
33   depends_on "python@3.12" => :build
34   depends_on "sphinx-doc" => :build
35   depends_on macos: :catalina
37   uses_from_macos "m4" => :build
38   uses_from_macos "xz" => :build
39   uses_from_macos "ncurses"
41   on_linux do
42     depends_on "gmp" => :build
43   end
45   # A binary of ghc is needed to bootstrap ghc
46   resource "binary" do
47     on_macos do
48       on_arm do
49         url "https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-aarch64-apple-darwin.tar.xz"
50         sha256 "34db9b19571905b08ca1e444b46490e7c19cb73a0fe778696fa6ec02ff8d3c4b"
51       end
52       on_intel do
53         url "https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-x86_64-apple-darwin.tar.xz"
54         sha256 "eb78361feaf4277f627cbdc4b849849d09d175d0d878d28433719b7482db27f5"
55       end
56     end
57     on_linux do
58       on_arm do
59         url "https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-aarch64-deb10-linux.tar.xz"
60         sha256 "645433359d8ad9e7b286f85ef5111db1b787ee3712c24c5dfde7c62769aa59a4"
61       end
62       on_intel do
63         url "https://downloads.haskell.org/~ghc/9.2.8/ghc-9.2.8-x86_64-ubuntu20.04-linux.tar.xz"
64         sha256 "6e4adc184a53ca9d9dd8c11c6611d0643fdc3b76550ae769e378d9edb2bda745"
65       end
66     end
67   end
69   resource "cabal-install" do
70     on_macos do
71       on_arm do
72         url "https://downloads.haskell.org/~cabal/cabal-install-3.10.2.0/cabal-install-3.10.2.0-aarch64-darwin.tar.xz"
73         sha256 "d2bd336d7397cf4b76f3bb0d80dea24ca0fa047903e39c8305b136e855269d7b"
74       end
75       on_intel do
76         url "https://downloads.haskell.org/~cabal/cabal-install-3.10.2.0/cabal-install-3.10.2.0-x86_64-darwin.tar.xz"
77         sha256 "cd64f2a8f476d0f320945105303c982448ca1379ff54b8625b79fb982b551d90"
78       end
79     end
80     on_linux do
81       on_arm do
82         url "https://downloads.haskell.org/~cabal/cabal-install-3.10.2.0/cabal-install-3.10.2.0-aarch64-linux-deb10.tar.xz"
83         sha256 "004ed4a7ca890fadee23f58f9cb606c066236a43e16b34be2532b177b231b06d"
84       end
85       on_intel do
86         url "https://downloads.haskell.org/~cabal/cabal-install-3.10.2.0/cabal-install-3.10.2.0-x86_64-linux-ubuntu20_04.tar.xz"
87         sha256 "c2a8048caa3dbfe021d0212804f7f2faad4df1154f1ff52bd2f3c68c1d445fe1"
88       end
89     end
90   end
92   # Backport fix for building docs with sphinx-doc 6.
93   # Ref: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/9625
94   patch do
95     url "https://gitlab.haskell.org/ghc/ghc/-/commit/00dc51060881df81258ba3b3bdf447294618a4de.diff"
96     sha256 "354baeb8727fbbfb6da2e88f9748acaab23bcccb5806f8f59787997753231dbb"
97   end
99   # Backport fix for building docs with sphinx-doc 7.
100   # Ref: https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10520
101   patch do
102     url "https://gitlab.haskell.org/ghc/ghc/-/commit/70526f5bd8886126f49833ef20604a2c6477780a.diff"
103     sha256 "54cdde1ca5d1b6fe3bbad8d0eac2b8c112ca1f346c4086d1e7361fa9510f1f44"
104   end
106   def install
107     ENV["CC"] = ENV.cc
108     ENV["LD"] = "ld"
109     ENV["PYTHON"] = which("python3.12")
111     binary = buildpath/"binary"
112     resource("binary").stage do
113       binary_args = []
114       if OS.linux?
115         binary_args << "--with-gmp-includes=#{Formula["gmp"].opt_include}"
116         binary_args << "--with-gmp-libraries=#{Formula["gmp"].opt_lib}"
117       end
119       system "./configure", "--prefix=#{binary}", *binary_args
120       ENV.deparallelize { system "make", "install" }
122       ENV.prepend_path "PATH", binary/"bin"
123     end
125     resource("cabal-install").stage { (binary/"bin").install "cabal" }
126     system "cabal", "v2-update"
127     cabal_args = std_cabal_v2_args.reject { |s| s["installdir"] }
128     system "cabal", "v2-install", "alex", "happy", *cabal_args, "--installdir=#{binary}/bin"
130     system "./configure", "--prefix=#{prefix}", "--disable-numa", "--with-intree-gmp"
131     hadrian_args = %W[
132       -j#{ENV.make_jobs}
133       --prefix=#{prefix}
134       --flavour=perf
135       --docs=no-sphinx-pdfs
136     ]
137     # Work around linkage error due to RPATH in ghc-iserv-dyn-ghc
138     # Issue ref: https://gitlab.haskell.org/ghc/ghc/-/issues/22557
139     os = OS.mac? ? "osx" : OS.kernel_name.downcase
140     cpu = Hardware::CPU.arm? ? "aarch64" : Hardware::CPU.arch.to_s
141     extra_rpath = rpath(source: lib/"ghc-#{version}/bin",
142                         target: lib/"ghc-#{version}/lib/#{cpu}-#{os}-ghc-#{version}")
143     hadrian_args << "*.iserv.ghc.link.opts += -optl-Wl,-rpath,#{extra_rpath}"
144     # Let hadrian handle its own parallelization
145     ENV.deparallelize { system "hadrian/build", "install", *hadrian_args }
147     bash_completion.install "utils/completion/ghc.bash" => "ghc"
148     (lib/"ghc-#{version}/lib/package.conf.d/package.cache").unlink
149     (lib/"ghc-#{version}/lib/package.conf.d/package.cache.lock").unlink
150   end
152   def post_install
153     system bin/"ghc-pkg", "recache"
154   end
156   test do
157     (testpath/"hello.hs").write('main = putStrLn "Hello Homebrew"')
158     assert_match "Hello Homebrew", shell_output("#{bin}/runghc hello.hs")
159   end