108 lines
3.6 KiB
Ruby
108 lines
3.6 KiB
Ruby
class R < Formula
|
|
desc "Software environment for statistical computing"
|
|
homepage "https://www.r-project.org/"
|
|
url "https://cran.r-project.org/src/base/R-4/R-4.0.4.tar.gz"
|
|
sha256 "523f27d69744a08c8f0bd5e1e6c3d89a4db29ed983388ba70963a3cd3a4a802e"
|
|
license "GPL-2.0-or-later"
|
|
|
|
livecheck do
|
|
url "https://cran.rstudio.com/banner.shtml"
|
|
regex(%r{href=(?:["']?|.*?/)R[._-]v?(\d+(?:\.\d+)+)\.t}i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_big_sur: "850201a102aa7b0ae7865b32ed27b1f252e968d93aa663929abc475394a2d21b"
|
|
sha256 big_sur: "1bf6b564592e5908384a43a78b8039a9077d2953cccb8ec7cff3aeb11961596f"
|
|
sha256 catalina: "9ac4f83c55c651d5dfb22f1b9bca3f90ac60494b226a55bb74085a454dcd8027"
|
|
sha256 mojave: "0a7797f9411a5339be8caf9e7efb0ceb283002916156e1f8a36b4ada02d60d4f"
|
|
end
|
|
|
|
depends_on "pkg-config" => :build
|
|
depends_on "gcc" # for gfortran
|
|
depends_on "gettext"
|
|
depends_on "jpeg"
|
|
depends_on "libpng"
|
|
depends_on "openblas"
|
|
depends_on "pcre2"
|
|
depends_on "readline"
|
|
depends_on "tcl-tk"
|
|
depends_on "xz"
|
|
|
|
# needed to preserve executable permissions on files without shebangs
|
|
skip_clean "lib/R/bin", "lib/R/doc"
|
|
|
|
def install
|
|
# BLAS detection fails with Xcode 12 due to missing prototype
|
|
# https://bugs.r-project.org/bugzilla/show_bug.cgi?id=18024
|
|
ENV.append "CFLAGS", "-Wno-implicit-function-declaration"
|
|
|
|
args = [
|
|
"--prefix=#{prefix}",
|
|
"--enable-memory-profiling",
|
|
"--without-cairo",
|
|
"--without-x",
|
|
"--with-tcl-config=#{Formula["tcl-tk"].opt_lib}/tclConfig.sh",
|
|
"--with-tk-config=#{Formula["tcl-tk"].opt_lib}/tkConfig.sh",
|
|
"--with-aqua",
|
|
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
|
|
"--enable-R-shlib",
|
|
"SED=/usr/bin/sed", # don't remember Homebrew's sed shim
|
|
"--disable-java",
|
|
]
|
|
|
|
# Help CRAN packages find gettext and readline
|
|
["gettext", "readline", "xz"].each do |f|
|
|
ENV.append "CPPFLAGS", "-I#{Formula[f].opt_include}"
|
|
ENV.append "LDFLAGS", "-L#{Formula[f].opt_lib}"
|
|
end
|
|
|
|
system "./configure", *args
|
|
system "make"
|
|
ENV.deparallelize do
|
|
system "make", "install"
|
|
end
|
|
|
|
cd "src/nmath/standalone" do
|
|
system "make"
|
|
ENV.deparallelize do
|
|
system "make", "install"
|
|
end
|
|
end
|
|
|
|
r_home = lib/"R"
|
|
|
|
# make Homebrew packages discoverable for R CMD INSTALL
|
|
inreplace r_home/"etc/Makeconf" do |s|
|
|
s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include")
|
|
s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib")
|
|
s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)")
|
|
end
|
|
|
|
include.install_symlink Dir[r_home/"include/*"]
|
|
lib.install_symlink Dir[r_home/"lib/*"]
|
|
|
|
# avoid triggering mandatory rebuilds of r when gcc is upgraded
|
|
inreplace lib/"R/etc/Makeconf", Formula["gcc"].prefix.realpath,
|
|
Formula["gcc"].opt_prefix
|
|
end
|
|
|
|
def post_install
|
|
short_version =
|
|
`#{bin}/Rscript -e 'cat(as.character(getRversion()[1,1:2]))'`.strip
|
|
site_library = HOMEBREW_PREFIX/"lib/R/#{short_version}/site-library"
|
|
site_library.mkpath
|
|
ln_s site_library, lib/"R/site-library"
|
|
end
|
|
|
|
test do
|
|
assert_equal "[1] 2", shell_output("#{bin}/Rscript -e 'print(1+1)'").chomp
|
|
assert_equal ".dylib", shell_output("#{bin}/R CMD config DYLIB_EXT").chomp
|
|
assert_equal "[1] \"aqua\"",
|
|
shell_output("#{bin}/Rscript -e 'library(tcltk)' -e 'tclvalue(.Tcl(\"tk windowingsystem\"))'").chomp
|
|
|
|
system bin/"Rscript", "-e", "install.packages('gss', '.', 'https://cloud.r-project.org')"
|
|
assert_predicate testpath/"gss/libs/gss.so", :exist?,
|
|
"Failed to install gss package"
|
|
end
|
|
end
|