summaryrefslogtreecommitdiff
blob: 1ae8074616533f6455b8a69b7232e608c3e81577 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sci-libs/shogun/shogun-2.0.0.ebuild,v 1.2 2013/03/04 19:08:43 bicatali Exp $

EAPI=5

inherit eutils multilib versionator toolchain-funcs java-pkg-opt-2

MYPV=$(get_version_component_range 1-2)
MYPD=${PN}-data-0.4

DESCRIPTION="Large Scale Machine Learning Toolbox"
HOMEPAGE="http://shogun-toolbox.org/"
SRC_URI="ftp://shogun-toolbox.org/shogun/releases/${MYPV}/sources/${P}.tar.bz2
	test? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )
	examples? ( ftp://shogun-toolbox.org/shogun/data/${MYPD}.tar.bz2 )"

LICENSE="GPL-3 free-noncomm"
SLOT="0"
KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
IUSE="arpack bzip2 doc eigen examples glpk gzip hdf5 json lapack lpsolve mono lua lzma
	lzo nlopt java R ruby octave python readline smp snappy static-libs superlu test xml"

RDEPEND="
	sci-libs/gsl
	sys-libs/zlib
	arpack? ( sci-libs/arpack )
	bzip2? ( app-arch/bzip2 )
	eigen? ( >=dev-cpp/eigen-3 )
	glpk? ( sci-mathematics/glpk )
	gzip? ( app-arch/gzip )
	hdf5? ( sci-libs/hdf5 )
	java? ( >=virtual/jdk-1.5 )
	json? ( dev-libs/json-c )
	lapack? ( virtual/cblas virtual/lapack )
	lpsolve? ( sci-mathematics/lpsolve )
	lua? ( dev-lang/lua )
	lzo? ( dev-libs/lzo )
	mono? ( dev-lang/mono )
	nlopt? ( sci-libs/nlopt )
	octave? ( sci-mathematics/octave[hdf5=] )
	python? ( dev-python/numpy )
	R? ( dev-lang/R )
	readline? ( sys-libs/readline )
	ruby? ( >=dev-ruby/narray-0.6.0.1-r2 )
	snappy? ( app-arch/snappy )
	superlu? ( sci-libs/superlu )
	xml? ( dev-libs/libxml2 )"

DEPEND="${RDEPEND}
	virtual/pkgconfig
	doc? ( app-doc/doxygen[dot] )
	java? ( >=dev-lang/swig-2.0.4 dev-java/ant )
	octave? ( >=dev-lang/swig-2.0.4 )
	python? ( >=dev-lang/swig-2.0.4 test? ( sci-libs/scipy ) )
	ruby? ( >=dev-lang/swig-2.0.4 )"

S="${WORKDIR}/${P}/src"

src_prepare() {
	epatch \
		"${FILESDIR}"/${PN}-1.1.0-respect-ldflags.patch \
		"${FILESDIR}"/${PN}-1.1.0-test-readline.patch \
		"${FILESDIR}"/${PN}-1.1.0-as-needed.patch

	# dist-packages is only for debian
	# remove exagarated optimizations (-O9 does not exist...)
	# use gentoo lapack framework
	sed -i \
		-e 's/dist-packages/site-packages/g' \
		-e '/^COMP_OPTS=/d' \
		-e "s:-llapack -lcblas:$($(tc-getPKG_CONFIG) --libs cblas lapack):g" \
		configure || die

	# disable ldconfig which violates sandbox
	# install in gentoo java standard paths
	sed -i \
		-e '/ldconfig/d' \
		-e '/share\/java/d' \
		-e '/jni/d' \
		-e 's/OCTAVE_LOADPATH/OCTAVE_PATH/g' \
		Makefile.template || die
}

src_configure() {
	# define interfaces to shogun library to build
	local x iface
	for x in java lua octave python ruby ; do
		use ${x} && iface="${iface}${x}_modular,"
	done
	use mono &&	iface="${iface}csharp_modular,"
	use R && iface="${iface}r_modular,"
	if use static-libs; then
		iface="${iface}cmdline_static,"
		use octave && iface="${iface}octave_static,"
		use python && iface="${iface}python_static,"
		use R && iface="${iface}r_static,"
		use octave && use python && use R && iface="${iface}elwms_static,"
	fi
	iface="${iface%,}"

	# gentoo bug #302621
	use hdf5 && has_version sci-libs/hdf5[mpi] && export CXX=mpicxx CC=mpicc
	./configure \
		--disable-cpudetection \
		--destdir="${D}" \
		--prefix="${EPREFIX}/usr" \
		--mandir="${EPREFIX}/usr/share/man" \
		--libdir="${EPREFIX}/usr/$(get_libdir)" \
		--cc="$(tc-getCC)" \
		--cxx="$(tc-getCXX)" \
		--target="${CTARGET}" \
		--interfaces=${iface} \
		$(use_enable arpack) \
		$(use_enable bzip2) \
		$(use_enable doc doxygen) \
		$(use_enable eigen eigen3) \
		$(use_enable glpk) \
		$(use_enable gzip) \
		$(use_enable hdf5) \
		$(use_enable json) \
		$(use_enable lapack) \
		$(use_enable lpsolve) \
		$(use_enable lzma) \
		$(use_enable lzo) \
		$(use_enable nlopt) \
		$(use_enable readline) \
		$(use_enable smp hmm-parallel) \
		$(use_enable snappy) \
		$(use_enable static-libs static) \
		$(use_enable superlu) \
		$(use_enable xml) || die
}

src_compile() {
	emake
	use doc && emake -C ../doc
}

src_test() {
	use lapack || return
	ln -s ../../${MYPD}/* ../data/
	emake DESTDIR="${D}" install
	# disable because very long
	# emake tests
	emake -C shogun check-examples
}

src_install() {
	default
	use static-libs || rm "${ED}"/usr/$(get_libdir)/*.a
	if use java; then
		java-pkg_dojar interfaces/java_modular/shogun.jar
		java-pkg_doso interfaces/java_modular/libmodshogun.so
	fi

	use doc && dohtml -r ../doc/html/*
	if use examples; then
		insinto /usr/share/doc/${PF}
		emake -C ../examples clean && doins -r ../examples
		insinto /usr/share/doc/${PF}/data
		doins -r "${WORKDIR}"/${MYPD}/*
	fi
}