1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit bash-completion-r1 autotools eutils flag-o-matic fortran-2 multilib versionator toolchain-funcs
9 BCP=${PN}-20130129.bash_completion
10 DESCRIPTION="Language and environment for statistical computing and graphics"
11 HOMEPAGE="http://www.r-project.org/"
13 mirror://cran/src/base/R-3/${P}.tar.gz
14 https://dev.gentoo.org/~bicatali/distfiles/${BCP}.bz2"
16 LICENSE="|| ( GPL-2 GPL-3 ) LGPL-2.1"
18 KEYWORDS="~amd64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux ~x64-macos"
19 IUSE="cairo doc icu java jpeg lapack minimal nls openmp perl png prefix profile readline static-libs tiff tk X"
20 REQUIRED_USE="png? ( || ( cairo X ) ) jpeg? ( || ( cairo X ) ) tiff? ( || ( cairo X ) )"
25 app-text/ghostscript-gpl
26 >=dev-libs/libpcre-8.35:3=
28 || ( >=sys-apps/coreutils-8.15 sys-freebsd/freebsd-bin app-misc/realpath )
29 cairo? ( x11-libs/cairo:0=[X] x11-libs/pango:0= )
30 icu? ( dev-libs/icu:= )
31 jpeg? ( virtual/jpeg:0 )
32 lapack? ( virtual/lapack:0 )
33 perl? ( dev-lang/perl )
34 png? ( media-libs/libpng:0= )
35 readline? ( sys-libs/readline:0= )
36 tiff? ( media-libs/tiff:0= )
37 tk? ( dev-lang/tk:0= )
38 X? ( x11-libs/libXmu:0= x11-misc/xdg-utils )"
44 dev-texlive/texlive-fontsrecommended
48 ( || ( <sys-libs/zlib-1.2.5.1-r1:0 >=sys-libs/zlib-1.2.5.1-r2:0[minizip] ) )
49 java? ( >=virtual/jre-1.5 )"
51 RESTRICT="minimal? ( test )"
53 R_DIR="${EROOT%/}/usr/$(get_libdir)/${PN}"
57 if [[ $(tc-getCC) == *gcc ]] && ! tc-has-openmp; then
58 ewarn "OpenMP is not available in your current selected gcc"
59 die "need openmp capable gcc"
64 filter-ldflags -Wl,-Bdirect -Bdirect
65 # avoid using existing R installation
67 # Temporary fix for bug #419761
68 if [[ ($(tc-getCC) == *gcc) && ($(gcc-version) == 4.7) ]]; then
69 append-flags -fno-ipa-cp-clone
75 "${FILESDIR}"/${PN}-2.11.1-parallel.patch \
76 "${FILESDIR}"/${PN}-2.13.1-zlib_header_fix.patch \
77 "${FILESDIR}"/${PN}-3.0.0-rmath-shared.patch \
78 "${FILESDIR}"/${PN}-3.2.0-omitted-extern-R_running_as_main_program.patch
80 # fix packages.html for doc (gentoo bug #205103)
82 -e "s:../../../library:../../../../$(get_libdir)/R/library:g" \
83 src/library/tools/R/Rd.R || die
85 # fix Rscript path when installed (gentoo bug #221061)
87 -e "s:-DR_HOME='\"\$(rhome)\"':-DR_HOME='\"${R_DIR}\"':" \
88 src/unix/Makefile.in || die "sed unix Makefile failed"
90 # fix HTML links to manual (gentoo bug #273957)
92 -e 's:\.\./manual/:manual/:g' \
93 $(grep -Flr ../manual/ doc) || die "sed for HTML links failed"
96 export LAPACK_LIBS="$($(tc-getPKG_CONFIG) --libs lapack)"
99 export R_BROWSER="$(type -p xdg-open)"
100 export R_PDFVIEWER="$(type -p xdg-open)"
103 export PERL5LIB="${S}/share/perl:${PERL5LIB:+:}${PERL5LIB}"
105 # don't search /usr/local
106 sed -i -e '/FLAGS=.*\/local\//c\: # removed by ebuild' configure.ac || die
107 # Fix for Darwin (OS X)
109 if [[ ${CHOST} == *-darwin* ]] ; then
111 -e 's:-install_name libR.dylib:-install_name ${libdir}/R/lib/libR.dylib:' \
112 -e 's:-install_name libRlapack.dylib:-install_name ${libdir}/R/lib/libRlapack.dylib:' \
113 -e 's:-install_name libRblas.dylib:-install_name ${libdir}/R/lib/libRblas.dylib:' \
114 -e "/SHLIB_EXT/s/\.so/.dylib/" \
116 # sort of "undo" 2.14.1-rmath-shared.patch
118 -e "s:-Wl,-soname=libRmath.so:-install_name ${EROOT%/}/usr/$(get_libdir)/libRmath.dylib:" \
119 src/nmath/standalone/Makefile.in || die
121 append-ldflags -Wl,-rpath="${EROOT%/}/usr/$(get_libdir)/R/lib"
129 # --with-system-tre \
130 # tre is patched from upstream
132 --enable-byte-compiled-packages \
134 --disable-R-framework \
136 --with-system-bzlib \
139 --with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
140 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
141 rdocdir="${EPREFIX}/usr/share/doc/${PF}" \
143 $(use_enable openmp) \
144 $(use_enable profile R-profiling) \
145 $(use_enable profile memory-profiling) \
146 $(use_enable static-libs static) \
147 $(use_enable static-libs R-static-lib) \
149 $(use_with icu ICU) \
150 $(use_with jpeg jpeglib) \
152 $(use_with !minimal recommended-packages) \
153 $(use_with png libpng) \
154 $(use_with readline) \
155 $(use_with tiff libtiff) \
156 $(use_with tk tcltk) \
157 $(use_with tk tk-config "${EPREFIX}"/usr/lib/tkConfig.sh) \
158 $(use_with tk tcl-config "${EPREFIX}"/usr/lib/tclConfig.sh) \
163 export VARTEXFONTS="${T}/fonts"
164 emake AR="$(tc-getAR)"
165 emake -C src/nmath/standalone \
166 shared $(use static-libs && echo static) AR="$(tc-getAR)"
167 use doc && emake info pdf
172 emake -j1 -C src/nmath/standalone DESTDIR="${D}" install
175 emake DESTDIR="${D}" install-info install-pdf
176 dosym ../manual /usr/share/doc/${PF}/html/manual
184 newbashcomp "${WORKDIR}"/${BCP} ${PN}
185 # The buildsystem has a different understanding of install_names than
186 # we require. Since it builds modules like shared objects (wrong), many
187 # objects (all modules) get an incorrect install_name. Fixing the build
188 # system here is not really trivial.
189 if [[ ${CHOST} == *-darwin* ]] ; then
191 pushd "${ED}"/usr/lib/R > /dev/null
192 for mod in $(find . -name "*.dylib") ; do
194 install_name_tool -id "${EPREFIX}/usr/lib/R/${mod}" \
199 docompress -x /usr/share/doc/${PF}/NEWS.rds
204 einfo "Re-initializing java paths for ${P}"