2 desc "Software environment for statistical computing"
3 homepage "https://www.r-project.org/"
4 url "https://cran.r-project.org/src/base/R-3/R-3.5.3.tar.gz"
5 sha256 "2bfa37b7bd709f003d6b8a172ddfb6d03ddd2d672d6096439523039f7a8e678c"
8 root_url "https://linuxbrew.bintray.com/bottles"
9 sha256 "8d1c5161ae03b34d8ed55bd7aa60c708b196b39929cd867bf80973640915f86e" => :mojave
10 sha256 "e1d29ef3229094d533527fa8caaf1d747548b06ef03260dbda3b490f8ee85904" => :high_sierra
11 sha256 "e3da4551f917e2846fb7c887c1bffdd923fcd8abab3f035d69c592ef74d9a18a" => :sierra
12 sha256 "448ad4b364a862a39e95c515110a15725061fe52bbd354a90a08013e978d786a" => :x86_64_linux
15 depends_on "pkg-config" => :build
16 depends_on "gcc" # for gfortran
28 depends_on "linuxbrew/xorg/xorg"
31 # needed to preserve executable permissions on files without shebangs
32 skip_clean "lib/R/bin"
35 url "https://cloud.r-project.org/src/contrib/gss_2.1-9.tar.gz", :using => :nounzip
36 mirror "https://mirror.las.iastate.edu/CRAN/src/contrib/gss_2.1-9.tar.gz"
37 sha256 "2961fe61c1d3bb3fe7b8e1070d6fb1dfc5d71e0c6e8a6b7c46ff6b42867c4cf3"
41 # Fix dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
42 if MacOS.version == "10.11" && MacOS::Xcode.installed? &&
43 MacOS::Xcode.version >= "8.0"
44 ENV["ac_cv_have_decl_clock_gettime"] = "no"
49 "--enable-memory-profiling",
53 "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
56 # don't remember Homebrew's sed shim
57 args << "SED=/usr/bin/sed" if File.exist?("/usr/bin/sed")
60 args << "--libdir=#{lib}" # avoid using lib64 on CentOS
61 args << "--with-cairo"
63 # If LDFLAGS contains any -L options, configure sets LD_LIBRARY_PATH to
64 # search those directories. Remove -LHOMEBREW_PREFIX/lib from LDFLAGS.
65 ENV.remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
68 # Help CRAN packages find gettext and readline
69 ["gettext", "readline"].each do |f|
70 ENV.append "CPPFLAGS", "-I#{Formula[f].opt_include}"
71 ENV.append "LDFLAGS", "-L#{Formula[f].opt_lib}"
74 system "./configure", *args
77 system "make", "install"
80 cd "src/nmath/standalone" do
83 system "make", "install"
89 # make Homebrew packages discoverable for R CMD INSTALL
90 inreplace r_home/"etc/Makeconf" do |s|
91 s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include")
92 s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib")
93 s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)")
96 include.install_symlink Dir[r_home/"include/*"]
97 lib.install_symlink Dir[r_home/"lib/*"]
99 # avoid triggering mandatory rebuilds of r when gcc is upgraded
100 inreplace lib/"R/etc/Makeconf",
101 Formula["gcc"].prefix.realpath,
102 Formula["gcc"].opt_prefix,
108 `#{bin}/Rscript -e 'cat(as.character(getRversion()[1,1:2]))'`.strip
109 site_library = HOMEBREW_PREFIX/"lib/R/#{short_version}/site-library"
111 ln_s site_library, lib/"R/site-library"
115 dylib_ext = OS.mac? ? ".dylib" : ".so"
116 assert_equal "[1] 2", shell_output("#{bin}/Rscript -e 'print(1+1)'").chomp
117 assert_equal dylib_ext, shell_output("#{bin}/R CMD config DYLIB_EXT").chomp
119 testpath.install resource("gss")
120 system bin/"R", "CMD", "INSTALL", "--library=.", Dir["gss*"].first
121 assert_predicate testpath/"gss/libs/gss.so", :exist?,
122 "Failed to install gss package"