116 lines
3.7 KiB
Ruby
116 lines
3.7 KiB
Ruby
class Erlang < 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-24.0.5/otp_src_24.0.5.tar.gz"
|
|
sha256 "a5fec674b11d0a2b888963157a9de60fc384be27ff1a2175cd20708a5b9aa97d"
|
|
license "Apache-2.0"
|
|
|
|
livecheck do
|
|
url :stable
|
|
regex(/^OTP[._-]v?(\d+(?:\.\d+)+)$/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "c24a800044ebc42d8844b4e31b81000a0ee07f7109fb76983134d00adfdc271a"
|
|
sha256 cellar: :any, big_sur: "7795a804b581ad2e0685ecc3b3897d5ac332992bd48b7cad5548da2d45a98c61"
|
|
sha256 cellar: :any, catalina: "199e559ec28f6e0d636b36b1c06048b92ed0ba2b5cb3c69dd697dfca139f2818"
|
|
sha256 cellar: :any, mojave: "e44aefc02d6b38885ffa8069f9fcf9cfb4ed09bb5bf9f07772ff2504de809101"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "224deed75379d5e2913a16c406e4b93869eb11516c47f3e28dd739f27edd5d9f"
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/erlang/otp.git"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
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_24.0.tar.gz"
|
|
mirror "https://fossies.org/linux/misc/otp_doc_html_24.0.tar.gz"
|
|
sha256 "6ceaa2cec97fa5a631779544a3c59afe9e146084e560725b823c476035716e73"
|
|
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}") }
|
|
|
|
# Do this if building from a checkout to generate configure
|
|
system "./otp_build", "autoconf" unless File.exist? "configure"
|
|
|
|
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
|