Use https by default
[gentoo.git] / dev-lang / R / R-3.2.0-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit bash-completion-r1 autotools eutils flag-o-matic fortran-2 multilib versionator toolchain-funcs
8
9 BCP=${PN}-20130129.bash_completion
10 DESCRIPTION="Language and environment for statistical computing and graphics"
11 HOMEPAGE="http://www.r-project.org/"
12 SRC_URI="
13         mirror://cran/src/base/R-3/${P}.tar.gz
14         https://dev.gentoo.org/~bicatali/distfiles/${BCP}.bz2"
15
16 LICENSE="|| ( GPL-2 GPL-3 ) LGPL-2.1"
17 SLOT="0"
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 ) )"
21
22 CDEPEND="
23         app-arch/bzip2:0=
24         app-arch/xz-utils:0=
25         app-text/ghostscript-gpl
26         >=dev-libs/libpcre-8.35:3=
27         virtual/blas:0
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 )"
39
40 DEPEND="${CDEPEND}
41         virtual/pkgconfig
42         doc? (
43                 virtual/latex-base
44                 dev-texlive/texlive-fontsrecommended
45         )"
46
47 RDEPEND="${CDEPEND}
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 )"
50
51 RESTRICT="minimal? ( test )"
52
53 R_DIR="${EROOT%/}/usr/$(get_libdir)/${PN}"
54
55 pkg_setup() {
56         if use openmp; then
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"
60                 fi
61                 FORTRAN_NEED_OPENMP=1
62         fi
63         fortran-2_pkg_setup
64         filter-ldflags -Wl,-Bdirect -Bdirect
65         # avoid using existing R installation
66         unset R_HOME
67         # Temporary fix for bug #419761
68         if [[ ($(tc-getCC) == *gcc) && ($(gcc-version) == 4.7) ]]; then
69                 append-flags -fno-ipa-cp-clone
70         fi
71 }
72
73 src_prepare() {
74         epatch \
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
79
80         # fix packages.html for doc (gentoo bug #205103)
81         sed -i \
82                 -e "s:../../../library:../../../../$(get_libdir)/R/library:g" \
83                 src/library/tools/R/Rd.R || die
84
85         # fix Rscript path when installed (gentoo bug #221061)
86         sed -i \
87                 -e "s:-DR_HOME='\"\$(rhome)\"':-DR_HOME='\"${R_DIR}\"':" \
88                 src/unix/Makefile.in || die "sed unix Makefile failed"
89
90         # fix HTML links to manual (gentoo bug #273957)
91         sed -i \
92                 -e 's:\.\./manual/:manual/:g' \
93                 $(grep -Flr ../manual/ doc) || die "sed for HTML links failed"
94
95         use lapack && \
96                 export LAPACK_LIBS="$($(tc-getPKG_CONFIG) --libs lapack)"
97
98         if use X; then
99                 export R_BROWSER="$(type -p xdg-open)"
100                 export R_PDFVIEWER="$(type -p xdg-open)"
101         fi
102         use perl && \
103                 export PERL5LIB="${S}/share/perl:${PERL5LIB:+:}${PERL5LIB}"
104
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)
108         if use prefix; then
109                 if [[ ${CHOST} == *-darwin* ]] ; then
110                         sed -i \
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/" \
115                                 configure.ac || die
116                         # sort of "undo" 2.14.1-rmath-shared.patch
117                         sed -i \
118                                 -e "s:-Wl,-soname=libRmath.so:-install_name ${EROOT%/}/usr/$(get_libdir)/libRmath.dylib:" \
119                                 src/nmath/standalone/Makefile.in || die
120                 else
121                         append-ldflags -Wl,-rpath="${EROOT%/}/usr/$(get_libdir)/R/lib"
122                 fi
123         fi
124         AT_M4DIR=m4 eaclocal
125         eautoconf
126 }
127
128 src_configure() {
129         #       --with-system-tre \
130         # tre is patched from upstream
131         econf \
132                 --enable-byte-compiled-packages \
133                 --enable-R-shlib \
134                 --disable-R-framework \
135                 --with-system-zlib \
136                 --with-system-bzlib \
137                 --with-system-pcre \
138                 --with-system-xz \
139                 --with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
140                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
141                 rdocdir="${EPREFIX}/usr/share/doc/${PF}" \
142                 $(use_enable nls) \
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) \
148                 $(use_with cairo) \
149                 $(use_with icu ICU) \
150                 $(use_with jpeg jpeglib) \
151                 $(use_with lapack) \
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) \
159                 $(use_with X x)
160 }
161
162 src_compile() {
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
168 }
169
170 src_install() {
171         default
172         emake -j1 -C src/nmath/standalone DESTDIR="${D}" install
173
174         if use doc; then
175                 emake DESTDIR="${D}" install-info install-pdf
176                 dosym ../manual /usr/share/doc/${PF}/html/manual
177         fi
178
179         cat > 99R <<-EOF
180                 LDPATH=${R_DIR}/lib
181                 R_HOME=${R_DIR}
182         EOF
183         doenvd 99R
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
190                 local mod
191                 pushd "${ED}"/usr/lib/R > /dev/null
192                 for mod in $(find . -name "*.dylib") ; do
193                         mod=${mod#./}
194                         install_name_tool -id "${EPREFIX}/usr/lib/R/${mod}" \
195                                 "${mod}"
196                 done
197                 popd > /dev/null
198         fi
199         docompress -x /usr/share/doc/${PF}/NEWS.rds
200 }
201
202 pkg_postinst() {
203         if use java; then
204                 einfo "Re-initializing java paths for ${P}"
205                 R CMD javareconf
206         fi
207 }