homebrew-core/Formula/perl.rb

89 lines
2.9 KiB
Ruby

class Perl < Formula
desc "Highly capable, feature-rich programming language"
homepage "https://www.perl.org/"
url "https://www.cpan.org/src/5.0/perl-5.32.1.tar.xz"
sha256 "57cc47c735c8300a8ce2fa0643507b44c4ae59012bfdad0121313db639e02309"
license any_of: ["Artistic-1.0-Perl", "GPL-1.0-or-later"]
revision 1
head "https://github.com/perl/perl5.git", branch: "blead"
livecheck do
url "https://www.cpan.org/src/"
regex(/href=.*?perl[._-]v?(\d+\.\d*[02468](?:\.\d+)*)\.t/i)
end
bottle do
sha256 arm64_big_sur: "900ac321ecfc07d89588b203a6860fe3f3ba056a3565225d77115c99d651aed0"
sha256 big_sur: "5178a634bfb37437ee40d836c3bacb1adb89516a553ef6a8c2d40cee9eea608b"
sha256 catalina: "7ac87157d98223abcc2b25e35811c9dfd016f807454ec8fc219a910b4a9cdacc"
sha256 mojave: "2663e8ce52b4fb4fab170e19fff638e0b65688a933a3cddd86696403323be88d"
end
depends_on "berkeley-db"
depends_on "gdbm"
uses_from_macos "expat"
# Prevent site_perl directories from being removed
skip_clean "lib/perl5/site_perl"
def install
args = %W[
-des
-Dprefix=#{prefix}
-Dprivlib=#{lib}/perl5/#{version}
-Dsitelib=#{lib}/perl5/site_perl/#{version}
-Dotherlibdirs=#{HOMEBREW_PREFIX}/lib/perl5/site_perl/#{version}
-Dperlpath=#{opt_bin}/perl
-Dstartperl=#!#{opt_bin}/perl
-Dman1dir=#{man1}
-Dman3dir=#{man3}
-Duseshrplib
-Duselargefiles
-Dusethreads
]
on_macos do
args << "-Dsed=/usr/bin/sed"
end
args << "-Dusedevel" if build.head?
system "./Configure", *args
system "make"
system "make", "install"
end
def post_install
on_linux do
perl_archlib = Utils.safe_popen_read("perl", "-MConfig", "-e", "print $Config{archlib}")
perl_core = Pathname.new(perl_archlib)/"CORE"
if File.readlines("#{perl_core}/perl.h").grep(/include <xlocale.h>/).any? &&
(OS::Linux::Glibc.system_version >= "2.26" ||
(Formula["glibc"].any_version_installed? && Formula["glibc"].version >= "2.26"))
# Glibc does not provide the xlocale.h file since version 2.26
# Patch the perl.h file to be able to use perl on newer versions.
# locale.h includes xlocale.h if the latter one exists
inreplace "#{perl_core}/perl.h", "include <xlocale.h>", "include <locale.h>"
end
end
end
def caveats
<<~EOS
By default non-brewed cpan modules are installed to the Cellar. If you wish
for your modules to persist across updates we recommend using `local::lib`.
You can set that up like this:
PERL_MM_OPT="INSTALL_BASE=$HOME/perl5" cpan local::lib
echo 'eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib=$HOME/perl5)"' >> #{shell_profile}
EOS
end
test do
(testpath/"test.pl").write "print 'Perl is not an acronym, but JAPH is a Perl acronym!';"
system "#{bin}/perl", "test.pl"
end
end