dev-libs/xapian-bindings: x86 stable
[gentoo.git] / dev-libs / xapian-bindings / xapian-bindings-1.4.7.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=( python{2_7,3_6} )
7 PYTHON_REQ_USE="threads(+)"
8
9 USE_PHP="php5-6 php7-1 php7-2"
10
11 PHP_EXT_NAME="xapian"
12 PHP_EXT_INI="yes"
13 PHP_EXT_OPTIONAL_USE="php"
14
15 USE_RUBY="ruby22 ruby23 ruby24"
16 RUBY_OPTIONAL="yes"
17
18 inherit java-pkg-opt-2 mono-env multibuild php-ext-source-r3 python-r1 ruby-ng toolchain-funcs
19
20 DESCRIPTION="SWIG and JNI bindings for Xapian"
21 HOMEPAGE="https://www.xapian.org/"
22 SRC_URI="https://oligarchy.co.uk/xapian/${PV}/${P}.tar.xz"
23
24 LICENSE="GPL-2"
25 SLOT="0"
26 KEYWORDS="~alpha amd64 arm ia64 ~mips ppc ppc64 ~sparc ~x86"
27 IUSE="java lua mono perl php python ruby tcl"
28 REQUIRED_USE="|| ( java lua mono perl php python ruby tcl )
29         python? ( ${PYTHON_REQUIRED_USE} )
30         ruby? ( || ( $(ruby_get_use_targets) ) )"
31
32 COMMONDEPEND=">=dev-libs/xapian-1.4.7:0/30
33         lua? ( dev-lang/lua:= )
34         perl? ( dev-lang/perl:= )
35         python? (
36                 dev-python/sphinx[${PYTHON_USEDEP}]
37                 ${PYTHON_DEPS}
38         )
39         ruby? ( $(ruby_implementations_depend) )
40         tcl? ( dev-lang/tcl:= )
41         mono? ( dev-lang/mono )"
42 DEPEND="${COMMONDEPEND}
43         virtual/pkgconfig
44         java? ( >=virtual/jdk-1.6 )"
45 RDEPEND="${COMMONDEPEND}
46         java? ( >=virtual/jre-1.6 )"
47
48 S="${WORKDIR}/${P}"
49
50 has_basic_bindings() {
51         # Update this list if new bindings are added that are not built
52         # multiple times for multiple versions like php, python and ruby are
53         return $(use mono || use java || use lua || use perl || use tcl)
54 }
55
56 php_copy_sources() {
57         local MULTIBUILD_VARIANTS=($(php_get_slots))
58         multibuild_copy_sources
59 }
60
61 php_foreach_impl() {
62         local MULTIBUILD_VARIANTS=($(php_get_slots))
63         multibuild_foreach_variant "$@"
64 }
65
66 ruby_copy_sources() {
67         local MULTIBUILD_VARIANTS=($(ruby_get_use_implementations))
68         multibuild_copy_sources
69 }
70
71 ruby_foreach_impl() {
72         local MULTIBUILD_VARIANTS=($(ruby_get_use_implementations))
73         multibuild_foreach_variant "$@"
74 }
75
76 pkg_setup() {
77         use mono && mono-env_pkg_setup
78         use java && java-pkg-opt-2_pkg_setup
79 }
80
81 src_unpack() {
82         default
83
84         if use php; then
85                 local php_slot
86                 for php_slot in $(php_get_slots); do
87                         # Unfortunately required for php-ext-source-r3_createinifiles().
88                         mkdir "${WORKDIR}/${php_slot}"
89                 done
90         fi
91 }
92
93 src_prepare() {
94         use java && java-pkg-opt-2_src_prepare
95
96         # https://trac.xapian.org/ticket/702
97         export XAPIAN_CONFIG="/usr/bin/xapian-config"
98
99         if use php; then
100                 php_copy_sources
101         fi
102
103         if use python; then
104                 python_copy_sources
105         fi
106
107         if use ruby; then
108                 ruby_copy_sources
109         fi
110
111         eapply_user
112 }
113
114 src_configure() {
115         if has_basic_bindings ; then
116                 local conf=(
117                         --disable-documentation
118                         $(use_with mono csharp)
119                         $(use_with java)
120                         $(use_with lua)
121                         $(use_with perl)
122                         $(use_with tcl)
123                         --without-php
124                         --without-php7
125                         --without-python
126                         --without-python3
127                         --without-ruby
128                 )
129
130                 if use java; then
131                         local -x CXXFLAGS="${CXXFLAGS} $(java-pkg_get-jni-cflags)"
132                 fi
133
134                 if use perl; then
135                         local -x PERL_ARCH="$(perl -MConfig -e 'print $Config{installvendorarch}')"
136                         local -x PERL_LIB="$(perl -MConfig -e 'print $Config{installvendorlib}')"
137                 fi
138
139                 if use lua; then
140                         local -x LUA_INC="$("$(tc-getPKG_CONFIG)" --variable=INSTALL_INC lua)"
141                         local -x LUA_LIB="$("$(tc-getPKG_CONFIG)" --variable=INSTALL_CMOD lua)"
142                 fi
143
144                 econf "${conf[@]}"
145         fi
146
147         php_configure() {
148                 local myconf=(
149                         --disable-documentation
150                         --without-java
151                         --without-lua
152                         --without-csharp
153                         --without-perl
154                         --without-python
155                         --without-python3
156                         --without-ruby
157                         --without-tcl
158                 )
159                 if [[ ${MULTIBUILD_VARIANT} == php5.* ]]; then
160                         myconf+=(
161                                 --with-php
162                                 --without-php7
163                         )
164                         local -x PHP_CONFIG="${EPREFIX}/usr/$(get_libdir)/${MULTIBUILD_VARIANT/-/.}/bin/php-config"
165                 elif [[ ${MULTIBUILD_VARIANT} == php7.* ]]; then
166                         myconf+=(
167                                 --without-php
168                                 --with-php7
169                         )
170                         local -x PHP_CONFIG7="${EPREFIX}/usr/$(get_libdir)/${MULTIBUILD_VARIANT/-/.}/bin/php-config"
171                 fi
172
173                 econf "${myconf[@]}"
174         }
175
176         if use php; then
177                 addpredict /usr/share/snmp/mibs/.index
178                 addpredict /var/lib/net-snmp/mib_indexes
179
180                 php_foreach_impl run_in_build_dir php_configure
181         fi
182
183         python_configure() {
184                 local myconf=(
185                         --disable-documentation
186                         --without-java
187                         --without-lua
188                         --without-csharp
189                         --without-perl
190                         --without-php
191                         --without-php7
192                         --without-ruby
193                         --without-tcl
194                 )
195                 if python_is_python3; then
196                         myconf+=( --with-python3 )
197                 else
198                         myconf+=( --with-python )
199                 fi
200
201                 # Avoid sandbox failures when compiling modules
202                 addpredict "$(python_get_sitedir)"
203
204                 econf "${myconf[@]}"
205         }
206
207         if use python; then
208                 python_foreach_impl run_in_build_dir python_configure
209         fi
210
211         ruby_configure() {
212                 local myconf=(
213                         --disable-documentation
214                         --without-java
215                         --without-lua
216                         --without-csharp
217                         --without-perl
218                         --without-php
219                         --without-php7
220                         --without-python
221                         --without-python3
222                         --with-ruby
223                         --without-tcl
224                 )
225                 local -x RUBY="${EPREFIX}/usr/bin/${MULTIBUILD_VARIANT}"
226
227                 econf "${myconf[@]}"
228         }
229
230         if use ruby; then
231                 ruby_foreach_impl run_in_build_dir ruby_configure
232         fi
233 }
234
235 src_compile() {
236         if has_basic_bindings ; then
237                 default
238         fi
239
240         if use php; then
241                 php_foreach_impl run_in_build_dir emake
242         fi
243
244         if use python; then
245                 unset PYTHONDONTWRITEBYTECODE
246                 python_foreach_impl run_in_build_dir emake
247         fi
248
249         if use ruby; then
250                 ruby_foreach_impl run_in_build_dir emake
251         fi
252 }
253
254 src_test() {
255         if has_basic_bindings ; then
256                 default
257         fi
258
259         if use php; then
260                 php_foreach_impl run_in_build_dir emake check
261         fi
262
263         if use python; then
264                 python_foreach_impl run_in_build_dir emake check
265         fi
266
267         if use ruby; then
268                 ruby_foreach_impl run_in_build_dir emake check
269         fi
270 }
271
272 src_install() {
273         if has_basic_bindings ; then
274                 emake DESTDIR="${D}" install
275         fi
276
277         if use java; then
278                 java-pkg_dojar java/built/xapian.jar
279                 # TODO: make the build system not install this...
280                 java-pkg_doso java/.libs/libxapian_jni.so
281                 rm -rf "${D}var" || die "could not remove java cruft!"
282         fi
283
284         if use php; then
285                 php_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
286                 php-ext-source-r3_createinifiles
287                 # php-ext-source-r3_createinifiles() changes current directory.
288                 cd "${S}"
289         fi
290
291         if use python; then
292                 python_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
293         fi
294
295         if use ruby; then
296                 ruby_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
297         fi
298
299         # For some USE combinations this directory is not created
300         if [[ -d "${D}/usr/share/doc/xapian-bindings" ]]; then
301                 mv "${D}/usr/share/doc/xapian-bindings" "${D}/usr/share/doc/${PF}" || die
302         fi
303
304         dodoc AUTHORS HACKING NEWS TODO README
305 }