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 depends_on "pkg-config" => :build
9 depends_on "gcc" # for gfortran
17 depends_on :java => :optional
23 depends_on "linuxbrew/xorg/xorg"
25 depends_on "openblas" => :optional
28 # needed to preserve executable permissions on files without shebangs
29 skip_clean "lib/R/bin"
32 url "https://cloud.r-project.org/src/contrib/gss_2.1-9.tar.gz", :using => :nounzip
33 mirror "https://mirror.las.iastate.edu/CRAN/src/contrib/gss_2.1-9.tar.gz"
34 sha256 "2961fe61c1d3bb3fe7b8e1070d6fb1dfc5d71e0c6e8a6b7c46ff6b42867c4cf3"
38 # Fix dyld: lazy symbol binding failed: Symbol not found: _clock_gettime
39 if MacOS.version == "10.11" && MacOS::Xcode.installed? &&
40 MacOS::Xcode.version >= "8.0"
41 ENV["ac_cv_have_decl_clock_gettime"] = "no"
46 "--enable-memory-profiling",
50 #"--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas",
54 # don't remember Homebrew's sed shim
55 args << "SED=/usr/bin/sed" if File.exist?("/usr/bin/sed")
58 args << "--libdir=#{lib}" # avoid using lib64 on CentOS
59 #args << "--with-cairo"
61 # If LDFLAGS contains any -L options, configure sets LD_LIBRARY_PATH to
62 # search those directories. Remove -LHOMEBREW_PREFIX/lib from LDFLAGS.
63 ENV.remove "LDFLAGS", "-L#{HOMEBREW_PREFIX}/lib"
65 args << "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas"
66 #ENV.append "LDFLAGS", "-L#{Formula["openblas"].opt_lib}"
68 #args << "--with-cairo"
69 # https://github.com/Homebrew/homebrew-core/pull/24094/commits/22d0eeaae2f05c1a6b671728d88572b0fe8aa5ae
70 # Fix cairo detection with Quartz-only cairo
71 inreplace ["configure", "m4/cairo.m4"], "cairo-xlib.h", "cairo.h"
73 #args << "--without-cairo"
77 if build.with? "openblas"
78 args << "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas"
80 args << "--with-blas=-framework Accelerate"
81 ENV.append_to_cflags "-D__ACCELERATE__" if ENV.compiler != :clang
86 args << "--enable-java"
88 args << "--disable-java"
91 # Help CRAN packages find gettext and readline
92 ["gettext", "readline"].each do |f|
93 ENV.append "CPPFLAGS", "-I#{Formula[f].opt_include}"
94 ENV.append "LDFLAGS", "-L#{Formula[f].opt_lib}"
97 system "./configure", *args
100 system "make", "install"
103 cd "src/nmath/standalone" do
106 system "make", "install"
112 # make Homebrew packages discoverable for R CMD INSTALL
113 inreplace r_home/"etc/Makeconf" do |s|
114 s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include")
115 s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib")
116 s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)")
119 include.install_symlink Dir[r_home/"include/*"]
120 lib.install_symlink Dir[r_home/"lib/*"]
122 # avoid triggering mandatory rebuilds of r when gcc is upgraded
123 inreplace lib/"R/etc/Makeconf",
124 Formula["gcc"].prefix.realpath,
125 Formula["gcc"].opt_prefix,
131 `#{bin}/Rscript -e 'cat(as.character(getRversion()[1,1:2]))'`.strip
132 site_library = HOMEBREW_PREFIX/"lib/R/#{short_version}/site-library"
134 ln_s site_library, lib/"R/site-library"
138 dylib_ext = OS.mac? ? ".dylib" : ".so"
139 assert_equal "[1] 2", shell_output("#{bin}/Rscript -e 'print(1+1)'").chomp
140 assert_equal dylib_ext, shell_output("#{bin}/R CMD config DYLIB_EXT").chomp
142 testpath.install resource("gss")
143 system bin/"R", "CMD", "INSTALL", "--library=.", Dir["gss*"].first
144 assert_predicate testpath/"gss/libs/gss.so", :exist?,
145 "Failed to install gss package"