Ticket #30385: Portfile

File Portfile, 7.7 KB (added by kjell.konis@…, 13 years ago)

Updated Portfile to latest version of R

Line 
1# $Id: $
2
3PortSystem 1.0
4
5set major 2
6set minor 13
7set point 2
8
9name                        R-framework
10conflicts                   R
11version                     ${major}.${minor}.${point}
12categories                  math science
13maintainers                 epfl.ch:kjell.konis
14license                     GPL-2 GPL-3
15platforms                   macosx
16
17description \
18    R is GNU S - an interpreted language for statistical computing
19
20long_description \
21    R is a language and environment for statistical computing and graphics. \
22    R provides a wide variety of statistical (linear and nonlinear modeling, \
23    classical statistical tests, time-series analysis, classification, \
24    clustering, ...) and graphical techniques, and is highly extensible.
25
26homepage                    http://www.r-project.org/
27
28master_sites                http://cran.us.r-project.org/src/base/R-2/ \
29                            http://cran.ms.unimelb.edu.au/src/base/R-2/ \
30                            http://cran.at.r-project.org/src/base/R-2/ \
31                            http://cran.hu.r-project.org/src/base/R-2/ \
32                            http://cran.r-project.org/src/base/R-2/
33
34distname                    R-${version}
35dist_subdir                 R
36
37checksums                   rmd160  ea6ea24215c50fcf83c99fd59a676cdc90de30c1 \
38                            sha256  a1c8733030636c86efa23f6f22dd673a0a54d0fedcffcc8c8deb03da8f972330
39
40depends_build               port:pkgconfig
41
42depends_lib                 port:llvm-gcc42 \
43                            port:readline \
44                            port:icu \
45                            port:libiconv
46
47universal_variant           no
48
49set resources ${frameworks_dir}/R.framework/Versions/${major}.${minor}/Resources
50
51post-patch {
52    reinplace "s|R_HOME|\"${resources}\"|" "${worksrcpath}/src/unix/Rscript.c"
53}
54
55configure.env-append        r_arch=${build_arch}
56
57configure.compiler          macports-llvm-gcc-4.2
58configure.ldflags-append    -L${prefix}/lib/llvm-gcc42 -lgfortran
59
60configure.pre_args-delete   --prefix=${prefix}
61configure.pre_args-append   --prefix=${frameworks_dir}
62
63configure.args              --enable-R-framework \
64                            --enable-R-shlib \
65                            --enable-BLAS-shlib \
66                            --enable-openmp \
67                            --with-blas="-framework vecLib" \
68                            --with-lapack="-framework vecLib" \
69                            --with-readline \
70                            --with-aqua \
71                            --without-tcltk \
72                            --without-cairo \
73                            --with-libpng \
74                            --without-jpeglib \
75                            --without-recommended-packages \
76                            --with-ICU \
77                            --without-x \
78                            --with-included-gettext
79
80variant cairo requires x11 description {Use cairo and pango} {
81    depends_lib-append      path:lib/pkgconfig/cairo.pc:cairo \
82                            path:lib/pkgconfig/pango.pc:pango \
83                            path:lib/pkgconfig/glib-2.0.pc:glib2 \
84                            port:freetype \
85                            port:fontconfig \
86                            port:gettext
87    configure.args-delete   --without-cairo
88    configure.args-append   --with-cairo
89}
90
91variant recommended description {Install recommended R packages} {
92    configure.args-delete   --without-recommended-packages
93    configure.args-append   --with-recommended-packages
94}
95
96variant tcltk requires x11 description {Use tcltk} {
97    depends_lib-append      port:tcl \
98                            port:tk \
99                            port:xorg-libXScrnSaver \
100                            port:xorg-libXext
101    configure.args-delete   --without-tcltk
102    configure.args-append   --with-tcltk \
103                            --with-tcl-config=${prefix}/lib/tclConfig.sh \
104                            --with-tk-config=${prefix}/lib/tkConfig.sh
105}
106
107variant x11 description {Use the X Window System} {
108    depends_lib-append      port:xorg-libsm \
109                            port:xorg-libice \
110                            port:xorg-libX11 \
111                            port:xorg-libXt \
112                            port:tiff \
113                            port:jpeg \
114                            port:libpng \
115                            port:zlib
116    configure.args-delete   --without-x \
117                            --without-jpeglib
118    configure.args-append   --with-x \
119                            --with-jpeglib \
120                            --x-include=${prefix}/include/X11 \
121                            --x-lib=${prefix}/lib
122}
123
124default_variants +cairo +recommended +tcltk +x11
125
126destroot.destdir prefix=${destroot}${frameworks_dir}
127
128post-destroot {
129    move ${destroot}${frameworks_dir}/lib/pkgconfig/libR.pc ${destroot}${prefix}/lib/pkgconfig/libR.pc
130
131    foreach v { "rhome" "rincludedir" } {
132        reinplace "s|${v}=${destroot}|${v}=|" "${destroot}${prefix}/lib/pkgconfig/libR.pc"
133    }
134
135    foreach dir { "R_HOME_DIR" "R_SHARE_DIR" "R_INCLUDE_DIR" "R_DOC_DIR" } {
136        reinplace "s|${dir}=${destroot}|${dir}=|" "${destroot}${resources}/bin/R"
137    }
138
139    reinplace "s|R_ARCH=/`arch`|R_ARCH=/${build_arch}|" "${destroot}${resources}/bin/R"
140    reinplace "s|-F${destroot}|-F|" "${destroot}${resources}/etc/${build_arch}/Makeconf"
141
142    file delete ${destroot}${resources}/lib/libR.dylib
143    file delete ${destroot}${resources}/lib/libRblas.dylib
144    file delete ${destroot}${resources}/lib/libRlapack.dylib
145
146    foreach dylib [ exec find ${destroot}${frameworks_dir}/R.framework -name "\*.dylib" ] {
147        regsub ":$" ${dylib} "" destroot_dylib_path
148        regsub ${destroot} ${destroot_dylib_path} "" dylib_path
149        system "install_name_tool -id ${dylib_path} ${destroot_dylib_path}"
150        system "install_name_tool -change ${destroot}${resources}/lib/libR.dylib ${resources}/lib/${build_arch}/libR.dylib \
151            ${destroot_dylib_path}"
152        system "install_name_tool -change ${destroot}${resources}/lib/libRblas.dylib ${resources}/lib/${build_arch}/libRblas.dylib \
153            ${destroot_dylib_path}"
154        system "install_name_tool -change ${destroot}${resources}/lib/libRlapack.dylib ${resources}/lib/${build_arch}/libRlapack.dylib \
155            ${destroot_dylib_path}"
156    }
157
158    foreach so [ exec find ${destroot}${frameworks_dir}/R.framework -name "\*.so" ] {
159        regsub ":$" ${so} "" destroot_so_path
160        regsub ${destroot} ${destroot_so_path} "" so_path
161        system "install_name_tool -id ${so_path} ${destroot_so_path}"
162        system "install_name_tool -change ${destroot}${resources}/lib/libR.dylib ${resources}/lib/${build_arch}/libR.dylib \
163            ${destroot_so_path}"
164        system "install_name_tool -change ${destroot}${resources}/lib/libRblas.dylib ${resources}/lib/${build_arch}/libRblas.dylib \
165            ${destroot_so_path}"
166        system "install_name_tool -change ${destroot}${resources}/lib/libRlapack.dylib ${resources}/lib/${build_arch}/libRlapack.dylib \
167            ${destroot_so_path}"
168    }
169
170    system "install_name_tool -change ${destroot}${resources}/lib/libR.dylib ${resources}/lib/${build_arch}/libR.dylib \
171        ${destroot}${resources}/bin/exec/${build_arch}/R"
172    system "install_name_tool -change ${destroot}${resources}/lib/libRblas.dylib ${resources}/lib/${build_arch}/libRblas.dylib \
173        ${destroot}${resources}/bin/exec/${build_arch}/R"
174
175    ln -s ${build_arch}/libR.dylib ${destroot}${resources}/lib/libR.dylib
176    ln -s ${build_arch}/libRblas.dylib ${destroot}${resources}/lib/libRblas.dylib
177    ln -s ${build_arch}/libRlapack.dylib ${destroot}${resources}/lib/libRlapack.dylib
178
179    ln -s ${resources}/bin/R ${destroot}${prefix}/bin/R
180    ln -s ${resources}/bin/Rscript ${destroot}${prefix}/bin/Rscript
181}
182
183
184