Use https by default
[gentoo.git] / dev-lang / R / R-3.2.2.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
79         # fix packages.html for doc (gentoo bug #205103)
80         sed -i \
81                 -e "s:../../../library:../../../../$(get_libdir)/R/library:g" \
82                 src/library/tools/R/Rd.R || die
83
84         # fix Rscript path when installed (gentoo bug #221061)
85         sed -i \
86                 -e "s:-DR_HOME='\"\$(rhome)\"':-DR_HOME='\"${R_DIR}\"':" \
87                 src/unix/Makefile.in || die "sed unix Makefile failed"
88
89         # fix HTML links to manual (gentoo bug #273957)
90         sed -i \
91                 -e 's:\.\./manual/:manual/:g' \
92                 $(grep -Flr ../manual/ doc) || die "sed for HTML links failed"
93
94         use lapack && \
95                 export LAPACK_LIBS="$($(tc-getPKG_CONFIG) --libs lapack)"
96
97         if use X; then
98                 export R_BROWSER="$(type -p xdg-open)"
99                 export R_PDFVIEWER="$(type -p xdg-open)"
100         fi
101         use perl && \
102                 export PERL5LIB="${S}/share/perl:${PERL5LIB:+:}${PERL5LIB}"
103
104         # don't search /usr/local
105         sed -i -e '/FLAGS=.*\/local\//c\: # removed by ebuild' configure.ac || die
106         # Fix for Darwin (OS X)
107         if use prefix; then
108                 if [[ ${CHOST} == *-darwin* ]] ; then
109                         sed -i \
110                                 -e 's:-install_name libR.dylib:-install_name ${libdir}/R/lib/libR.dylib:' \
111                                 -e 's:-install_name libRlapack.dylib:-install_name ${libdir}/R/lib/libRlapack.dylib:' \
112                                 -e 's:-install_name libRblas.dylib:-install_name ${libdir}/R/lib/libRblas.dylib:' \
113                                 -e "/SHLIB_EXT/s/\.so/.dylib/" \
114                                 configure.ac || die
115                         # sort of "undo" 2.14.1-rmath-shared.patch
116                         sed -i \
117                                 -e "s:-Wl,-soname=libRmath.so:-install_name ${EROOT%/}/usr/$(get_libdir)/libRmath.dylib:" \
118                                 src/nmath/standalone/Makefile.in || die
119                 else
120                         append-ldflags -Wl,-rpath="${EROOT%/}/usr/$(get_libdir)/R/lib"
121                 fi
122         fi
123         AT_M4DIR=m4 eaclocal
124         eautoconf
125 }
126
127 src_configure() {
128         #       --with-system-tre \
129         # tre is patched from upstream
130         econf \
131                 --enable-byte-compiled-packages \
132                 --enable-R-shlib \
133                 --disable-R-framework \
134                 --with-system-zlib \
135                 --with-system-bzlib \
136                 --with-system-pcre \
137                 --with-system-xz \
138                 --with-blas="$($(tc-getPKG_CONFIG) --libs blas)" \
139                 --docdir="${EPREFIX}/usr/share/doc/${PF}" \
140                 rdocdir="${EPREFIX}/usr/share/doc/${PF}" \
141                 $(use_enable nls) \
142                 $(use_enable openmp) \
143                 $(use_enable profile R-profiling) \
144                 $(use_enable profile memory-profiling) \
145                 $(use_enable static-libs static) \
146                 $(use_enable static-libs R-static-lib) \
147                 $(use_with cairo) \
148                 $(use_with icu ICU) \
149                 $(use_with jpeg jpeglib) \
150                 $(use_with lapack) \
151                 $(use_with !minimal recommended-packages) \
152                 $(use_with png libpng) \
153                 $(use_with readline) \
154                 $(use_with tiff libtiff) \
155                 $(use_with tk tcltk) \
156                 $(use_with tk tk-config "${EPREFIX}"/usr/lib/tkConfig.sh) \
157                 $(use_with tk tcl-config "${EPREFIX}"/usr/lib/tclConfig.sh) \
158                 $(use_with X x)
159 }
160
161 src_compile() {
162         export VARTEXFONTS="${T}/fonts"
163         emake AR="$(tc-getAR)"
164         emake -C src/nmath/standalone \
165                 shared $(use static-libs && echo static) AR="$(tc-getAR)"
166         use doc && emake info pdf
167 }
168
169 src_install() {
170         default
171         emake -j1 -C src/nmath/standalone DESTDIR="${D}" install
172
173         if use doc; then
174                 emake DESTDIR="${D}" install-info install-pdf
175                 dosym ../manual /usr/share/doc/${PF}/html/manual
176         fi
177
178         cat > 99R <<-EOF
179                 LDPATH=${R_DIR}/lib
180                 R_HOME=${R_DIR}
181         EOF
182         doenvd 99R
183         newbashcomp "${WORKDIR}"/${BCP} ${PN}
184         # The buildsystem has a different understanding of install_names than
185         # we require.  Since it builds modules like shared objects (wrong), many
186         # objects (all modules) get an incorrect install_name.  Fixing the build
187         # system here is not really trivial.
188         if [[ ${CHOST} == *-darwin* ]] ; then
189                 local mod
190                 pushd "${ED}"/usr/lib/R > /dev/null
191                 for mod in $(find . -name "*.dylib") ; do
192                         mod=${mod#./}
193                         install_name_tool -id "${EPREFIX}/usr/lib/R/${mod}" \
194                                 "${mod}"
195                 done
196                 popd > /dev/null
197         fi
198         docompress -x /usr/share/doc/${PF}/NEWS.rds
199 }
200
201 pkg_postinst() {
202         if use java; then
203                 einfo "Re-initializing java paths for ${P}"
204                 R CMD javareconf
205         fi
206 }