1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 inherit bash-completion-r1 autotools eutils flag-o-matic fortran-2 multilib toolchain-funcs
8 # latest git commit for R bash completion: https://github.com/deepayan/rcompletion
9 BCPV=78d6830e28ea90a046da79a9b4f70c39594bb6d6
11 DESCRIPTION="Language and environment for statistical computing and graphics"
12 HOMEPAGE="http://www.r-project.org/"
14 mirror://cran/src/base/R-3/${P}.tar.gz
15 https://raw.githubusercontent.com/deepayan/rcompletion/${BCPV}/bash_completion/R -> ${PN}-${BCPV}.bash_completion"
17 LICENSE="|| ( GPL-2 GPL-3 ) LGPL-2.1"
19 KEYWORDS="~amd64 ~arm64 ~hppa ~ia64 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos"
20 IUSE="cairo doc icu java jpeg lapack minimal nls openmp perl png prefix profile readline static-libs tiff tk X"
21 REQUIRED_USE="png? ( || ( cairo X ) ) jpeg? ( || ( cairo X ) ) tiff? ( || ( cairo X ) )"
26 app-text/ghostscript-gpl
27 >=dev-libs/libpcre-8.35:3=
31 || ( >=sys-apps/coreutils-8.15 app-misc/realpath )
32 cairo? ( x11-libs/cairo:0=[X=] x11-libs/pango:0= )
33 icu? ( dev-libs/icu:= )
34 jpeg? ( virtual/jpeg:0 )
35 lapack? ( virtual/lapack:0 )
36 perl? ( dev-lang/perl )
37 png? ( media-libs/libpng:0= )
38 readline? ( sys-libs/readline:0= )
39 tiff? ( media-libs/tiff:0= )
40 tk? ( dev-lang/tk:0= )
41 X? ( x11-libs/libXmu:0= x11-misc/xdg-utils )"
47 dev-texlive/texlive-fontsrecommended
51 >=sys-libs/zlib-1.2.5.1-r2:0[minizip]
52 java? ( >=virtual/jre-1.5 )"
54 RESTRICT="minimal? ( test )"
57 "${FILESDIR}"/${PN}-3.4.1-parallel.patch
58 "${FILESDIR}"/${PN}-3.4.1-rmath-shared.patch
62 [[ ${MERGE_TYPE} != binary ]] && use openmp && tc-check-openmp
66 if [[ ${MERGE_TYPE} != binary ]] && use openmp; then
67 if ! tc-check-openmp; then
68 ewarn "OpenMP is not available in your current selected compiler"
69 die "need openmp capable compiler"
74 filter-ldflags -Wl,-Bdirect -Bdirect
75 # avoid using existing R installation
77 # Temporary fix for bug #419761
78 if [[ ($(tc-getCC) == *gcc) && ($(gcc-version) == 4.7) ]]; then
79 append-flags -fno-ipa-cp-clone
86 # fix packages.html for doc (gentoo bug #205103)
87 sed -e "s:../../../library:../../../../$(get_libdir)/R/library:g" \
88 -i src/library/tools/R/Rd.R || die
90 # fix Rscript path when installed (gentoo bug #221061)
91 sed -e "s:-DR_HOME='\"\$(rhome)\"':-DR_HOME='\"${EROOT}/usr/$(get_libdir)/${PN}\"':" \
92 -i src/unix/Makefile.in || die "sed unix Makefile failed"
94 # fix HTML links to manual (gentoo bug #273957)
95 sed -e 's:\.\./manual/:manual/:g' \
96 -i $(grep -Flr ../manual/ doc) || die "sed for HTML links failed"
99 export LAPACK_LIBS="$($(tc-getPKG_CONFIG) --libs lapack)"
102 export R_BROWSER="$(type -p xdg-open)"
103 export R_PDFVIEWER="$(type -p xdg-open)"
106 export PERL5LIB="${S}/share/perl:${PERL5LIB:+:}${PERL5LIB}"
108 # don't search /usr/local
109 sed -i -e '/FLAGS=.*\/local\//c\: # removed by ebuild' configure.ac || die
110 # Fix for Darwin (OS X)
112 if [[ ${CHOST} == *-darwin* ]] ; then
113 sed -e 's:-install_name libR.dylib:-install_name ${libdir}/R/lib/libR.dylib:' \
114 -e 's:-install_name libRlapack.dylib:-install_name ${libdir}/R/lib/libRlapack.dylib:' \
115 -e 's:-install_name libRblas.dylib:-install_name ${libdir}/R/lib/libRblas.dylib:' \
116 -e "/SHLIB_EXT/s/\.so/.dylib/" \
117 -i configure.ac || die
118 # sort of "undo" 2.14.1-rmath-shared.patch
119 sed -e "s:-Wl,-soname=libRmath.so:-install_name ${EROOT}/usr/$(get_libdir)/libRmath.dylib:" \
120 -i src/nmath/standalone/Makefile.in || die
122 append-ldflags -Wl,-rpath="${EROOT}/usr/$(get_libdir)/R/lib"
130 # --with-system-tre \
131 # tre is patched from upstream
133 --enable-byte-compiled-packages \
135 --disable-R-framework \
136 --with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
137 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
138 rdocdir="${EPREFIX}/usr/share/doc/${PF}" \
141 $(use_enable openmp) \
142 $(use_enable profile R-profiling) \
143 $(use_enable profile memory-profiling) \
144 $(use_enable static-libs static) \
145 $(use_enable static-libs R-static-lib) \
147 $(use_with icu ICU) \
148 $(use_with jpeg jpeglib) \
150 $(use_with !minimal recommended-packages) \
151 $(use_with png libpng) \
152 $(use_with readline) \
153 $(use_with tiff libtiff) \
154 $(use_with tk tcltk) \
155 $(use_with tk tk-config "${EPREFIX}"/usr/$(get_libdir)/tkConfig.sh) \
156 $(use_with tk tcl-config "${EPREFIX}"/usr/$(get_libdir)/tclConfig.sh) \
161 export VARTEXFONTS="${T}/fonts"
162 emake AR="$(tc-getAR)"
163 emake -C src/nmath/standalone \
164 shared $(use static-libs && echo static) AR="$(tc-getAR)"
165 use doc && emake info pdf
170 emake -j1 -C src/nmath/standalone DESTDIR="${D}" install
173 emake DESTDIR="${D}" install-info install-pdf
174 dosym ../manual /usr/share/doc/${PF}/html/manual
178 LDPATH=${EROOT}/usr/$(get_libdir)/${PN}/lib
179 R_HOME=${EROOT}/usr/$(get_libdir)/${PN}
182 newbashcomp "${DISTDIR}"/${PN}-${BCPV}.bash_completion ${PN}
183 # The buildsystem has a different understanding of install_names than
184 # we require. Since it builds modules like shared objects (wrong), many
185 # objects (all modules) get an incorrect install_name. Fixing the build
186 # system here is not really trivial.
187 if [[ ${CHOST} == *-darwin* ]] ; then
189 pushd "${ED}"/usr/$(get_libdir)/R > /dev/null
190 for mod in $(find . -name "*.dylib") ; do
192 install_name_tool -id "${EPREFIX}/usr/$(get_libdir)/R/${mod}" \
197 docompress -x /usr/share/doc/${PF}/{BioC_mirrors.csv,CRAN_mirrors.csv,KEYWORDS.db,NEWS.rds}
202 einfo "Re-initializing java paths for ${P}"