sci-libs/shogun: Clear QA warnings
[gentoo.git] / sci-libs / shogun / shogun-1.1.0.ebuild
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit eutils multilib versionator toolchain-funcs java-pkg-opt-2
8
9 MYPV=$(get_version_component_range 1-2)
10 MYPD=${PN}-data-0.3
11
12 DESCRIPTION="Large Scale Machine Learning Toolbox"
13 HOMEPAGE="http://shogun-toolbox.org/"
14 SRC_URI="ftp://shogun-toolbox.org/shogun/releases/${MYPV}/sources/${P}.tar.bz2
15         test? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )
16         examples? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )"
17
18 LICENSE="GPL-3 free-noncomm"
19 SLOT="0"
20 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
21 IUSE="arpack bzip2 doc examples glpk gzip hdf5 json lapack lpsolve mono lua lzma
22         lzo java R ruby octave python readline snappy static-libs superlu test xml"
23
24 RDEPEND="
25         sci-libs/gsl
26         sys-libs/zlib
27         arpack? ( sci-libs/arpack )
28         bzip2? ( app-arch/bzip2 )
29         glpk? ( sci-mathematics/glpk )
30         gzip? ( app-arch/gzip )
31         hdf5? ( sci-libs/hdf5 )
32         java? ( >=virtual/jdk-1.5 )
33         json? ( dev-libs/json-c )
34         lapack? ( virtual/cblas virtual/lapack )
35         lpsolve? ( sci-mathematics/lpsolve )
36         lua? ( dev-lang/lua )
37         lzo? ( dev-libs/lzo )
38         mono? ( dev-lang/mono )
39         octave? ( sci-mathematics/octave[hdf5=] )
40         python? ( dev-python/numpy )
41         R? ( dev-lang/R )
42         readline? ( sys-libs/readline )
43         ruby? ( >=dev-ruby/narray-0.6.0.1-r2 )
44         snappy? ( app-arch/snappy )
45         superlu? ( sci-libs/superlu )
46         xml? ( dev-libs/libxml2 )"
47
48 DEPEND="${RDEPEND}
49         virtual/pkgconfig
50         doc? ( app-doc/doxygen[dot] )
51         java? ( dev-lang/swig dev-java/ant )
52         octave? ( dev-lang/swig )
53         python? ( dev-lang/swig test? ( sci-libs/scipy ) )
54         ruby? ( dev-lang/swig )"
55
56 S="${WORKDIR}/${P}/src"
57
58 src_prepare() {
59         epatch \
60                 "${FILESDIR}"/${P}-respect-ldflags.patch \
61                 "${FILESDIR}"/${P}-test-snappy.patch \
62                 "${FILESDIR}"/${P}-test-readline.patch \
63                 "${FILESDIR}"/${P}-as-needed.patch
64
65         # dist-packages is only for debian
66         # remove exagarated optimizations (-O9 does not exist...)
67         # use gentoo lapack framework
68         sed -i \
69                 -e 's/dist-packages/site-packages/g' \
70                 -e '/^COMP_OPTS=/d' \
71                 -e "s:-llapack -lcblas:$($(tc-getPKG_CONFIG) --libs cblas lapack):g" \
72                 configure || die
73
74         # disable ldconfig which violates sandbox
75         # install in gentoo java standard paths
76         sed -i \
77                 -e '/ldconfig/d' \
78                 -e '/share\/java/d' \
79                 -e '/jni/d' \
80                 Makefile.template || die
81 }
82
83 src_configure() {
84         # define interfaces to shogun library to build
85         local x iface
86         for x in java lua octave python ruby ; do
87                 use ${x} && iface="${iface}${x}_modular,"
88         done
89         use mono &&     iface="${iface}csharp_modular,"
90         use R && iface="${iface}r_modular,"
91         if use static-libs; then
92                 iface="${iface}cmdline_static,"
93                 use octave && iface="${iface}octave_static,"
94                 use python && iface="${iface}python_static,"
95                 use R && iface="${iface}r_static,"
96                 use octave && use python && use R && iface="${iface}elwms_static,"
97         fi
98         iface="${iface%,}"
99
100         # gentoo bug #302621
101         use hdf5 && has_version sci-libs/hdf5[mpi] && export CXX=mpicxx CC=mpicc
102
103         ./configure \
104                 --disable-cpudetection \
105                 --destdir="${ED}" \
106                 --prefix="${EPREFIX}/usr" \
107                 --mandir="${EPREFIX}/usr/share/man" \
108                 --libdir="${EPREFIX}/usr/$(get_libdir)" \
109                 --cc="$(tc-getCC)" \
110                 --cxx="$(tc-getCXX)" \
111                 --target="${CTARGET}" \
112                 --interfaces=${iface} \
113                 $(use_enable arpack) \
114                 $(use_enable bzip2) \
115                 $(use_enable doc doxygen) \
116                 $(use_enable glpk) \
117                 $(use_enable gzip) \
118                 $(use_enable hdf5) \
119                 $(use_enable json) \
120                 $(use_enable lapack) \
121                 $(use_enable lpsolve) \
122                 $(use_enable lzma) \
123                 $(use_enable lzo) \
124                 $(use_enable readline) \
125                 $(use_enable snappy) \
126                 $(use_enable static-libs static) \
127                 $(use_enable superlu) \
128                 $(use_enable xml) || die
129 }
130
131 src_compile() {
132         emake
133         use doc && emake -C ../doc
134 }
135
136 src_test() {
137         use lapack || return
138         ln -s ../../${MYPD}/* ../data/
139         emake DESTDIR="${ED}" install
140         # disable because very long and buggy dynamic paths (assumed install)
141         # emake tests
142         emake -C shogun check-examples
143 }
144
145 src_install() {
146         default
147         use static-libs || rm -f "${ED}"/usr/$(get_libdir)/*.a
148         if use java; then
149                 java-pkg_dojar interfaces/java_modular/shogun.jar
150                 java-pkg_doso interfaces/java_modular/libmodshogun.so
151         fi
152
153         use doc && dohtml -r ../doc/html/*
154         if use examples; then
155                 insinto /usr/share/doc/${PF}
156                 emake -C ../examples clean && doins -r ../examples
157                 insinto /usr/share/doc/${PF}/data
158                 doins -r "${WORKDIR}"/${MYPD}/*
159         fi
160 }