1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python{2_7,3_6} )
7 PYTHON_REQ_USE="threads(+)"
9 USE_PHP="php7-1 php7-2 php7-3"
13 PHP_EXT_OPTIONAL_USE="php"
15 USE_RUBY="ruby22 ruby23 ruby24"
18 inherit java-pkg-opt-2 mono-env multibuild php-ext-source-r3 python-r1 ruby-ng toolchain-funcs
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"
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) ) )"
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] )
37 dev-python/sphinx[${PYTHON_USEDEP}]
40 ruby? ( $(ruby_implementations_depend) )
41 tcl? ( dev-lang/tcl:= )
42 mono? ( dev-lang/mono )"
43 DEPEND="${COMMONDEPEND}
45 java? ( >=virtual/jdk-1.6 )"
46 RDEPEND="${COMMONDEPEND}
47 java? ( >=virtual/jre-1.6 )"
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)
58 local MULTIBUILD_VARIANTS=($(php_get_slots))
59 multibuild_copy_sources
63 local MULTIBUILD_VARIANTS=($(php_get_slots))
64 multibuild_foreach_variant "$@"
68 local MULTIBUILD_VARIANTS=($(ruby_get_use_implementations))
69 multibuild_copy_sources
73 local MULTIBUILD_VARIANTS=($(ruby_get_use_implementations))
74 multibuild_foreach_variant "$@"
78 use mono && mono-env_pkg_setup
79 use java && java-pkg-opt-2_pkg_setup
87 for php_slot in $(php_get_slots); do
88 # Unfortunately required for php-ext-source-r3_createinifiles().
89 mkdir "${WORKDIR}/${php_slot}"
95 use java && java-pkg-opt-2_src_prepare
97 # https://trac.xapian.org/ticket/702
98 export XAPIAN_CONFIG="/usr/bin/xapian-config"
116 if has_basic_bindings ; then
118 --disable-documentation
119 $(use_with mono csharp)
132 local -x CXXFLAGS="${CXXFLAGS} $(java-pkg_get-jni-cflags)"
136 local -x PERL_ARCH="$(perl -MConfig -e 'print $Config{installvendorarch}')"
137 local -x PERL_LIB="$(perl -MConfig -e 'print $Config{installvendorlib}')"
141 local -x LUA_INC="$("$(tc-getPKG_CONFIG)" --variable=INSTALL_INC lua)"
142 local -x LUA_LIB="$("$(tc-getPKG_CONFIG)" --variable=INSTALL_CMOD lua)"
150 --disable-documentation
160 if [[ ${MULTIBUILD_VARIANT} == php5.* ]]; then
165 local -x PHP_CONFIG="${EPREFIX}/usr/$(get_libdir)/${MULTIBUILD_VARIANT/-/.}/bin/php-config"
166 elif [[ ${MULTIBUILD_VARIANT} == php7.* ]]; then
171 local -x PHP_CONFIG7="${EPREFIX}/usr/$(get_libdir)/${MULTIBUILD_VARIANT/-/.}/bin/php-config"
178 addpredict /usr/share/snmp/mibs/.index
179 addpredict /var/lib/net-snmp/mib_indexes
181 php_foreach_impl run_in_build_dir php_configure
186 --disable-documentation
196 if python_is_python3; then
197 myconf+=( --with-python3 )
199 myconf+=( --with-python )
202 # Avoid sandbox failures when compiling modules
203 addpredict "$(python_get_sitedir)"
209 python_foreach_impl run_in_build_dir python_configure
214 --disable-documentation
226 local -x RUBY="${EPREFIX}/usr/bin/${MULTIBUILD_VARIANT}"
232 ruby_foreach_impl run_in_build_dir ruby_configure
237 if has_basic_bindings ; then
242 php_foreach_impl run_in_build_dir emake
246 unset PYTHONDONTWRITEBYTECODE
247 python_foreach_impl run_in_build_dir emake
251 ruby_foreach_impl run_in_build_dir emake
256 if has_basic_bindings ; then
261 php_foreach_impl run_in_build_dir emake check
265 python_foreach_impl run_in_build_dir emake check
269 ruby_foreach_impl run_in_build_dir emake check
274 if has_basic_bindings ; then
275 emake DESTDIR="${D}" install
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!"
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.
293 python_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
297 ruby_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
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
305 dodoc AUTHORS HACKING NEWS TODO README