xapian-inspect: Support glass instead of chert
[xapian.git] / xapian-bindings / configure.ac
blob65992d382cf29be5120e67930e2ba6b104502806
1 dnl Process this file with autoconf to produce a configure script.
3 dnl See xapian-core's HACKING document for details of the reasons for required
4 dnl versions.
5 AC_PREREQ([2.63])
7 m4_define([project_version], [1.4.1])
8 AC_INIT([xapian-bindings], project_version, [https://xapian.org/bugs])
10 dnl See xapian-core's HACKING document for details of the reasons for required
11 dnl versions.
12 AM_INIT_AUTOMAKE([1.12.2 parallel-tests -Wportability subdir-objects tar-ustar no-dist-gzip dist-xz])
13 AC_CONFIG_SRCDIR([xapian-headers.i])
15 AC_CONFIG_HEADERS([config.h])
17 AC_CONFIG_MACRO_DIR([m4])
19 dnl Mac OS X needs MACOSX_DEPLOYMENT_TARGET set to 10.3 (or higher) to
20 dnl successfully link the SWIG generated modules.  The link always fails on
21 dnl earlier versions of Mac OS X (10.1.4 and 10.2.8 tested), and these versions
22 dnl are long obsolete now, so we just ensure that MACOSX_DEPLOYMENT_TARGET is
23 dnl set to at least 10.3.
24 dnl
25 dnl NB we must do this *BEFORE* LT_INIT since that is what checks
26 dnl MACOSX_DEPLOYMENT_TARGET.
27 AC_CANONICAL_HOST
28 OVERRIDE_MACOSX_DEPLOYMENT_TARGET=
29 case $host in
30 *86*-darwin8*|*-darwin[[91]]*)
31   dnl On 10.5 or later, and 10.4 on x86, the deployment target defaults to the
32   dnl OS version, so we don't need to override on these.
33   ;;
34 *-darwin*)
35   case $MACOSX_DEPLOYMENT_TARGET in
36   "")
37     OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
38   10.[[012]])
39     AC_MSG_WARN([Overriding MACOSX_DEPLOYMENT_TARGET from $MACOSX_DEPLOYMENT_TARGET to 10.3])
40     OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
41   esac
42   ;;
43 esac
44 AM_CONDITIONAL(OVERRIDE_MACOSX_DEPLOYMENT_TARGET, test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET")
45 AC_SUBST(OVERRIDE_MACOSX_DEPLOYMENT_TARGET)
46 if test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET" ; then
47   MACOSX_DEPLOYMENT_TARGET=$OVERRIDE_MACOSX_DEPLOYMENT_TARGET
50 dnl Use libtool to manage our libraries, but don't build static libraries as
51 dnl the bindings only have a use for dynamic ones.
52 LT_PREREQ([2.2.6])
53 LT_INIT([disable-static])
55 dnl -no-undefined causes problems on Mac OS X with at least some
56 dnl MACOSX_DEPLOYMENT_TARGET settings, so only pass -no-undefined on
57 dnl platforms where it is required in order to link a shared library at
58 dnl all (Windows is the main one).
59 NO_UNDEFINED=
60 if test unsupported = "$allow_undefined_flag" ; then
61   NO_UNDEFINED=-no-undefined
63 AC_SUBST(NO_UNDEFINED)
65 dnl Checks for programs.
66 AC_PROG_CXX
68 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
69 case $host_os in
70   linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
71     dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
72     link_all_deplibs_CXX=no
73     ;;
74 esac
76 case $host_os in
77   linux*)
78     dnl Extract search path from ldconfig which is more reliable than the way
79     dnl vanilla libtool extracts them from ld.so.conf.
80     d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
81     test -z "$d" || sys_lib_dlsearch_path_spec=$d
82     ;;
83 esac
85 dnl Run tests using the C++ compiler.
86 AC_LANG_CPLUSPLUS
88 dnl Probe for any options needed to enable C++11 support.
89 AX_CXX_COMPILE_STDCXX_11
91 dnl Check for xapian-core.
92 XO_LIB_XAPIAN([], [],
93     [xapian-config]regexp(project_version,
94                           [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
96 NEED_JNILIB_EXT=no
97 NEED_INTREE_DYLD=no
98 INTREE_DYLD_PATH=
99 case $host_os in
100 darwin*)
101   NEED_JNILIB_EXT=yes
102   dnl If we're building against an uninstalled xapian-core, xapian-config
103   dnl --libs will give an error.
104   if $XAPIAN_CONFIG --libs >/dev/null 2>/dev/null ; then
105     :
106   else
107     NEED_INTREE_DYLD=yes
108     dnl $XAPIAN_LIBS may have some options first, so grab the last argument,
109     dnl which should be the .la file.
110     set x $XAPIAN_LIBS
111     as_fn_arith $# - 1
112     shift $as_val
113     INTREE_DYLD_PATH=$1
114     dnl Make sure the path is absolute.
115     case $INTREE_DYLD_PATH in
116       /*) ;;
117       *) INTREE_DYLD_PATH=`pwd`/$INTREE_DYLD_PATH ;;
118     esac
119     dnl Add .libs or equivalent.
120     INTREE_DYLD_PATH=`echo "$INTREE_DYLD_PATH"|sed 's,\(.*/\).*,\1,'`$lt_cv_objdir
121     AC_SUBST([INTREE_DYLD_PATH])
122   fi
123   ;;
124 esac
125 AM_CONDITIONAL(NEED_JNILIB_EXT, test yes = "$NEED_JNILIB_EXT")
126 AM_CONDITIONAL(NEED_INTREE_DYLD, test yes = "$NEED_INTREE_DYLD")
128 dnl We want XAPIAN_CXXFLAGS to be used for configure tests, so add it to
129 dnl CXXFLAGS for the duration of configure.
130 save_CXXFLAGS=$CXXFLAGS
131 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
133 dnl COMPAT_VERSION is the version of xapian-core that "matches" our version.
134 dnl We allow for bindings being version 0.8.5.1 while xapian-core is 0.8.5.
135 dnl COMPAT_VERSION also ignores any _git123 suffix which snapshots will have.
136 COMPAT_VERSION=[`echo "$PACKAGE_VERSION"|sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`]
137 AC_SUBST(COMPAT_VERSION)
139 dnl VERSION_NO_SNAPSHOT simply has any _git123 suffix removed.
140 VERSION_NO_SNAPSHOT=[`echo "$PACKAGE_VERSION"|sed 's/_.*$//'`]
141 AC_SUBST(VERSION_NO_SNAPSHOT)
143 dnl We only need to set docdir for compatibility with autoconf < 2.60 - this
144 dnl code can be removed once we move to requiring autoconf 2.60 or newer.
145 test -n "$docdir" || docdir='${datadir}/doc/${PACKAGE_TARNAME}'
146 AC_SUBST(docdir)
148 AC_ARG_ENABLE(visibility,
149   [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
150   [case ${enableval} in
151     yes|no) ;;
152     *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
153   esac])
155 dnl Only probe for SWIG and enable SWIG rules in makefiles if
156 dnl configure --enable-maintainer-mode is used.
157 AM_MAINTAINER_MODE
159 AC_ARG_ENABLE(documentation,
160   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild shipped documentation [default=maintainer-mode]])],
161   [case ${enableval} in
162     yes|no) ;;
163     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
164   esac])
165 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
166 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
167 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
169 if test yes = "$enable_documentation" ; then
170   dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
171   dnl Also look for rst2html.py, which archlinux reportedly installs it as.
172   AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
173   test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
176 if test x$USE_MAINTAINER_MODE = xyes; then
177   dnl Check for swig - this does most of the work for the bindings.
178   dnl AC_PATH_PROGS only honours an already set SWIG if it's a full
179   dnl path.  Listing it in the "to be searched" list like this allows
180   dnl ./configure SWIG=myswig to work.
181   swigoverridden=${SWIG+yes}
182   AC_PATH_PROGS(SWIG, ["${SWIG-swig}"], [])
183   AC_ARG_VAR(SWIG, [SWIG interface generator (only needed by Xapian developers)])
184   if test -z "$SWIG" ; then
185     AC_MSG_ERROR([Can't find SWIG utility])
186   fi
187   dnl Check for new enough SWIG.
188   dnl
189   dnl 3.0.6 fixes compiling the Perl bindings under C++11 ("seed" macro issue).
190   dnl 3.0.8 fixes conversion of integers large than an int in Python 3.
191   dnl 3.0.9 fixes generation of unnecessary _swigconstant helpers for Python.
192   v=`$SWIG -version 2>&1|sed 's/^SWIG Version \([[0-9\.]]*\).*/\1/p;d'`
193   case $v in
194     [[012].*|3.0.[012345678]|""])
195       msg="SWIG >= 3.0.9 required (you have ${v:-an unknown version})"
196       if test -n "$swigoverridden" ; then
197         dnl If SWIG was explicitly set, make this a warning only.
198         AC_MSG_WARN([$msg])
199       else
200         AC_MSG_ERROR([$msg])
201       fi ;;
202   esac
203   SWIG_FLAGS=`$XAPIAN_CONFIG --swigflags`
204   AC_SUBST(SWIG_FLAGS)
205   XAPIAN_HEADER_DIRS=
206   XAPIAN_HEADERS=
207   for a in $SWIG_FLAGS ; do
208     case $a in
209     -I*)
210       d=`echo "x$a"|sed 's/^x-I//'`
211       dnl Quote each entry in XAPIAN_HEADER_DIRS with "".
212       XAPIAN_HEADER_DIRS=$XAPIAN_HEADER_DIRS' "'$d'"'
213       for f in "$d/"*.h "$d/xapian/*.h" ; do
214         if test -f "$f" ; then
215           XAPIAN_HEADERS="$XAPIAN_HEADERS $f"
216         fi
217       done
218       ;;
219     esac
220   done
221   AC_SUBST([XAPIAN_HEADER_DIRS])
222   AC_SUBST([XAPIAN_HEADERS])
224   dnl Need perl in maintainer mode to generate the except.i file for python.
225   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
226   test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
227   dnl Need doxygen in maintainer mode to convert C++ doxygen comments to Python
228   dnl docstrings.
229   AC_PATH_PROG(DOXYGEN, doxygen, [])
230   test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
233 AC_ARG_WITH(python,
234   AC_HELP_STRING([--with-python], [enable Python 2 bindings]),
235   [],
236   [with_python=])
238 AC_ARG_WITH(python3,
239   AC_HELP_STRING([--with-python3], [enable Python 3 bindings]),
240   [],
241   [with_python3=])
243 AC_ARG_WITH(php,
244   AC_HELP_STRING([--with-php], [enable PHP 5 bindings]),
245   [],
246   [with_php=])
248 AC_ARG_WITH(php7,
249   AC_HELP_STRING([--with-php7], [enable PHP 7 bindings]),
250   [],
251   [with_php7=])
253 AC_ARG_WITH(ruby,
254   AC_HELP_STRING([--with-ruby], [enable Ruby bindings]),
255   [],
256   [with_ruby=])
258 AC_ARG_WITH(tcl,
259   AC_HELP_STRING([--with-tcl], [enable Tcl bindings]),
260   [],
261   [with_tcl=])
263 AC_ARG_WITH(csharp,
264   AC_HELP_STRING([--with-csharp], [enable CSharp bindings]),
265   [],
266   [with_csharp=])
268 AC_ARG_WITH(java,
269   AC_HELP_STRING([--with-java], [enable Java bindings]),
270   [],
271   [with_java=])
273 AC_ARG_WITH(perl,
274   AC_HELP_STRING([--with-perl], [enable Perl bindings]),
275   [],
276   [with_perl=])
278 AC_ARG_WITH(lua,
279   AC_HELP_STRING([--with-lua], [enable Lua bindings]),
280   [],
281   [with_lua=])
283 case $with_python$with_python3$with_php$with_php7$with_ruby$with_tcl$with_csharp$with_java$with_perl$with_lua in
284 *yes*)
285   dnl Default unspecified values to no.
286   test -z "$with_python" && with_python=no
287   test -z "$with_python3" && with_python3=no
288   test -z "$with_php" && with_php=no
289   test -z "$with_php7" && with_php7=no
290   test -z "$with_tcl" && with_tcl=no
291   test -z "$with_csharp" && with_csharp=no
292   test -z "$with_java" && with_java=no
293   test -z "$with_ruby" && with_ruby=no
294   test -z "$with_perl" && with_perl=no
295   test -z "$with_lua" && with_lua=no
296   ;;
297 esac
299 BINDINGS=
301 if test no != "$with_python" ; then
302   dnl For backward compatibility:
303   : ${PYTHON2="$PYTHON"}
304   : ${PYTHON2_INC="$PYTHON_INC"}
305   : ${PYTHON2_LIB="$PYTHON_LIB"}
306   : ${PYTHON2_LIBS="$PYTHON_LIBS"}
307   : ${PYTHON2_SO="$PYTHON_SO"}
308   dnl See comment for AC_PATH_PROGS(SWIG, ...).
309   if test -n "$PYTHON2" ; then
310     AC_PATH_PROGS(PYTHON2, ["$PYTHON2"], [])
311   else
312     AC_PATH_PROGS(PYTHON2, [python2 python], [])
313   fi
314   AC_ARG_VAR(PYTHON2, [Python 2 interpreter])
315   if test -n "$PYTHON2" ; then
316     dnl Require Python 2.6 or newer.  Older versions are essentially
317     dnl unsupported upstream.
318     AC_MSG_CHECKING([$PYTHON2 version])
319     version=`$PYTHON2 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
320     case $version in
321     [2.[6-9]*|2.[1-5][0-9]*])
322       AC_MSG_RESULT([$version])
323       ;;
324     [[3-9].*])
325       AC_MSG_RESULT([$version (too new - use --with-python3 for Python 3 support)])
326       if test yes = "$with_python" ; then
327         AC_MSG_ERROR([Use --with-python3 for Python 3 support ($PYTHON2 is $version)])
328       fi
329       PYTHON2=
330       ;;
331     *)
332       AC_MSG_RESULT([$version (too old)])
333       if test yes = "$with_python" ; then
334         AC_MSG_ERROR([Only Python 2.6 or newer is supported ($PYTHON2 is $version)])
335       fi
336       PYTHON2=
337       ;;
338     esac
339     if test -n "$PYTHON2" ; then
340       if $PYTHON2 -c 'import distutils.sysconfig' 2>/dev/null ; then
341         PYTHON2_INC=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
342         AC_SUBST(PYTHON2_INC)
343       else
344         if test yes = "$with_python" ; then
345           AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python-dev or python-devel package])
346         else
347           AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python-dev or python-devel package installed])
348           PYTHON2=
349         fi
350       fi
351     fi
352     AC_MSG_CHECKING([for python2 sphinx module])
353     if $PYTHON2 -c 'import sphinx;print(repr(sphinx.main))' >&5 2>&5 ; then
354       AC_MSG_RESULT([yes])
355     else
356       AC_MSG_RESULT([no])
357       if test yes = "$with_python2" ; then
358         AC_MSG_ERROR([Couldn't import sphinx module and call sphinx.main() for Python2 - try package python-sphinx])
359       fi
360       PYTHON2=
361     fi
362     if test -n "$PYTHON2" ; then
363       dnl Check that Python.h is there, which is a good way to check that
364       dnl the appropriate python-dev package has been installed.
365       AC_MSG_CHECKING([for $PYTHON2_INC/Python.h])
366       if test -f "$PYTHON2_INC/Python.h" ; then
367         AC_MSG_RESULT(yes)
368         AC_MSG_CHECKING([for directory to install python2 bindings in])
369         if test -z "$PYTHON2_LIB" ; then
370           PYTHON2_LIB=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
371         fi
372         AC_MSG_RESULT([$PYTHON2_LIB])
373         AC_ARG_VAR(PYTHON2_LIB, [Directory to install python2 bindings in])
375         AC_MSG_CHECKING([for python2 libraries to link against])
376         case $host_os in
377         mingw* | pw32*)
378           PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
379         cygwin*)
380           PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
381         *)
382           PYTHON2_LIBS= ;;
383         esac
384         AC_SUBST(PYTHON2_LIBS)
385         AC_MSG_RESULT([$PYTHON2_LIBS])
387         AC_MSG_CHECKING([for python2 module extension])
388         dnl Usually ".so", but for example, Mac OS X uses ".dylib".
389         PYTHON2_SO=`$PYTHON2 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
390         AC_SUBST(PYTHON2_SO)
391         AC_MSG_RESULT([$PYTHON2_SO])
392         BINDINGS="$BINDINGS python"
393       else
394         AC_MSG_RESULT([no (install python-dev or python-devel package or similar)])
395         if test yes = "$with_python" ; then
396           AC_MSG_ERROR([Python.h not found])
397         fi
398       fi
399     fi
400   fi
403 if test no != "$with_python3" ; then
404   dnl See comment for AC_PATH_PROGS(SWIG, ...).
405   if test -n "$PYTHON3" ; then
406     AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
407   else
408     AC_PATH_PROGS(PYTHON3, [python3 python], [])
409   fi
410   AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
411   if test -n "$PYTHON3" ; then
412     dnl Require Python 3.2 or newer, as that's the oldest version we can
413     dnl easily test with.  If anyone's keen to support older versions, please
414     dnl test and send in any patches needed to get it to work.
415     AC_MSG_CHECKING([$PYTHON3 version])
416     version=`$PYTHON3 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
417     case $version in
418     [3.[2-9]*|3.1[0-9]*|[4-9].*])
419       AC_MSG_RESULT([$version])
420       ;;
421     *)
422       AC_MSG_RESULT([$version (too old)])
423       if test yes = "$with_python3" ; then
424         AC_MSG_ERROR([Only Python 3.2 or newer is supported ($python3 is $version)])
425       fi
426       PYTHON3=
427       ;;
428     esac
429     if test -n "$PYTHON3" ; then
430       if $PYTHON3 -c 'import distutils.sysconfig' 2>/dev/null ; then
431         PYTHON3_INC=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
432         AC_SUBST(PYTHON3_INC)
433       else
434         if test yes = "$with_python3" ; then
435           AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python3-dev or python3-devel package])
436         else
437           AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python3-dev or python3-devel package installed])
438           PYTHON3=
439         fi
440       fi
441     fi
442     AC_MSG_CHECKING([for python3 sphinx module])
443     if $PYTHON3 -c 'import sphinx;print(repr(sphinx.main))' >&5 2>&5 ; then
444       AC_MSG_RESULT([yes])
445     else
446       AC_MSG_RESULT([no])
447       if test yes = "$with_python3" ; then
448         AC_MSG_ERROR([Couldn't import sphinx module and call sphinx.main() for Python3 - try package python3-sphinx])
449       fi
450       PYTHON3=
451     fi
452     if test -n "$PYTHON3" ; then
453       dnl Check that Python.h is there, which is a good way to check that
454       dnl the appropriate python3-dev package has been installed.
455       AC_MSG_CHECKING([for $PYTHON3_INC/Python.h])
456       if test -f "$PYTHON3_INC/Python.h" ; then
457         AC_MSG_RESULT(yes)
458         AC_MSG_CHECKING([for directory to install python3 bindings in])
459         if test -z "$PYTHON3_LIB" ; then
460           PYTHON3_LIB=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
461         fi
462         AC_MSG_RESULT([$PYTHON3_LIB])
463         AC_ARG_VAR(PYTHON3_LIB, [Directory to install python3 bindings in])
465         AC_MSG_CHECKING([for python3 libraries to link against])
466         case $host_os in
467         mingw* | pw32*)
468           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
469         cygwin*)
470           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
471         *)
472           PYTHON3_LIBS= ;;
473         esac
474         AC_SUBST(PYTHON3_LIBS)
475         AC_MSG_RESULT([$PYTHON3_LIBS])
477         AC_MSG_CHECKING([for python3 module extension])
478         dnl Usually ".so", but for example, Mac OS X uses ".dylib".
479         PYTHON3_SO=`$PYTHON3 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
480         AC_SUBST(PYTHON3_SO)
481         AC_MSG_RESULT([$PYTHON3_SO])
483         AC_MSG_CHECKING([for tag for cached compiled scripts])
484         PYTHON3_CACHE_TAG=`$PYTHON3 -c 'import imp;print(imp.get_tag())'`
485         AC_SUBST(PYTHON3_CACHE_TAG)
486         AC_MSG_RESULT([$PYTHON3_CACHE_TAG])
488         AC_MSG_CHECKING([for extension of cached and optimized python3 bytecode])
489         PYTHON3_CACHE_OPT1_EXT=`$PYTHON3 -c 'import imp,sys;print("%s.pyo"%imp.get_tag()) if sys.version_info.minor<5 else print("{1}{2}".format(*imp.util.cache_from_source("",optimization=1).rpartition(imp.get_tag())))'`
490         AC_SUBST(PYTHON3_CACHE_OPT1_EXT)
491         AC_MSG_RESULT([$PYTHON3_CACHE_OPT1_EXT])
493         BINDINGS="$BINDINGS python3"
494       else
495         AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
496         if test yes = "$with_python3" ; then
497           AC_MSG_ERROR([Python.h not found])
498         fi
499       fi
500     fi
501   fi
504 if test x$USE_MAINTAINER_MODE = xyes; then
505   dnl Need python in maintainer mode to run doxy2swig.py.
506   dnl Either Python 2 or 3 is OK for this.
507   if test -n "$PYTHON2" ; then
508     PYTHON=$PYTHON2
509   elif test -n "$PYTHON3" ; then
510     PYTHON=$PYTHON3
511   else
512     AC_PATH_PROGS(PYTHON, [python2 python python3], [])
513   fi
514   test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
517 if test no != "$with_php" ; then
518   dnl See comment for AC_PATH_PROGS(SWIG, ...).
519   if test -n "$PHP_CONFIG" ; then
520     AC_PATH_PROGS(PHP_CONFIG, ["$PHP_CONFIG"], [])
521   fi
522   if test -z "$PHP_CONFIG" ; then
523     AC_PATH_PROGS(PHP_CONFIG, [php-config5 php-config], [])
524   fi
525   AC_ARG_VAR(PHP_CONFIG, [php-config utility for PHP5])
526   AC_ARG_VAR(PHP, [PHP5 interpreter (optional - only needed to run PHP5 testsuite with)])
527   if test -n "$PHP_CONFIG" ; then
528     AC_MSG_CHECKING([$PHP_CONFIG version])
529     version=`$PHP_CONFIG --version 2>/dev/null`
530     case $version in
531     [[01234].*|5.[01234].*|[6789].*])
532       AC_MSG_RESULT([$version (not supported, PHP5 bindings need PHP 5.x where x >= 5)])
533       if test yes = "$with_php" ; then
534         AC_MSG_ERROR([$PHP_CONFIG reports version $version - PHP5 bindings need PHP 5.x where x >= 5])
535       fi
536       with_php=no
537       ;;
538     *)
539       AC_MSG_RESULT([$version])
540       PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
541       ;;
542     esac
543     AC_SUBST(PHP_MAJOR_VERSION)
545     if test no != "$with_php" ; then
546       AC_MSG_CHECKING([for PHP5 extension directory])
547       if test -z "$PHP_EXTENSION_DIR" ; then
548         PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
549       fi
550       AC_MSG_RESULT([$PHP_EXTENSION_DIR])
551       AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP5 extensions in])
552     fi
554     if test no != "$with_php" ; then
555       PHP_INC=`$PHP_CONFIG --includes`
556       AC_SUBST(PHP_INC)
557       save_CPPFLAGS=$CPPFLAGS
558       CPPFLAGS="$CPPFLAGS $PHP_INC"
559       dnl One of SGI's SuSE boxes has php-config but no headers.
560       AC_CHECK_HEADER(zend.h, [], [
561         if test yes = "$with_php" ; then
562           AC_MSG_ERROR(['$PHP_CONFIG --includes' reports '$PHP_INC' but zend.h can't be included from there])
563         fi
564         with_php=no], [ ])
565       CPPFLAGS=$save_CPPFLAGS
566     fi
568     if test no != "$with_php" ; then
569       if test x"$PHP" = x ; then
570         AC_MSG_CHECKING([for PHP5 interpreter])
571         dnl PHP5's php-config supports --php-binary, so just use that.
572         PHP=`$PHP_CONFIG --php-binary 2>/dev/null`
573         if test x"$PHP" != x ; then
574           if $PHP -r 'exit(0);' 2> /dev/null ; then
575             if $PHP -r 'exit(PHP_MAJOR_VERSION==5?0:1);' 2> /dev/null ; then
576               AC_MSG_RESULT([$PHP])
577             else
578               dnl We get /usr/bin/php on Debian, which might be PHP7:
579               dnl https://bugs.debian.org/819139
580               if ${PHP}5 -r 'exit(PHP_MAJOR_VERSION==5?0:1);' 2> /dev/null ; then
581                 PHP=${PHP}5
582                 AC_MSG_RESULT([$PHP])
583               else
584                 AC_MSG_RESULT([no ($PHP isn't PHP5)])
585                 PHP=
586               fi
587             fi
588           else
589             AC_MSG_RESULT([no ($PHP does not work)])
590             PHP=
591           fi
592         else
593           AC_MSG_RESULT([not found])
594         fi
595       else
596         AC_PATH_PROGS(PHP, ["$PHP"], [])
597       fi
598       if test x"$PHP" = x ; then
599         AC_MSG_WARN([No PHP5 interpreter found - PHP5 bindings tests will be skipped])
600         dnl The skiptest script just returns exit code 77.
601         PHP='$(top_srcdir)/skiptest'
602       else
603         AC_MSG_CHECKING([for PHP5 path separator])
604         PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
605         AC_SUBST([PHP_PATH_SEPARATOR])
606         AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
607       fi
609       case $host_os in
610       mingw* | pw32*)
611         dnl This is a bit of an informed guess, pending more information from
612         dnl someone who actually has mingw and wants to build the PHP bindings
613         dnl there.  FIXME.
614         PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
615       cygwin*)
616         PHP_LIBS="-lphp${PHP_MAJOR_VERSION}lib" ;;
617       *)
618         PHP_LIBS= ;;
619       esac
620       AC_SUBST(PHP_LIBS)
621       BINDINGS="$BINDINGS php"
622     fi
623   fi
626 if test no != "$with_php7" ; then
627   dnl See comment for AC_PATH_PROGS(SWIG, ...).
628   if test -n "$PHP_CONFIG7" ; then
629     AC_PATH_PROGS(PHP_CONFIG7, ["$PHP_CONFIG7"], [])
630   fi
631   if test -z "$PHP_CONFIG7" ; then
632     AC_PATH_PROGS(PHP_CONFIG7, [php-config7.1 php-config7.0 php-config], [])
633   fi
634   AC_ARG_VAR(PHP_CONFIG7, [php-config utility for PHP7])
635   AC_ARG_VAR(PHP7, [PHP7 interpreter (optional - only needed to run PHP7 testsuite with)])
636   if test -n "$PHP_CONFIG7" ; then
637     AC_MSG_CHECKING([$PHP_CONFIG7 version])
638     version=`$PHP_CONFIG7 --version 2>/dev/null`
639     case $version in
640     [[0123456].*])
641       AC_MSG_RESULT([$version (not supported, PHP7 bindings need PHP >= 7.0)])
642       if test yes = "$with_php7" ; then
643         AC_MSG_ERROR([$PHP_CONFIG7 reports version $version - PHP7 bindings need >= 7.0])
644       fi
645       with_php7=no
646       ;;
647     *)
648       AC_MSG_RESULT([$version])
649       PHP7_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
650       ;;
651     esac
652     AC_SUBST(PHP7_MAJOR_VERSION)
654     if test no != "$with_php7" ; then
655       AC_MSG_CHECKING([for PHP7 extension directory])
656       if test -z "$PHP7_EXTENSION_DIR" ; then
657         PHP7_EXTENSION_DIR=`$PHP_CONFIG7 --extension-dir`
658       fi
659       AC_MSG_RESULT([$PHP7_EXTENSION_DIR])
660       AC_ARG_VAR(PHP7_EXTENSION_DIR, [Directory to install PHP7 extensions in])
661     fi
663     if test no != "$with_php7" ; then
664       PHP7_INC=`$PHP_CONFIG7 --includes`
665       AC_SUBST(PHP7_INC)
666     fi
668     if test no != "$with_php7" ; then
669       if test x"$PHP7" = x ; then
670         AC_MSG_CHECKING([for PHP7 interpreter])
671         dnl PHP7's php-config supports --php-binary, so just use that.
672         PHP7=`$PHP_CONFIG7 --php-binary 2>/dev/null`
673         if test x"$PHP7" != x ; then
674           if $PHP7 -r 'exit(0);' 2> /dev/null ; then
675             if $PHP7 -r 'exit(PHP_MAJOR_VERSION==7?0:1);' 2> /dev/null ; then
676               AC_MSG_RESULT([$PHP7])
677             else
678               AC_MSG_RESULT([no ($PHP7 isn't PHP7)])
679               PHP7=
680             fi
681           else
682             AC_MSG_RESULT([no ($PHP7 does not work)])
683             PHP7=
684           fi
685         else
686           AC_MSG_RESULT([not found])
687         fi
688       else
689         AC_PATH_PROGS(PHP7, ["$PHP7"], [])
690       fi
691       if test x"$PHP7" = x ; then
692         AC_MSG_WARN([No PHP7 interpreter found - PHP7 bindings tests will be skipped])
693         dnl The skiptest script just returns exit code 77.
694         PHP7='$(top_srcdir)/skiptest'
695       else
696         AC_MSG_CHECKING([for PHP7 path separator])
697         PHP7_PATH_SEPARATOR=`$PHP7 -r 'echo PATH_SEPARATOR;'`
698         AC_SUBST([PHP7_PATH_SEPARATOR])
699         AC_MSG_RESULT([$PHP7_PATH_SEPARATOR])
700       fi
702       case $host_os in
703       mingw* | pw32*)
704         dnl This is a bit of an informed guess, pending more information from
705         dnl someone who actually has mingw and wants to build the PHP bindings
706         dnl there.  FIXME.
707         PHP7_LIBS="-L`$PHP_CONFIG7 --prefix` -lphp${PHP7_MAJOR_VERSION}ts" ;;
708       cygwin*)
709         PHP7_LIBS="-lphp${PHP7_MAJOR_VERSION}lib" ;;
710       *)
711         PHP7_LIBS= ;;
712       esac
713       AC_SUBST(PHP7_LIBS)
714       BINDINGS="$BINDINGS php7"
715     fi
716   fi
719 if test no != "$with_tcl" ; then
720   dnl The documented minimum requirement is Tcl 8.5.  Older versions may work,
721   dnl but we don't test with them regularly, and they are no longer supported
722   dnl upstream.  Also ::tcl::pckconfig was added in Tcl 8.5, which makes the
723   dnl tests below simpler and more reliable.
724   dnl
725   dnl If you really want to build with an older version, run configure with
726   dnl a lower tcl_min and specify at least TCL_INC explicitly:
727   dnl
728   dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
729   dnl
730   dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
731   : ${tcl_min=8.5}
732   AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
733   AC_ARG_VAR(TCLSH, [Tcl interpreter])
734   if test -n "$TCLSH" ; then
735     AC_MSG_CHECKING([$TCLSH version])
736     if echo 'if {$tcl_version < '"$tcl_min"' } { exit 1 }'|$TCLSH 2> /dev/null ; then
737       tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
738       AC_MSG_RESULT([$tcl_version])
740       AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
741       if test -z "$TCL_LIB" ; then
742         [TCL_LIB=`echo 'foreach d $tcl_pkgPath {if {![regexp {/share(/|$)} $d]} {break}};puts $d'|$TCLSH`]
743       fi
744       AC_SUBST(TCL_LIB)
746       AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
747       if test -z "$TCL_INC" ; then
748         dnl ::tcl::pkgconfig was added in Tcl 8.5.
749         [TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
750       fi
752       dnl Check that the headers are there (the tcl8.N-dev package
753       dnl may not be installed).
754       TCL_CPPFLAGS=
755       AC_MSG_CHECKING([for tcl.h from Tcl $tcl_version])
756       if test x"$TCL_INC" != x && test -f "$TCL_INC/tcl.h" ; then
757         tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
758         if test x"$tcl_hdr_version" = x"$tcl_version" ; then
759           AC_MSG_RESULT([$TCL_INC/tcl.h])
760           BINDINGS="$BINDINGS tcl8"
761           if test x"$TCL_INC" != x"/usr/include" ; then
762             TCL_CPPFLAGS="-I$TCL_INC"
763           fi
764         else
765           AC_MSG_RESULT([not found])
766           if test yes = "$with_tcl" ; then
767             AC_MSG_ERROR([Found tcl.h from version $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
768           fi
769           TCLSH=
770         fi
771       else
772         AC_MSG_RESULT([not found])
773         if test yes = "$with_tcl" ; then
774           AC_MSG_ERROR([Can't find tcl.h])
775         fi
776         TCLSH=
777       fi
779       if test -n "$TCLSH" ; then
780         dnl Cygwin needs to link with -ltcl8.5 or similar.
781         TCL_LIBS=
782         case $host_os in
783         cygwin*)
784           AC_CHECK_LIB([tcl$tcl_version], [Tcl_Init],
785                        [TCL_LIBS="-ltcl$tcl_version"],
786                        [AC_MSG_ERROR([libtcl$tcl_version not found])])
787           ;;
788         *)
789           dnl ::tcl::pkgconfig was added in Tcl 8.5, but prior to 8.6 it isn't
790           dnl necessary to link against -ltclstub anyway.
791           [tcl_libdir_runtime=`echo 'puts [::tcl::pkgconfig get libdir,runtime]'|$TCLSH 2> /dev/null`]
792           if test -n "$tcl_libdir_runtime" ; then
793             for x in "/tcl$tcl_version" "" ; do
794               TCLCONFIG_SH=$tcl_libdir_runtime$x/tclConfig.sh
795               if test -r "$TCLCONFIG_SH" ; then
796                 eval "`sed 's/^TCL_STUB_LIB_SPEC=/TCL_LIBS=/p;d' $TCLCONFIG_SH`"
797                 break
798               fi
799             done
800           fi
801           TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS" ;;
802         esac
803       fi
805       AC_SUBST(TCL_CPPFLAGS)
806       AC_SUBST(TCL_LIBS)
807     else
808       AC_MSG_RESULT([< $tcl_min (too old)])
809       if test yes = "$with_tcl" ; then
810         AC_MSG_ERROR([$TCLSH too old (Tcl $tcl_min or newer required)])
811       fi
812     fi
813   else
814     if test yes = "$with_tcl" ; then
815       AC_MSG_ERROR([tclsh not found])
816     fi
817   fi
820 if test no != "$with_csharp" ; then
821   csc_note=
822   AC_ARG_VAR(CSC, [CSharp compiler command])
823   if test -n "$CSC" ; then
824     AC_PATH_PROGS(CSC, ["$CSC"], [])
825   fi
826   if test -z "$CSC" ; then
827     dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
828     dnl as "alternatives" which can be mapped to the CSharp compiler the admin
829     dnl favours.
830     AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
831     if test -z "$CSC" ; then
832       dnl mcs is the Mono CSharp compiler, which is a unified compiler
833       dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
834       dnl that's no longer relevant).
835       AC_PATH_PROGS(CSC, [mcs], [])
836       if test -n "$CSC" ; then
837         dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
838         dnl so we check that the mcs we found understands --version which is
839         dnl sufficient to distinguish mono's mcs from the Tru64 one.
840         AC_MSG_CHECKING([whether $CSC is from GNU Mono])
841         if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
842           AC_MSG_RESULT(yes)
843         else
844           AC_MSG_RESULT(no)
845           CSC=
846           csc_note="$csc_note (found different mcs program)"
847         fi
848       fi
849     fi
850     if test -z "$CSC" ; then
851       dnl csc is the Microsoft CSharp compiler.
852       AC_PATH_PROGS(CSC, [csc], [])
853       if test -n "$CSC" ; then
854         dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
855         dnl check if the output from "csc -version" includes the word chicken
856         dnl which is sufficient to distinguish Chicken's csc from Microsoft's
857         dnl csc.exe.
858         AC_MSG_CHECKING([whether $CSC is for CSharp])
859         if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
860           AC_MSG_RESULT(no)
861           CSC=
862           csc_note="$csc_note (found Chicken csc program)"
863         else
864           AC_MSG_RESULT(yes)
865         fi
866       fi
867     fi
868   fi
870   if test -n "$CSC" ; then
871     AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
872     if test -n "$GACUTIL" ; then
873       AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
874     fi
875     if test -z "$GACUTIL" ; then
876       AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil], [])
877     fi
879     AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
880     if test -n "$SN" ; then
881       AC_PATH_PROGS(SN, ["$SN"], [])
882     fi
883     if test -z "$SN" ; then
884       AC_PATH_PROGS(SN, [cli-sn sn], [])
885     fi
886     if test -n "$GACUTIL" -a -n "$SN" ; then
887       AC_MSG_CHECKING([whether the CSharp compiler works])
888       [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
889       if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
890         AC_MSG_RESULT(yes)
891         AC_MSG_CHECKING([whether CSharp programs can just be run])
892         if test OK = "`./conftest.exe 2> /dev/null`" ; then
893           AC_MSG_RESULT(yes)
894           RUN_CSHARP=
895         else
896           AC_MSG_RESULT(no)
897           AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
898           if test -z "$CLI" ; then
899             AC_PATH_PROGS(CLI, [mono ilrun], [])
900           fi
901           AC_ARG_VAR(CLI, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
902           if test -n "$CLI" ; then
903             AC_MSG_CHECKING([whether $CLI can run CSharp programs])
904             if test OK = "`$CLI ./conftest.exe 2> /dev/null`" ; then
905               AC_MSG_RESULT(yes)
906               RUN_CSHARP=$CLI
907             else
908               AC_MSG_RESULT([no - CSharp tests will be skipped])
909               RUN_CSHARP='\$(top_srcdir)/skiptest'
910             fi
911           else
912             AC_MSG_RESULT([not found - CSharp tests will be skipped])
913             RUN_CSHARP='\$(top_srcdir)/skiptest'
914           fi
915         fi
916         AC_SUBST(RUN_CSHARP)
918         AC_MSG_CHECKING([for extra flags for $GACUTIL])
919         GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
920         dnl Microsoft's gacutil accepts fewer options than Mono's
921         $GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
922         AC_SUBST([GACUTIL_FLAGS])
923         if test -z "$GACUTIL_FLAGS" ; then
924           AC_MSG_RESULT([no])
925         else
926           AC_MSG_RESULT([$GACUTIL_FLAGS])
927         fi
929         BINDINGS="$BINDINGS csharp"
930       else
931         AC_MSG_RESULT(no)
932         if test yes = "$with_csharp" ; then
933           AC_MSG_ERROR([CSharp compiler $CSC doesn't work])
934         fi
935       fi
936     else
937       if test yes = "$with_csharp" ; then
938         if test -z "$GACUTIL" ; then
939           AC_MSG_ERROR([Mono gacutil not found])
940         elif test -z "$SN" ; then
941           AC_MSG_ERROR([Mono sn not found])
942         fi
943       fi
944     fi
945   else
946     if test yes = "$with_csharp" ; then
947       AC_MSG_ERROR([CSharp compiler not found$csc_note])
948     fi
949   fi
952 JAVA_CPPFLAGS=
953 if test no != "$with_java" ; then
954   AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
955         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
956   AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
957         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
958   AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
959         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
960   AC_ARG_VAR(JAVA, [Java interpreter command])
961   AC_ARG_VAR(JAVAC, [Java compiler command])
962   AC_ARG_VAR(JAR, [java jar utility])
963   AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
964   AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
965   AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
966   if test -n "$JAVA" -a -n "$JAVAC" -a -n "$JAR" ; then
967     dnl Eric says:
968     dnl  The JNI library *requires* "Java 2", which is 1.2 or better.
969     dnl
970     dnl So checking for jni.h presumably implicitly checks we have "Java 2".
971     dnl Note: jni.h #defines JNI_VERSION_1_[12468] (but not 3, 5 or 7 it seems).
972     dnl So we could check for one of these if we want to check for a particular
973     dnl JDK version...
974     java_ok=no
975     AC_CHECK_HEADER([jni.h], [java_ok=yes], [
976       dnl We need to look for jni.h in /usr/lib/jvm/java-gcj/include on some
977       dnl Debian and Ubuntu boxes at least.  And on Mac OS X, jni.h lives
978       dnl in /System/Library/Frameworks/JavaVM.framework/Headers.
979       SAVE_CPPFLAGS=$CPPFLAGS
980       real_javac=$JAVAC
981       dnl Avoid endlessly traversing if there's a symlink loop.
982       for count in 1 2 3 4 5 6 7 8 9 ; do
983         r=`readlink "$real_javac"`
984         test -n "$r" || break
985         real_javac=$r
986       done
987       dnl Translate ".../bin/javac" to ".../include".
988       [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
989       for jnidir in \
990           $JNI_INCLUDE_DIR \
991           ${JAVA_HOME+"$JAVA_HOME/include"} \
992           ${JDK_HOME+"$JDK_HOME/include"} \
993           "$rel_jnidir" \
994           /System/Library/Frameworks/JavaVM.framework/Headers ; do
995         CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
996         AC_MSG_CHECKING([for jni.h in $jnidir])
997         if test -f "$jnidir/jni.h" ; then
998           AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
999           if test yes = $java_ok ; then
1000             AC_MSG_RESULT([yes])
1001             JAVA_CPPFLAGS=-I$jnidir
1002             break
1003           fi
1005           dnl For OpenJDK (and maybe others) we have to specify an extra -I
1006           dnl option for an OS-specific subdirectory containing a "jni_md.h"
1007           dnl header which is included by "jni.h".  Sadly we seem to need to
1008           dnl hardcode a mapping for these platform names - the list below
1009           dnl was determined by inspecting the source code of OpenJDK 8.
1010           jni_host_os=
1011           case $host_os in
1012             linux*)
1013               jni_host_os=linux ;;
1014             solaris*)
1015               jni_host_os=solaris ;;
1016             mingw* | pw32* | cygwin*)
1017               jni_host_os=win32 ;;
1018             darwin*)
1019               jni_host_os=darwin ;;
1020             *bsd*)
1021               jni_host_os=bsd ;;
1022             aix*)
1023               jni_host_os=aix ;;
1024           esac
1025           if test -n "$jni_host_os" ; then
1026             CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
1027             AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
1028             if test yes = $java_ok ; then
1029               AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
1030               JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
1031               break
1032             fi
1033           fi
1034           AC_MSG_RESULT([found, but not usable])
1036           CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
1037         else
1038           AC_MSG_RESULT([no])
1039         fi
1040       done
1041       CPPFLAGS=$SAVE_CPPFLAGS
1042       test noyes = $java_ok$with_java && AC_MSG_ERROR([jni.h not found])
1043       ], [ ])
1044     AC_SUBST(JAVA_CPPFLAGS)
1045     if test yes = $java_ok ; then
1046       AC_MSG_CHECKING([for Java path separator])
1047       [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
1048       if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
1049         JAVA_PATHSEP=`$JAVA conftest 2>&5`
1050         AC_SUBST(JAVA_PATHSEP)
1051         if test -n "$JAVA_PATHSEP" ; then
1052           AC_MSG_RESULT($JAVA_PATHSEP)
1053           BINDINGS="$BINDINGS java"
1055           dnl Optional, we run tests with it enabled if it's supported.
1056           AC_MSG_CHECKING([for $JAVA -Xcheck:jni option])
1057           JAVA_PATHSEP2=`$JAVA conftest 2>&5`
1058           JAVA_CHECK_JNI_OPTION=
1059           if test "$JAVA_PATHSEP" = "$JAVA_PATHSEP2" ; then
1060             JAVA_CHECK_JNI_OPTION=-Xcheck:jni
1061             AC_MSG_RESULT([yes])
1062           else
1063             AC_MSG_RESULT([no])
1064           fi
1065           AC_SUBST([JAVA_CHECK_JNI_OPTION])
1066         else
1067           AC_MSG_RESULT([failed to run test program])
1068           java_ok=no
1069         fi
1070       else
1071         AC_MSG_RESULT([failed to compile test program])
1072         java_ok=no
1073       fi
1074       if test no = "$java_ok" ; then
1075         test yes = "$with_java" && AC_MSG_ERROR([Couldn't compile and run a simple Java test program])
1076       fi
1077     fi
1078   else
1079     if test yes = "$with_java" ; then
1080       if test -z "$JAVA" ; then
1081         AC_MSG_ERROR([java not found])
1082       elif test -z "$JAVAC" ; then
1083         AC_MSG_ERROR([javac not found])
1084       elif test -z "$JAR" ; then
1085         AC_MSG_ERROR([jar not found])
1086       fi
1087     fi
1088   fi
1091 if test no != "$with_ruby" ; then
1092   dnl See comment for AC_PATH_PROGS(SWIG, ...).
1093   if test -n "$RUBY" ; then
1094     AC_PATH_PROGS(RUBY, ["$RUBY"], [])
1095   else
1096     AC_PATH_PROGS(RUBY, [ruby], [])
1097   fi
1098   AC_ARG_VAR(RUBY, [Ruby interpreter])
1099   if test -n "$RUBY" ; then
1100     dnl Require Ruby 2.1 or newer.
1101     AC_MSG_CHECKING([$RUBY version])
1102     dnl RUBY_VERSION works with 1.6.  Once we've checked we have at least 1.8
1103     dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8).
1104     version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
1105     case $version in
1106     "")
1107       AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work])
1108       if test yes = "$with_ruby" ; then
1109         AC_MSG_ERROR([Working Ruby interpreter not found])
1110       fi
1111       RUBY=
1112       ;;
1113     [[01].*|2.0.*])
1114       AC_MSG_RESULT([$version (too old)])
1115       if test yes = "$with_ruby" ; then
1116         AC_MSG_ERROR([Only Ruby 2.1 or newer is supported ($RUBY is $version)])
1117       fi
1118       RUBY=
1119       ;;
1120     esac
1121     if test -n "$RUBY" ; then
1122       AC_MSG_RESULT([$version])
1123       AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
1124       if test -z "$RUBY_INC" ; then
1125         dnl Ruby 1.9 added rubyhdrdir.
1126         [RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]'`]
1127       fi
1128       AC_SUBST(RUBY_INC)
1129       dnl Check that ruby.h is there, which is a good way to check that
1130       dnl the appropriate ruby-dev package has been installed.
1131       AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
1132       if test -f "$RUBY_INC/ruby.h" ; then
1133         AC_MSG_RESULT(yes)
1135         AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found])
1136         if test -z "$RUBY_INC_ARCH" ; then
1137           dnl Ruby 2.0 and later have rubyarchhdrdir.
1138           [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]'`]
1139         fi
1140         AC_SUBST(RUBY_INC_ARCH)
1142         AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
1143         if test -z "$RUBY_LIB" ; then
1144           [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
1145         fi
1146         AC_SUBST(RUBY_LIB)
1148         AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
1149         if test -z "$RUBY_LIB_ARCH" ; then
1150           [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
1151         fi
1152         AC_SUBST(RUBY_LIB_ARCH)
1154         RUBY_LIBS=
1155         if test unsupported = "$allow_undefined_flag" ; then
1156           dnl For Microsoft Windows and a few other platforms.
1157           [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
1158         fi
1159         AC_SUBST(RUBY_LIBS)
1161         dnl rdoc is included as part of the Ruby core distribution, so run it
1162         dnl at build time rather shipping the rather large generated output in
1163         dnl our source tarball.
1164         if test -n "$RDOC" ; then
1165           AC_PATH_PROGS(RDOC, ["$RDOC"], [])
1166         else
1167           dnl Try replace the *last* 'ruby' with 'rdoc'.
1168           rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
1169           AC_PATH_PROGS(RDOC, ["$rdoc_best_guess"], [])
1170           if test -z "$RDOC"; then
1171             AC_PATH_PROGS(RDOC, [rdoc], [])
1172           fi
1173         fi
1174         if test -n "$RDOC"; then
1175           BINDINGS="$BINDINGS ruby"
1176         fi
1177       else
1178         AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
1179         if test yes = "$with_ruby" ; then
1180           AC_MSG_ERROR([ruby.h not found])
1181         fi
1182       fi
1183       RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
1184       AC_SUBST(RUBY_DLEXT)
1185     fi
1186   fi
1189 if test no != "$with_perl" ; then
1190   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
1191   AC_ARG_VAR(PERL, [perl interpreter])
1192   if test -n "$PERL" ; then
1193     AC_PATH_PROGS(PROVE, ["${PROVE-prove}"], [])
1194     AC_ARG_VAR(PROVE, [Perl Test::Harness test runner])
1195     if test x"$PROVE" = x ; then
1196       AC_MSG_WARN([Perl 'prove' tool not found - Perl bindings tests will be skipped])
1197       dnl The skiptest script just returns exit code 77.
1198       PROVE='$(top_srcdir)/skiptest'
1199     fi
1201     if test -z "$PERL_INC" ; then
1202       PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
1203     fi
1204     AC_SUBST(PERL_INC)
1206     AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
1207     if test -z "$PERL_ARCH" ; then
1208       PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
1209     fi
1210     AC_SUBST(PERL_ARCH)
1212     AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
1213     if test -z "$PERL_LIB" ; then
1214       PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
1215     fi
1216     AC_SUBST(PERL_LIB)
1218     AC_ARG_VAR(PERL_SO, [Extension for compiled Perl modules])
1219     if test -z "$PERL_SO" ; then
1220       PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
1221     fi
1222     AC_SUBST(PERL_SO)
1224     if test -z "$PERL_XAPIAN_VERSION" ; then
1225       dnl snapshot versions look like 1.2.3_git123 or 1.2.3_svn14971
1226       case $PACKAGE_VERSION in
1227       *_git*)
1228         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
1229       *_svn*)
1230         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_svn/./'` ;;
1231       *)
1232         PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
1233       esac
1234     fi
1235     AC_SUBST(PERL_XAPIAN_VERSION)
1237     BINDINGS="$BINDINGS perl"
1238   else
1239     if test yes = "$with_perl" ; then
1240       AC_MSG_ERROR([perl not found])
1241     fi
1242   fi
1245 if test no != "$with_lua" ; then
1246   AC_PATH_PROGS(LUA, ["${LUA-lua}"], [])
1247   AC_ARG_VAR(LUA, [lua interpreter])
1248   if test -n "$LUA" ; then
1249     dnl We need Lua 5.1 or later.
1250     AC_MSG_CHECKING([$LUA version])
1251     lua_version=`$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' 2>&AS_MESSAGE_LOG_FD`
1253     case $lua_version in
1254     [[01234]].*|5.0|5.0.*)
1255       AC_MSG_RESULT([$lua_version < 5.1 (too old)])
1256       if test yes = "$with_lua" ; then
1257         AC_MSG_ERROR([$LUA too old (Lua 5.1 or newer required)])
1258       fi
1259       LUA=
1260       ;;
1261     "")
1262       AC_MSG_RESULT([\$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' didn't work])
1264       if test yes = "$with_lua" ; then
1265         AC_MSG_ERROR([Working Lua interpreter not found])
1266       fi
1267       LUA=
1268       ;;
1269     esac
1271     if test -n "$LUA" ; then
1272       AC_MSG_RESULT([$lua_version])
1274       AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
1275       AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
1276       AC_MSG_CHECKING([for directory to install compiled Lua modules into])
1277       if test -z "$LUA_LIB" -o -z "$LUA_SO" ; then
1278         lua_cpath=`$LUA -e 'require("package") print(package.cpath)'`
1279         dnl Look for the first absolute path in lua_cpath which has leaf
1280         dnl "?.<ext>" and put the directory part into lua_lib and <ext> into
1281         dnl lua_so.  If LUA_SO was specified by the user, only consider
1282         dnl entries where <ext> matches LUA_SO.
1283         lua_lib=
1284         lua_so=
1285         case $LUA_SO in
1286           "")
1287            [lua_so_pat='[a-zA-Z][a-zA-Z]*'] ;;
1288           .*)
1289             dnl If LUA_SO has a leading '.', remove it.
1290             lua_so_pat=`AS_ECHO("$LUA_SO")|sed 's/^\.//'` ;;
1291           *)
1292             dnl If LUA_SO was specified without a leading '.', add one to the
1293             dnl value substituted into Makefile.in.
1294             lua_so_pat=$LUA_SO
1295             LUA_SO=.$LUA_SO
1296             ;;
1297         esac
1298         while test x"$lua_cpath" != x ; do
1299           [lua_lib=`expr X"$lua_cpath" : X'\([^;]*\)'`]
1300           lua_so=.`expr X"$lua_lib" : X'/.*/?\.\('"$lua_so_pat"'\)$'`
1301           case $lua_so in
1302             .|.lua)
1303               dnl If someone has foolishly put ?.lua in cpath, ignore them.
1304               lua_lib=
1305               ;;
1306             *)
1307               lua_lib=`expr X"$lua_lib" : X'\(/.*\)/?\.'"$lua_so_pat"'$'`
1308               break ;;
1309           esac
1310           [lua_cpath=`expr X"$lua_cpath" : X'[^;]*;*\(.*\)'`]
1311         done
1312         test -n "$LUA_LIB" || LUA_LIB=$lua_lib
1313         test -n "$LUA_SO" || LUA_SO=$lua_so
1314       fi
1315       if test -z "$LUA_LIB"; then
1316         AC_MSG_RESULT([not found])
1317       else
1318         AC_MSG_RESULT([$LUA_LIB])
1319       fi
1320       AC_SUBST([LUA_LIB])
1322       AC_MSG_CHECKING([for extension to use for compiled Lua modules])
1323       if test -z "$LUA_SO"; then
1324         AC_MSG_RESULT([not found])
1325       else
1326         AC_MSG_RESULT([$LUA_SO])
1327       fi
1328       AC_SUBST([LUA_SO])
1330       AC_MSG_CHECKING([for Lua header files])
1331       AC_ARG_VAR([LUA_INC], [Directory to include for lua headers])
1332       if test -z "$LUA_INC" ; then
1333         dirs="/usr/include/lua$lua_version /usr/local/include/lua$lua_version"
1334         for i in $dirs ; do
1335           if test -r "$i/lua.h"; then
1336             LUA_INC=$i
1337             break
1338           fi
1339         done
1340       fi
1342       if test -z "$LUA_INC" ; then
1343         AC_MSG_RESULT([not found])
1344       else
1345         AC_MSG_RESULT([$LUA_INC])
1346         BINDINGS="$BINDINGS lua"
1347         LUA_CPPFLAGS="-I$LUA_INC"
1348       fi
1349       AC_SUBST([LUA_CPPFLAGS])
1350     fi
1351   else
1352     if test yes = "$with_lua" ; then
1353       AC_MSG_ERROR([lua not found])
1354     fi
1355   fi
1358 AC_SUBST(BINDINGS)
1360 case $BINDINGS in
1361 *python*) dnl Matches python and/or python3
1362   dnl C++11 has thread_local
1363   dnl GCC and some others have __thread
1364   dnl MSVC and some others have __declspec(thread)
1365   AC_MSG_CHECKING([for thread-local storage qualifier])
1366   AC_ARG_VAR([THREAD_LOCAL], [thread-local storage qualifier])
1367   if test -z "$THREAD_LOCAL" ; then
1368     for t in thread_local __thread '__declspec(thread)' ; do
1369       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static $t void * p;]])],
1370                         [THREAD_LOCAL=$t; break])
1371     done
1372   fi
1373   if test -z "$THREAD_LOCAL" ; then
1374     AC_MSG_RESULT([unknown, disabling thread-local support])
1375   else
1376     AC_MSG_RESULT([$THREAD_LOCAL])
1377     AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
1378   fi
1379   ;;
1380 esac
1382 dnl Set flags to control warnings (enable more, or disable annoying ones)
1383 dnl and other compiler specific flags.
1384 SWIG_CXXFLAGS=
1385 if test yes = "$GXX" ; then
1386   dnl Python itself is compiled with -fno-strict-aliasing, and it appears
1387   dnl it's safest to follow this lead when compiling the SWIG generated
1388   dnl interface code.  E.g.:
1389   dnl   http://article.gmane.org/gmane.comp.gcc.devel/74692
1390   dnl The code SWIG generates for other languages seems to have similar
1391   dnl issues too, so just turn this on for all of them.
1392   dnl
1393   dnl There's no need to check -fno-strict-aliasing is supported as it works
1394   dnl with GCC 2.95 and we don't support anything older.
1395   SWIG_CXXFLAGS="-fno-strict-aliasing"
1397   dnl We need to explicitly link against -lstdc++ on OpenBSD (discovered
1398   dnl on OpenBSD 3.7 with GCC 3.3.5 but this appears to be due to a
1399   dnl deliberate decision on the part of OpenBSD developers).  Luckily
1400   dnl we can just always specify -lstdc++ explicitly if GCC is the
1401   dnl compiler and libtool will eliminate the duplicate on other
1402   dnl platforms.
1403   XAPIAN_LIBS="$XAPIAN_LIBS -lstdc++"
1405   dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
1406   dnl which we actually have.
1407   AC_EGREP_CPP(yes,
1408     [#ifdef __INTEL_COMPILER
1409      yes
1410      #endif
1411     ],
1412     [
1413       dnl Intel's compiler:
1414       dnl
1415       dnl -w1 stops the avalanche of uninteresting "remark" messages.
1416       dnl -wd... disables warnings which don't have good code workarounds.
1417       dnl
1418       dnl Swig generated code gives lots of unused and uninitialized warnings.
1419       dnl They're non-harmful, so suppress them.
1420       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
1421     ],
1422     [
1423       dnl GCC or clang:
1424       dnl
1425       dnl Swig generated code gives lots of unused and uninitialized warnings.
1426       dnl They're non-harmful, so suppress them.
1427       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -Wno-unused -Wno-uninitialized"
1428     ])
1430   if test no != "$enable_visibility"; then
1431     dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1432     dnl on mingw).
1433     AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
1434     if echo 'int bar() __attribute__((visibility("default"))); int foo() {return 42;}'|$CXX -Werror -fvisibility=hidden -c -oconftest.o -xc++ - >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1435       AC_MSG_RESULT([yes])
1436       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden"
1437     else
1438       AC_MSG_RESULT([no])
1439     fi
1440   fi
1442 AC_SUBST(SWIG_CXXFLAGS)
1444 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1445 CXXFLAGS=$save_CXXFLAGS
1447 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1448 : ${AUTOM4TE=autom4te}
1449 AC_SUBST([AUTOM4TE])
1451 AC_CONFIG_FILES([Makefile
1452  doxygen_xml.conf
1453  xapian-version.h
1454  python/Makefile python/docs/conf.py python/version.i
1455  python3/Makefile python3/docs/conf.py python3/version.i
1456  php/Makefile
1457  php7/Makefile
1458  java/Makefile
1459  tcl8/Makefile tcl8/pkgIndex.tcl
1460  csharp/Makefile csharp/AssemblyInfo.cs
1461  ruby/Makefile
1462  perl/Makefile perl/util.i
1463  lua/Makefile
1464  xapian-bindings.spec
1465  ])
1466 AC_OUTPUT
1468 echo ""
1469 if test -z "$BINDINGS" ; then
1470   echo "*** Not found the required tools for building bindings for any"
1471   echo "*** supported language!"
1472   echo "***"
1473   echo "*** You may need to install -dev or -devel packages for the languages"
1474   echo "*** you want to build bindings for."
1475   echo "***"
1476   echo "*** For details of how to point configure at tools not on PATH, see:"
1477   echo "***     ./configure --help"
1478 else
1479   echo "*** Building bindings for languages:" $BINDINGS
1481 echo ""
1482 if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
1483   release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
1484   case $XAPIAN_VERSION in
1485   $release_series*) ;;
1486   *)
1487     AC_MSG_ERROR([Xapian library is version ${XAPIAN_VERSION-<0.8.2} which is from a different release series to bindings $PACKAGE_VERSION, so they aren't compatible.])
1488     ;;
1489   esac
1490   dnl 0.8.2 was the first version which set XAPIAN_VERSION
1491   AC_MSG_WARN([Xapian library is version ${XAPIAN_VERSION-<0.8.2} but the bindings are version $PACKAGE_VERSION - we strongly recommend using matching versions.])