homebrew-core/Formula/r.rb

105 lines
3.1 KiB
Ruby
Raw Normal View History

class R < Formula
desc "Software environment for statistical computing"
homepage "https://www.r-project.org/"
url "https://cran.rstudio.com/src/base/R-3/R-3.4.1.tar.gz"
sha256 "02b1135d15ea969a3582caeb95594a05e830a6debcdb5b85ed2d5836a6a3fc78"
revision 1
bottle do
2017-07-18 09:48:28 +00:00
sha256 "9b96002d2a130dba0ead8984d4a76c1b057d8ef7427d6f5895f7e0c2698d86ef" => :sierra
sha256 "3d75841c3a8861ba040cb5c943133e4c3b6ceab8b6b8b9f311a5e6af6dce2bba" => :el_capitan
sha256 "bce75ad0e8e8cbacd1e2da18b9007695d7fd3e32c0eb1e77df122aca8927e16a" => :yosemite
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
depends_on "openblas" => :optional
depends_on :java => :optional
# needed to preserve executable permissions on files without shebangs
skip_clean "lib/R/bin"
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
]
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
if build.with? "java"
args << "--enable-java"
else
args << "--disable-java"
end
# 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/*"]
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
end
end