2017-07-16 17:44:23 +00:00
|
|
|
class R < Formula
|
|
|
|
desc "Software environment for statistical computing"
|
|
|
|
homepage "https://www.r-project.org/"
|
2017-09-29 13:41:07 +00:00
|
|
|
url "https://cran.rstudio.com/src/base/R-3/R-3.4.2.tar.gz"
|
|
|
|
sha256 "971e30c2436cf645f58552905105d75788bd9733bddbcb7c4fbff4c1a6d80c64"
|
2017-07-16 17:44:23 +00:00
|
|
|
|
|
|
|
bottle do
|
2017-09-29 14:10:10 +00:00
|
|
|
sha256 "6074e19280c7002ef3e99fcc77fefc4f37c1d90f89ef2ec22e3937aaa8cf79ec" => :high_sierra
|
|
|
|
sha256 "01a3ec41728feefac6b093d943e84fb912d8b82149e5533b2287bd97ffd38378" => :sierra
|
|
|
|
sha256 "54bccc2c6410fb1b4703bd818052010bfaa6c555b6f33bb471d90fad77f5ad88" => :el_capitan
|
2017-07-16 17:44:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
depends_on "pkg-config" => :build
|
|
|
|
depends_on "gettext"
|
|
|
|
depends_on "jpeg"
|
|
|
|
depends_on "libpng"
|
|
|
|
depends_on "pcre"
|
|
|
|
depends_on "readline"
|
|
|
|
depends_on "xz"
|
|
|
|
depends_on :fortran
|
2017-07-21 14:43:28 +00:00
|
|
|
depends_on "openblas" => :optional
|
2017-07-18 09:35:34 +00:00
|
|
|
depends_on :java => :optional
|
|
|
|
|
|
|
|
# needed to preserve executable permissions on files without shebangs
|
|
|
|
skip_clean "lib/R/bin"
|
2017-07-16 17:44:23 +00:00
|
|
|
|
2017-08-18 13:44:42 +00:00
|
|
|
resource "gss" do
|
|
|
|
url "https://cloud.r-project.org/src/contrib/gss_2.1-7.tar.gz", :using => :nounzip
|
|
|
|
mirror "https://mirror.las.iastate.edu/CRAN/src/contrib/gss_2.1-7.tar.gz"
|
|
|
|
sha256 "0405bb5e4c4d60b466335e5da07be4f9570045a24aed09e7bc0640e1a00f3adb"
|
|
|
|
end
|
|
|
|
|
2017-07-16 17:44:23 +00:00
|
|
|
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",
|
2017-07-18 09:35:34 +00:00
|
|
|
"--enable-R-shlib",
|
2017-07-16 17:44:23 +00:00
|
|
|
"SED=/usr/bin/sed", # don't remember Homebrew's sed shim
|
|
|
|
]
|
|
|
|
|
|
|
|
if build.with? "openblas"
|
|
|
|
args << "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas"
|
|
|
|
ENV.append "LDFLAGS", "-L#{Formula["openblas"].opt_lib}"
|
|
|
|
else
|
|
|
|
args << "--with-blas=-framework Accelerate"
|
|
|
|
ENV.append_to_cflags "-D__ACCELERATE__" if ENV.compiler != :clang
|
|
|
|
end
|
|
|
|
|
2017-07-18 09:35:34 +00:00
|
|
|
if build.with? "java"
|
|
|
|
args << "--enable-java"
|
|
|
|
else
|
|
|
|
args << "--disable-java"
|
|
|
|
end
|
|
|
|
|
2017-07-16 17:44:23 +00:00
|
|
|
# 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
|
|
|
|
|
2017-07-18 09:35:34 +00:00
|
|
|
r_home = lib/"R"
|
|
|
|
|
2017-07-16 17:44:23 +00:00
|
|
|
# make Homebrew packages discoverable for R CMD INSTALL
|
2017-07-18 09:35:34 +00:00
|
|
|
inreplace r_home/"etc/Makeconf" do |s|
|
2017-07-16 17:44:23 +00:00
|
|
|
s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include")
|
|
|
|
s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib")
|
|
|
|
s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)")
|
|
|
|
end
|
2017-07-18 09:35:34 +00:00
|
|
|
|
|
|
|
include.install_symlink Dir[r_home/"include/*"]
|
|
|
|
lib.install_symlink Dir[r_home/"lib/*"]
|
2017-08-18 13:44:42 +00:00
|
|
|
|
|
|
|
# avoid triggering mandatory rebuilds of r when gcc is upgraded
|
|
|
|
inreplace lib/"R/etc/Makeconf", Formula["gcc"].prefix.realpath,
|
|
|
|
Formula["gcc"].opt_prefix
|
2017-07-16 17:44:23 +00:00
|
|
|
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
|
2017-07-18 09:35:34 +00:00
|
|
|
assert_equal ".dylib", shell_output("#{bin}/R CMD config DYLIB_EXT").chomp
|
2017-08-18 13:44:42 +00:00
|
|
|
|
|
|
|
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"
|
2017-07-16 17:44:23 +00:00
|
|
|
end
|
|
|
|
end
|