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