homebrew-core/Formula/erlang@23.rb

108 lines
3.6 KiB
Ruby

class ErlangAT23 < Formula
desc "Programming language for highly scalable real-time systems"
homepage "https://www.erlang.org/"
# Download tarball from GitHub; it is served faster than the official tarball.
url "https://github.com/erlang/otp/releases/download/OTP-23.3.4.10/otp_src_23.3.4.10.tar.gz"
sha256 "5dd75f5032b0c13193620981b901e6277af9dfd8e6e7a7cbee51b8a6448acd19"
license "Apache-2.0"
livecheck do
url :stable
regex(/^OTP[._-]v?(23(?:\.\d+)+)$/i)
end
bottle do
sha256 cellar: :any, arm64_monterey: "c914a3577d5d4570092f5f9cc9262f83bdb230eac0c0087d5241b2daab4085e3"
sha256 cellar: :any, arm64_big_sur: "09d447d2ba492376608f98abb89287934cb0730575f73aa937255e7348da6834"
sha256 cellar: :any, monterey: "fe79e0f2e7304f267f6cd61b803643171ec95b2898cfd662ee59117e77dd9a2e"
sha256 cellar: :any, big_sur: "5515810e0b31aa71ed0e1396caffb7d18f00ffd7ffca3bfa0121f2dfc67f34bd"
sha256 cellar: :any, catalina: "2afda978c143f08a0926ac472dfb0e0597a573f04ab198c20cda428415b91ed5"
sha256 cellar: :any_skip_relocation, x86_64_linux: "195fa88e6d6d632150880012ab039c26991d392ca3a5af8ae2b5da8eb3b12968"
end
keg_only :versioned_formula
depends_on "openssl@1.1"
depends_on "wxwidgets" # for GUI apps like observer
resource "html" do
url "https://www.erlang.org/download/otp_doc_html_23.3.tar.gz"
mirror "https://fossies.org/linux/misc/otp_doc_html_23.3.tar.gz"
sha256 "03d86ac3e71bb58e27d01743a9668c7a1265b573541d4111590f0f3ec334383e"
end
def install
# Unset these so that building wx, kernel, compiler and
# other modules doesn't fail with an unintelligible error.
%w[LIBS FLAGS AFLAGS ZFLAGS].each { |k| ENV.delete("ERL_#{k}") }
args = %W[
--disable-debug
--disable-silent-rules
--prefix=#{prefix}
--enable-dynamic-ssl-lib
--enable-hipe
--enable-shared-zlib
--enable-smp-support
--enable-threads
--enable-wx
--with-ssl=#{Formula["openssl@1.1"].opt_prefix}
--without-javac
]
if OS.mac?
args << "--enable-darwin-64bit"
args << "--enable-kernel-poll" if MacOS.version > :el_capitan
args << "--with-dynamic-trace=dtrace" if MacOS::CLT.installed?
end
system "./configure", *args
system "make"
system "make", "install"
# Build the doc chunks (manpages are also built by default)
system "make", "docs", "DOC_TARGETS=chunks"
system "make", "install-docs"
doc.install resource("html")
end
def caveats
<<~EOS
Man pages can be found in:
#{opt_lib}/erlang/man
Access them with `erl -man`, or add this directory to MANPATH.
EOS
end
test do
system "#{bin}/erl", "-noshell", "-eval", "crypto:start().", "-s", "init", "stop"
(testpath/"factorial").write <<~EOS
#!#{bin}/escript
%% -*- erlang -*-
%%! -smp enable -sname factorial -mnesia debug verbose
main([String]) ->
try
N = list_to_integer(String),
F = fac(N),
io:format("factorial ~w = ~w\n", [N,F])
catch
_:_ ->
usage()
end;
main(_) ->
usage().
usage() ->
io:format("usage: factorial integer\n").
fac(0) -> 1;
fac(N) -> N * fac(N-1).
EOS
chmod 0755, "factorial"
assert_match "usage: factorial integer", shell_output("./factorial")
assert_match "factorial 42 = 1405006117752879898543142606244511569936384000000000", shell_output("./factorial 42")
end
end