summaryrefslogtreecommitdiff
blob: b0cc54e900fb017e24db49788145a130cb09e29d (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
# 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-1.1.0.ebuild,v 1.5 2013/02/21 21:24:38 jlec Exp $

EAPI=4

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

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

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 examples glpk gzip hdf5 json lapack lpsolve mono lua lzma
	lzo java R ruby octave python readline snappy static-libs superlu test xml"

RDEPEND="
	sci-libs/gsl
	sys-libs/zlib
	arpack? ( sci-libs/arpack )
	bzip2? ( app-arch/bzip2 )
	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 )
	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 dev-java/ant )
	octave? ( dev-lang/swig )
	python? ( dev-lang/swig test? ( sci-libs/scipy ) )
	ruby? ( dev-lang/swig )"

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

src_prepare() {
	epatch \
		"${FILESDIR}"/${P}-respect-ldflags.patch \
		"${FILESDIR}"/${P}-test-snappy.patch \
		"${FILESDIR}"/${P}-test-readline.patch \
		"${FILESDIR}"/${P}-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' \
		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="${ED}" \
		--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 glpk) \
		$(use_enable gzip) \
		$(use_enable hdf5) \
		$(use_enable json) \
		$(use_enable lapack) \
		$(use_enable lpsolve) \
		$(use_enable lzma) \
		$(use_enable lzo) \
		$(use_enable readline) \
		$(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="${ED}" install
	# disable because very long and buggy dynamic paths (assumed install)
	# emake tests
	emake -C shogun check-examples
}

src_install() {
	default
	use static-libs || rm -f "${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
}