dev-libs/xapian-bindings: convert to python-r1 and enable python3
[gentoo.git] / dev-libs / xapian-bindings / xapian-bindings-1.4.1.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI="5"
6
7 PYTHON_COMPAT=( python{2_7,3_4,3_5} )
8 PYTHON_REQ_USE="threads(+)"
9
10 USE_PHP="php5-5 php5-6"
11
12 PHP_EXT_NAME="xapian"
13 PHP_EXT_INI="yes"
14 PHP_EXT_OPTIONAL_USE="php"
15
16 #mono violates sandbox, we disable it until we figure this out
17 #inherit distutils-r1 libtool java-pkg-opt-2 mono-env php-ext-source-r2 toolchain-funcs
18 inherit python-r1 libtool java-pkg-opt-2 php-ext-source-r2 toolchain-funcs
19
20 DESCRIPTION="SWIG and JNI bindings for Xapian"
21 HOMEPAGE="http://www.xapian.org/"
22 SRC_URI="http://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 IUSE="java lua perl php python ruby tcl"
29 #REQUIRED_USE="|| ( java lua mono perl php python ruby tcl )"
30 REQUIRED_USE="|| ( java lua perl php python ruby tcl )"
31
32 COMMONDEPEND="dev-libs/xapian: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? ( dev-lang/ruby:= )
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 REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )"
49
50 pkg_setup() {
51 #       use mono && mono-env_pkg_setup
52         use java && java-pkg-opt-2_pkg_setup
53 }
54
55 src_prepare() {
56         use java && java-pkg-opt-2_src_prepare
57
58         # http://trac.xapian.org/ticket/702
59         export XAPIAN_CONFIG="/usr/bin/xapian-config"
60
61         # Accept ruby 2.0 - patch configure directly to avoid autoreconf
62         epatch "${FILESDIR}"/${PN}-1.3.6-allow-ruby-2.0.patch
63
64         if use python; then
65                 python_copy_sources
66         fi
67 }
68
69 src_configure() {
70         if use java; then
71                 export CXXFLAGS="${CXXFLAGS} $(java-pkg_get-jni-cflags)"
72         fi
73
74         if use perl; then
75                 export PERL_ARCH="$(perl -MConfig -e 'print $Config{installvendorarch}')"
76                 export PERL_LIB="$(perl -MConfig -e 'print $Config{installvendorlib}')"
77         fi
78
79         if use lua; then
80                 export LUA_LIB="$($(tc-getPKG_CONFIG) --variable=INSTALL_CMOD lua)"
81         fi
82
83         econf \
84                 --disable-documentation \
85                 $(use_with java) \
86                 $(use_with lua) \
87                 --without-csharp \
88                 $(use_with perl) \
89                 $(use_with php) \
90                 --without-python \
91                 --without-python3 \
92                 $(use_with ruby) \
93                 $(use_with tcl)
94 #               $(use_with mono csharp)
95
96         python_configure() {
97                 local myconf=(
98                         --disable-documentation
99                         --without-java
100                         --without-lua
101                         --without-csharp
102                         --without-perl
103                         --without-php
104                         --without-ruby
105                         --without-tcl
106                 )
107                 if python_is_python3; then
108                         myconf+=( --with-python3 )
109                 else
110                         myconf+=( --with-python )
111                 fi
112                 econf "${myconf[@]}"
113         }
114
115         if use python; then
116                 python_foreach_impl run_in_build_dir python_configure
117         fi
118 }
119
120 src_compile() {
121         default
122         if use python; then
123                 unset PYTHONDONTWRITEBYTECODE
124                 python_foreach_impl run_in_build_dir emake
125         fi
126 }
127
128 src_install() {
129         emake DESTDIR="${D}" install
130
131         if use java; then
132                 java-pkg_dojar java/built/xapian_jni.jar
133                 # TODO: make the build system not install this...
134                 java-pkg_doso java/.libs/libxapian_jni.so
135                 rm -rf "${D}var" || die "could not remove java cruft!"
136         fi
137
138         use php && php-ext-source-r2_createinifiles
139
140         if use python; then
141                 python_foreach_impl run_in_build_dir emake DESTDIR="${D}" install
142         fi
143
144         # For some USE combinations this directory is not created
145         if [[ -d "${D}/usr/share/doc/xapian-bindings" ]]; then
146                 mv "${D}/usr/share/doc/xapian-bindings" "${D}/usr/share/doc/${PF}" || die
147         fi
148
149         dodoc AUTHORS HACKING NEWS TODO README
150 }