82a612f37075ad4bb5e5c5817deaeb85f1f3ce2b
[gentoo.git] / sci-libs / shogun / shogun-5.0.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 PYTHON_COMPAT=( python2_7 python3_6 )
7
8 inherit cmake-utils flag-o-matic python-single-r1 toolchain-funcs versionator
9
10 MYPV=$(get_version_component_range 1-2)
11 MYPD=${PN}-data-0.9
12
13 DESCRIPTION="Large Scale Machine Learning Toolbox"
14 HOMEPAGE="http://shogun-toolbox.org/"
15 SRC_URI="
16         ftp://shogun-toolbox.org/shogun/releases/${MYPV}/sources/${P}.tar.bz2
17         test? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )
18         examples? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )"
19
20 LICENSE="GPL-3 free-noncomm"
21 SLOT="0/16"
22 KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
23 IUSE="cpu_flags_x86_sse doc examples lua octave opencl python R ruby static-libs test"
24 RESTRICT="!test? ( test )"
25
26 REQUIRED_USE="
27         python? ( ${PYTHON_REQUIRED_USE} )
28         test? ( python )"
29
30 RDEPEND="
31         app-arch/bzip2
32         app-arch/gzip
33         app-arch/lzma
34         app-arch/snappy
35         dev-libs/lzo
36         dev-cpp/eigen:3
37         dev-libs/json-c:=
38         dev-libs/libxml2
39         dev-libs/protobuf:=
40         net-misc/curl
41         sci-libs/arpack
42         sci-libs/arprec
43         sci-libs/colpack
44         sci-libs/hdf5:=
45         sci-libs/nlopt
46         sci-mathematics/glpk:=
47         sci-mathematics/lpsolve:=
48         sys-libs/readline:0=
49         sys-libs/zlib
50         virtual/blas
51         virtual/cblas
52         virtual/lapack
53         lua? ( dev-lang/lua:0 )
54         octave? ( >=sci-mathematics/octave-4.2.0:=[hdf5] )
55         opencl? ( virtual/opencl )
56         python? (
57                 ${PYTHON_DEPS}
58                 dev-python/numpy[${PYTHON_USEDEP}]
59         )
60         R? ( dev-lang/R )
61         ruby? ( dev-ruby/narray )"
62 DEPEND="${RDEPEND}
63         virtual/pkgconfig
64         doc? (
65                 >=app-doc/doxygen-1.8.13-r1[dot]
66                 dev-python/sphinx
67         )
68         lua? ( >=dev-lang/swig-3.0.12 )
69         octave? ( >=dev-lang/swig-3.0.12 )
70         python? (
71                 >=dev-lang/swig-3.0.12
72                 test? (
73                         sci-libs/scipy
74                 )
75         )
76         R? ( >=dev-lang/swig-3.0.12 )
77         ruby? ( >=dev-lang/swig-3.0.12 )
78         test? (
79                 dev-python/jinja[${PYTHON_USEDEP}]
80                 >=dev-cpp/gtest-1.8.0
81         )"
82
83 # javamodular needs jblas (painful to package properly)
84 # permodular work in progress (as 3.2.0)
85 # could actually support multiple pythons, multiple rubys
86 # feel free to do work for it
87
88 PATCHES=(
89         "${FILESDIR}"/${PN}-5.0.0-fix-buildsystem.patch
90         "${FILESDIR}"/${PN}-4.1.0-remove-C-linkage.patch
91 )
92
93 pkg_setup() {
94         use python && python-single-r1_pkg_setup
95 }
96
97 src_configure() {
98         export ATLAS_LIBRARY="$($(tc-getPKG_CONFIG) --libs cblas lapack)"
99         export CBLAS_LIBRARY="$($(tc-getPKG_CONFIG) --libs cblas)"
100         export ATLAS_LIBRARIES="$($(tc-getPKG_CONFIG) --libs blas cblas lapack)"
101         export LAPACK_LIBRARIES="$($(tc-getPKG_CONFIG) --libs lapack)"
102
103         append-cppflags "$($(tc-getPKG_CONFIG) --cflags cblas)"
104
105         local mycmakeargs=(
106                 -DCMAKE_SKIP_RPATH=ON
107                 -DCMAKE_SKIP_INSTALL_RPATH=ON
108                 -DLIB_INSTALL_DIR=$(get_libdir)
109                 -DENABLE_TESTING=$(usex test)
110                 -DBUILD_EXAMPLES=$(usex examples)
111                 -DDISABLE_SSE=$(usex !cpu_flags_x86_sse)
112                 -DCMAKE_DISABLE_FIND_PACKAGE_Pandoc=ON
113                 $(cmake-utils_use_find_package doc Sphinx)
114                 $(cmake-utils_use_find_package doc Doxygen)
115
116                 # Features:
117                 -DENABLE_COVERAGE=OFF
118                 -DENABLE_COLPACK=ON
119                 -DENABLE_PROTOBUF=ON
120                 -DENABLE_PYTHON_DEBUG=OFF
121                 -DENABLE_VIENNACL=$(usex opencl)
122                 -DUSE_ARPREC=ON
123                 -DUSE_HDF5=ON
124
125                 # Bindings:
126                 -DJavaModular=OFF
127                 -DPerlModular=OFF
128                 -DCSharpModular=OFF
129                 -DLuaModular=$(usex lua)
130                 -DOctaveModular=$(usex octave)
131                 -DPythonModular=$(usex python)
132                 -DRModular=$(usex R)
133                 -DRubyModular=$(usex ruby)
134
135                 # Disable bundled libs
136                 -DBUNDLE_COLPACK=OFF
137                 -DBUNDLE_JSON=OFF
138                 -DBUNDLE_NLOPT=OFF
139         )
140         cmake-utils_src_configure
141
142         # gentoo bug #302621
143         has_version 'sci-libs/hdf5[mpi]' && export CXX=mpicxx CC=mpicc
144 }
145
146 src_compile() {
147         cmake-utils_src_compile
148         use doc && cmake-utils_src_compile -C doc
149 }
150
151 src_install() {
152         cmake-utils_src_install
153
154         if use doc; then
155                 local i
156                 for i in lua octave python R ruby; do
157                         if use $i; then
158                                 docinto html/${i,}_modular
159                                 dodoc -r "${BUILD_DIR}"/src/interfaces/${i,}_modular/modshogun/doxygen_xml/.
160                         fi
161                 done
162         fi
163 }