├── README.md └── Formula └── r@3.6.3.rb /README.md: -------------------------------------------------------------------------------- 1 | # My Homebrew tap 2 | -------------------------------------------------------------------------------- /Formula/r@3.6.3.rb: -------------------------------------------------------------------------------- 1 | class RAT363 < Formula 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.6.3.tar.gz" 5 | sha256 "89302990d8e8add536e12125ec591d6951022cf8475861b3690bc8bf1cefaa8f" 6 | revision 2 7 | 8 | bottle do 9 | sha256 "c05a51529bae3464274f9648f70fcc36e3d0fef06209bb77255095b7fb784290" => :catalina 10 | sha256 "c6d4210a241f9466804d5660b467afb6f59d2150e43288b1c66e47387ff43f6e" => :mojave 11 | sha256 "c729bce5fcd925da95a67d862065af7cd99a517c4b0ceef9460766a46ca2701e" => :high_sierra 12 | end 13 | 14 | depends_on "pkg-config" => :build 15 | depends_on "gcc" # for gfortran 16 | depends_on "gettext" 17 | depends_on "jpeg" 18 | depends_on "libpng" 19 | depends_on "openblas" 20 | depends_on "pcre" 21 | depends_on "readline" 22 | depends_on "xz" 23 | 24 | # needed to preserve executable permissions on files without shebangs 25 | skip_clean "lib/R/bin", "lib/R/doc" 26 | 27 | resource "gss" do 28 | url "https://cloud.r-project.org/src/contrib/gss_2.1-12.tar.gz", :using => :nounzip 29 | mirror "https://mirror.las.iastate.edu/CRAN/src/contrib/gss_2.1-12.tar.gz" 30 | sha256 "bcc92bb621671dbf94684e11a0b1c2b6c423f57d7d4ed8c7eeba4f4e51ef170b" 31 | end 32 | 33 | def install 34 | # Fix dyld: lazy symbol binding failed: Symbol not found: _clock_gettime 35 | if MacOS.version == "10.11" && MacOS::Xcode.installed? && 36 | MacOS::Xcode.version >= "8.0" 37 | ENV["ac_cv_have_decl_clock_gettime"] = "no" 38 | end 39 | 40 | args = [ 41 | "--prefix=#{prefix}", 42 | "--enable-memory-profiling", 43 | "--without-cairo", 44 | "--without-tcltk", 45 | "--without-x", 46 | "--with-aqua", 47 | "--with-lapack", 48 | "--enable-R-shlib", 49 | "SED=/usr/bin/sed", # don't remember Homebrew's sed shim 50 | "--disable-java", 51 | "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas", 52 | ] 53 | 54 | # Help CRAN packages find gettext and readline 55 | ["gettext", "readline"].each do |f| 56 | ENV.append "CPPFLAGS", "-I#{Formula[f].opt_include}" 57 | ENV.append "LDFLAGS", "-L#{Formula[f].opt_lib}" 58 | end 59 | 60 | system "./configure", *args 61 | system "make" 62 | ENV.deparallelize do 63 | system "make", "install" 64 | end 65 | 66 | cd "src/nmath/standalone" do 67 | system "make" 68 | ENV.deparallelize do 69 | system "make", "install" 70 | end 71 | end 72 | 73 | r_home = lib/"R" 74 | 75 | # make Homebrew packages discoverable for R CMD INSTALL 76 | inreplace r_home/"etc/Makeconf" do |s| 77 | s.gsub!(/^CPPFLAGS =.*/, "\\0 -I#{HOMEBREW_PREFIX}/include") 78 | s.gsub!(/^LDFLAGS =.*/, "\\0 -L#{HOMEBREW_PREFIX}/lib") 79 | s.gsub!(/.LDFLAGS =.*/, "\\0 $(LDFLAGS)") 80 | end 81 | 82 | include.install_symlink Dir[r_home/"include/*"] 83 | lib.install_symlink Dir[r_home/"lib/*"] 84 | 85 | # avoid triggering mandatory rebuilds of r when gcc is upgraded 86 | inreplace lib/"R/etc/Makeconf", Formula["gcc"].prefix.realpath, 87 | Formula["gcc"].opt_prefix 88 | end 89 | 90 | def post_install 91 | short_version = 92 | `#{bin}/Rscript -e 'cat(as.character(getRversion()[1,1:2]))'`.strip 93 | site_library = HOMEBREW_PREFIX/"lib/R/#{short_version}/site-library" 94 | site_library.mkpath 95 | ln_s site_library, lib/"R/site-library" 96 | end 97 | 98 | test do 99 | assert_equal "[1] 2", shell_output("#{bin}/Rscript -e 'print(1+1)'").chomp 100 | assert_equal ".dylib", shell_output("#{bin}/R CMD config DYLIB_EXT").chomp 101 | 102 | testpath.install resource("gss") 103 | system bin/"R", "CMD", "INSTALL", "--library=.", Dir["gss*"].first 104 | assert_predicate testpath/"gss/libs/gss.so", :exist?, 105 | "Failed to install gss package" 106 | end 107 | end 108 | --------------------------------------------------------------------------------