forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr.rb
104 lines (84 loc) · 3.07 KB
/
r.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
require 'formula'
class RDownloadStrategy < SubversionDownloadStrategy
def stage
quiet_safe_system 'cp', '-r', @clone, Dir.pwd
Dir.chdir cache_filename
end
end
class R < Formula
homepage 'http://www.r-project.org/'
url 'http://cran.rstudio.com/src/base/R-3/R-3.1.0.tar.gz'
mirror 'http://cran.r-project.org/src/base/R-3/R-3.1.0.tar.gz'
sha1 'a9d13932c739cc12667c6a17fabd9361624a1708'
head do
url 'https://svn.r-project.org/R/trunk', :using => RDownloadStrategy
depends_on :tex
end
option "without-accelerate", "Build without the Accelerate framework (use Rblas)"
option 'without-check', 'Skip build-time tests (not recommended)'
option 'without-tcltk', 'Build without Tcl/Tk'
depends_on :fortran
depends_on 'readline'
depends_on 'gettext'
depends_on 'libtiff'
depends_on 'jpeg'
depends_on 'cairo'
depends_on :x11 => :recommended
depends_on 'valgrind' => :optional
depends_on 'openblas' => :optional
# This is the same script that Debian packages use.
resource 'completion' do
url 'https://rcompletion.googlecode.com/svn-history/r28/trunk/bash_completion/R', :using => :curl
version 'r28'
sha1 'af734b8624b33f2245bf88d6782bea0dc5d829a4'
end
def install
args = [
"--prefix=#{prefix}",
"--with-aqua",
"--with-libintl-prefix=#{Formula['gettext'].prefix}",
"--enable-R-framework",
]
if build.with? 'valgrind'
args << '--with-valgrind-instrumentation=2'
ENV.Og
end
if build.with? "openblas"
args << "--with-blas=-L#{Formula["openblas"].opt_lib} -lopenblas" << "--with-lapack"
elsif build.with? "accelerate"
args << "--with-blas=-framework Accelerate" << "--with-lapack"
# Fall back to Rblas without-accelerate or -openblas
end
args << '--without-tcltk' if build.without? 'tcltk'
args << '--without-x' if build.without? 'x11'
# Also add gettext include so that libintl.h can be found when installing packages.
ENV.append "CPPFLAGS", "-I#{Formula['gettext'].include}"
# Pull down recommended packages if building from HEAD.
system './tools/rsync-recommended' if build.head?
system "./configure", *args
system "make"
ENV.deparallelize # Serialized installs, please
system "make check 2>&1 | tee make-check.log" if build.with? 'check'
system "make install"
# Link binaries and manpages from the Framework
# into the normal locations
bin.mkpath
man1.mkpath
ln_s prefix+"R.framework/Resources/bin/R", bin
ln_s prefix+"R.framework/Resources/bin/Rscript", bin
ln_s prefix+"R.framework/Resources/man1/R.1", man1
ln_s prefix+"R.framework/Resources/man1/Rscript.1", man1
bash_completion.install resource('completion')
prefix.install 'make-check.log' if build.with? 'check'
end
test do
(testpath / 'test.R').write('print(1+1);')
system "r < test.R --no-save"
system "rscript test.R"
end
def caveats; <<-EOS.undent
To enable rJava support, run the following command:
R CMD javareconf JAVA_CPPFLAGS=-I/System/Library/Frameworks/JavaVM.framework/Headers
EOS
end
end