106 lines
3.4 KiB
Ruby
106 lines
3.4 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-3/R-3.6.0.tar.gz"
|
|
sha256 "36fcac3e452666158e62459c6fc810adc247c7109ed71c5b6c3ad5fc2bf57509"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "cc0bcd96d5baf4e79e5e719f8378ee53336cd2d2e1d389e9d01ada6c75fb8f16" => :mojave
|
|
sha256 "5bbacfd1b67f1e35a133fcdad48c6e4bb4d4ea2d52522e1cdd8538a0d37f17a7" => :high_sierra
|
|
sha256 "df39c323a3e7a97758a2f4a606c2411abd9ceed108eddd88a8e86345fd1f9d26" => :sierra
|
|
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 "pcre"
|
|
depends_on "readline"
|
|
depends_on "xz"
|
|
|
|
# needed to preserve executable permissions on files without shebangs
|
|
skip_clean "lib/R/bin"
|
|
|
|
resource "gss" do
|
|
url "https://cloud.r-project.org/src/contrib/gss_2.1-9.tar.gz", :using => :nounzip
|
|
mirror "https://mirror.las.iastate.edu/CRAN/src/contrib/gss_2.1-9.tar.gz"
|
|
sha256 "2961fe61c1d3bb3fe7b8e1070d6fb1dfc5d71e0c6e8a6b7c46ff6b42867c4cf3"
|
|
end
|
|
|
|
def install
|
|
# Fix dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
|
|
if MacOS.version == "10.11" && MacOS::Xcode.installed? &&
|
|
MacOS::Xcode.version >= "8.0"
|
|
ENV["ac_cv_have_decl_clock_gettime"] = "no"
|
|
end
|
|
|
|
args = [
|
|
"--prefix=#{prefix}",
|
|
"--enable-memory-profiling",
|
|
"--without-cairo",
|
|
"--without-x",
|
|
"--with-aqua",
|
|
"--with-lapack",
|
|
"--enable-R-shlib",
|
|
"SED=/usr/bin/sed", # don't remember Homebrew's sed shim
|
|
"--disable-java",
|
|
"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
|
|
]
|
|
|
|
# Help CRAN packages find gettext and readline
|
|
["gettext", "readline"].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
|
|
|
|
testpath.install resource("gss")
|
|
system bin/"R", "CMD", "INSTALL", "--library=.", Dir["gss*"].first
|
|
assert_predicate testpath/"gss/libs/gss.so", :exist?,
|
|
"Failed to install gss package"
|
|
end
|
|
end
|