Cache compiled regexps used in $transform
[xapian.git] / xapian-bindings / configure.ac
blobcbe0c7c6c3cf617ec58b8e66c4f4ff4a74897035
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.3.3])
8 AC_INIT([xapian-bindings], project_version, [http://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 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.3 fixes some problems with subclassing wrapped Xapian classes in PHP.
190   v=`$SWIG -version 2>&1|sed 's/^SWIG Version \([[0-9\.]]*\).*/\1/p;d'`
191   case $v in
192     [[012].*|3.0.[012]|""])
193       msg="SWIG >= 3.0.3 (commit e12322d) required (you have ${v:-an unknown version})"
194       if test -n "$swigoverridden" ; then
195         dnl If SWIG was explicitly set, make this a warning only.
196         AC_MSG_WARN([$msg])
197       else
198         AC_MSG_ERROR([$msg])
199       fi ;;
200   esac
201   SWIG_FLAGS=`$XAPIAN_CONFIG --swigflags`
202   AC_SUBST(SWIG_FLAGS)
203   XAPIAN_HEADER_DIRS=
204   XAPIAN_HEADERS=
205   for a in $SWIG_FLAGS ; do
206     case $a in
207     -I*)
208       d=`echo "x$a"|sed 's/^x-I//'`
209       dnl Quote each entry in XAPIAN_HEADER_DIRS with "".
210       XAPIAN_HEADER_DIRS=$XAPIAN_HEADER_DIRS' "'$d'"'
211       for f in "$d/"*.h "$d/xapian/*.h" ; do
212         if test -f "$f" ; then
213           XAPIAN_HEADERS="$XAPIAN_HEADERS $f"
214         fi
215       done
216       ;;
217     esac
218   done
219   AC_SUBST([XAPIAN_HEADER_DIRS])
220   AC_SUBST([XAPIAN_HEADERS])
222   dnl Need perl in maintainer mode to generate the except.i file for python.
223   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
224   test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
225   dnl Need doxygen in maintainer mode to convert C++ doxygen comments to Python
226   dnl docstrings.
227   AC_PATH_PROG(DOXYGEN, doxygen, [])
228   test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
231 AC_ARG_WITH(python,
232   AC_HELP_STRING([--with-python], [enable Python 2 bindings]),
233   [],
234   [with_python=])
236 AC_ARG_WITH(python3,
237   AC_HELP_STRING([--with-python3], [enable Python 3 bindings]),
238   [],
239   [with_python3=])
241 AC_ARG_WITH(php,
242   AC_HELP_STRING([--with-php], [enable PHP bindings]),
243   [],
244   [with_php=])
246 AC_ARG_WITH(ruby,
247   AC_HELP_STRING([--with-ruby], [enable Ruby bindings]),
248   [],
249   [with_ruby=])
251 AC_ARG_WITH(tcl,
252   AC_HELP_STRING([--with-tcl], [enable Tcl bindings]),
253   [],
254   [with_tcl=])
256 AC_ARG_WITH(csharp,
257   AC_HELP_STRING([--with-csharp], [enable CSharp bindings]),
258   [],
259   [with_csharp=])
261 AC_ARG_WITH(java,
262   AC_HELP_STRING([--with-java], [enable Java bindings]),
263   [],
264   [with_java=])
266 AC_ARG_WITH(perl,
267   AC_HELP_STRING([--with-perl], [enable Perl bindings]),
268   [],
269   [with_perl=])
271 AC_ARG_WITH(lua,
272   AC_HELP_STRING([--with-lua], [enable Lua bindings]),
273   [],
274   [with_lua=])
276 case $with_python$with_python3$with_php$with_ruby$with_tcl$with_csharp$with_java$with_perl$with_lua in
277 *yes*)
278   dnl Default unspecified values to no.
279   test -z "$with_python" && with_python=no
280   test -z "$with_python3" && with_python3=no
281   test -z "$with_php" && with_php=no
282   test -z "$with_tcl" && with_tcl=no
283   test -z "$with_csharp" && with_csharp=no
284   test -z "$with_java" && with_java=no
285   test -z "$with_ruby" && with_ruby=no
286   test -z "$with_perl" && with_perl=no
287   test -z "$with_lua" && with_lua=no
288   ;;
289 esac
291 BINDINGS=
293 if test no != "$with_python" ; then
294   dnl For backward compatibility:
295   : ${PYTHON2="$PYTHON"}
296   : ${PYTHON2_INC="$PYTHON_INC"}
297   : ${PYTHON2_LIB="$PYTHON_LIB"}
298   : ${PYTHON2_LIBS="$PYTHON_LIBS"}
299   : ${PYTHON2_SO="$PYTHON_SO"}
300   dnl See comment for AC_PATH_PROGS(SWIG, ...).
301   if test -n "$PYTHON2" ; then
302     AC_PATH_PROGS(PYTHON2, ["$PYTHON2"], [])
303   else
304     AC_PATH_PROGS(PYTHON2, [python2 python], [])
305   fi
306   AC_ARG_VAR(PYTHON2, [Python 2 interpreter])
307   if test -n "$PYTHON2" ; then
308     dnl Require Python 2.4 or newer.  Older versions are essentially
309     dnl unsupported upstream.
310     AC_MSG_CHECKING([$PYTHON2 version])
311     version=`$PYTHON2 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
312     case $version in
313     [2.[4-9]*|2.[12][0-9][0-9]*])
314       AC_MSG_RESULT([$version])
315       ;;
316     [[3-9].*])
317       AC_MSG_RESULT([$version (too new - use --with-python3 for Python 3 support)])
318       if test yes = "$with_python" ; then
319         AC_MSG_ERROR([Use --with-python3 for Python 3 support ($PYTHON2 is $version)])
320       fi
321       PYTHON2=
322       ;;
323     *)
324       AC_MSG_RESULT([$version (too old)])
325       if test yes = "$with_python" ; then
326         AC_MSG_ERROR([Only Python 2.4 or newer is supported ($PYTHON2 is $version)])
327       fi
328       PYTHON2=
329       ;;
330     esac
331     if test -n "$PYTHON2" ; then
332       if $PYTHON2 -c 'import distutils.sysconfig' 2>/dev/null ; then
333         PYTHON2_INC=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
334         AC_SUBST(PYTHON2_INC)
335       else
336         if test yes = "$with_python" ; then
337           AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python-dev or python-devel package])
338         else
339           AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python-dev or python-devel package installed])
340           PYTHON2=
341         fi
342       fi
343     fi
344     if test -n "$PYTHON2" ; then
345       dnl Check that Python.h is there, which is a good way to check that
346       dnl the appropriate python-dev package has been installed.
347       AC_MSG_CHECKING([for $PYTHON2_INC/Python.h])
348       if test -f "$PYTHON2_INC/Python.h" ; then
349         AC_MSG_RESULT(yes)
350         AC_MSG_CHECKING([for directory to install python2 bindings in])
351         if test -z "$PYTHON2_LIB" ; then
352           PYTHON2_LIB=`$PYTHON2 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
353         fi
354         AC_MSG_RESULT([$PYTHON2_LIB])
355         AC_ARG_VAR(PYTHON2_LIB, [Directory to install python2 bindings in])
357         AC_MSG_CHECKING([for python2 libraries to link against])
358         case $host_os in
359         mingw* | pw32*)
360           PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
361         cygwin*)
362           PYTHON2_LIBS=`$PYTHON2 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
363         *)
364           PYTHON2_LIBS= ;;
365         esac
366         AC_SUBST(PYTHON2_LIBS)
367         AC_MSG_RESULT([$PYTHON2_LIBS])
369         AC_MSG_CHECKING([for python2 module extension])
370         dnl Usually ".so", but for example, Mac OS X uses ".dylib".
371         PYTHON2_SO=`$PYTHON2 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
372         AC_SUBST(PYTHON2_SO)
373         AC_MSG_RESULT([$PYTHON2_SO])
374         BINDINGS="$BINDINGS python"
375       else
376         AC_MSG_RESULT([no (install python-dev or python-devel package or similar)])
377         if test yes = "$with_python" ; then
378           AC_MSG_ERROR([Python.h not found])
379         fi
380       fi
381     fi
382   fi
385 if test no != "$with_python3" ; then
386   dnl See comment for AC_PATH_PROGS(SWIG, ...).
387   if test -n "$PYTHON3" ; then
388     AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
389   else
390     AC_PATH_PROGS(PYTHON3, [python3 python], [])
391   fi
392   AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
393   if test -n "$PYTHON3" ; then
394     dnl Require Python 3.2 or newer, as that's the oldest version we can
395     dnl easily test with.  If anyone's keen to support older versions, please
396     dnl test and send in any patches needed to get it to work.
397     AC_MSG_CHECKING([$PYTHON3 version])
398     version=`$PYTHON3 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
399     case $version in
400     [3.[2-9]*|3.[12][0-9][0-9]*|[4-9].*])
401       AC_MSG_RESULT([$version])
402       ;;
403     *)
404       AC_MSG_RESULT([$version (too old)])
405       if test yes = "$with_python3" ; then
406         AC_MSG_ERROR([Only Python 3.2 or newer is supported ($python3 is $version)])
407       fi
408       PYTHON3=
409       ;;
410     esac
411     if test -n "$PYTHON3" ; then
412       if $PYTHON3 -c 'import distutils.sysconfig' 2>/dev/null ; then
413         PYTHON3_INC=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
414         AC_SUBST(PYTHON3_INC)
415       else
416         if test yes = "$with_python3" ; then
417           AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python3-dev or python3-devel package])
418         else
419           AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python3-dev or python3-devel package installed])
420           PYTHON3=
421         fi
422       fi
423     fi
424     if test -n "$PYTHON3" ; then
425       dnl Check that Python.h is there, which is a good way to check that
426       dnl the appropriate python3-dev package has been installed.
427       AC_MSG_CHECKING([for $PYTHON3_INC/Python.h])
428       if test -f "$PYTHON3_INC/Python.h" ; then
429         AC_MSG_RESULT(yes)
430         AC_MSG_CHECKING([for directory to install python3 bindings in])
431         if test -z "$PYTHON3_LIB" ; then
432           PYTHON3_LIB=`$PYTHON3 -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
433         fi
434         AC_MSG_RESULT([$PYTHON3_LIB])
435         AC_ARG_VAR(PYTHON3_LIB, [Directory to install python3 bindings in])
437         AC_MSG_CHECKING([for python3 libraries to link against])
438         case $host_os in
439         mingw* | pw32*)
440           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
441         cygwin*)
442           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
443         *)
444           PYTHON3_LIBS= ;;
445         esac
446         AC_SUBST(PYTHON3_LIBS)
447         AC_MSG_RESULT([$PYTHON3_LIBS])
449         AC_MSG_CHECKING([for python3 module extension])
450         dnl Usually ".so", but for example, Mac OS X uses ".dylib".
451         PYTHON3_SO=`$PYTHON3 -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
452         AC_SUBST(PYTHON3_SO)
453         AC_MSG_RESULT([$PYTHON3_SO])
455         AC_MSG_CHECKING([for tag for cached compiled scripts])
456         PYTHON3_CACHE_TAG=`$PYTHON3 -c 'import imp;print(imp.get_tag())'`
457         AC_SUBST(PYTHON3_CACHE_TAG)
458         AC_MSG_RESULT([$PYTHON3_CACHE_TAG])
460         AC_MSG_CHECKING([for extension of cached and optimized python3 bytecode])
461         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())))'`
462         AC_SUBST(PYTHON3_CACHE_OPT1_EXT)
463         AC_MSG_RESULT([$PYTHON3_CACHE_OPT1_EXT])
465         BINDINGS="$BINDINGS python3"
466       else
467         AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
468         if test yes = "$with_python3" ; then
469           AC_MSG_ERROR([Python.h not found])
470         fi
471       fi
472     fi
473   fi
476 if test x$USE_MAINTAINER_MODE = xyes; then
477   dnl Need python in maintainer mode to run doxy2swig.py.
478   dnl Either Python 2 or 3 is OK for this.
479   if test -n "$PYTHON2" ; then
480     PYTHON=$PYTHON2
481   elif test -n "$PYTHON3" ; then
482     PYTHON=$PYTHON3
483   else
484     AC_PATH_PROGS(PYTHON, [python2 python python3], [])
485   fi
486   test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
489 dnl If we're building documentation for either python version,
490 dnl we need sphinx-build
491 case $enable_documentation$BINDINGS in
492 yes*python*)
493   AC_PATH_PROG(SPHINX_BUILD, sphinx-build, [])
494   test -z "$SPHINX_BUILD" && AC_MSG_ERROR([sphinx-build is required to build python documentation (try packages python-sphinx and python3-sphinx)])
495   ;;
496 esac
498 if test no != "$with_php" ; then
499   dnl See comment for AC_PATH_PROGS(SWIG, ...).
500   AC_PATH_PROGS(PHP_CONFIG, ["${PHP_CONFIG-php-config}"], [])
501   AC_ARG_VAR(PHP_CONFIG, [php-config utility])
502   AC_ARG_VAR(PHP, [php interpreter (optional - only needed to run PHP testsuite with)])
503   if test -n "$PHP_CONFIG" ; then
504     AC_MSG_CHECKING([$PHP_CONFIG version])
505     version=`$PHP_CONFIG --version 2>/dev/null`
506     case $version in
507     [[01234].*|5.[01234]])
508       AC_MSG_RESULT([$version (not supported, need PHP >= 5.5)])
509       if test yes = "$with_php" ; then
510         AC_MSG_ERROR([Only PHP >= 5.5 is supported ($PHP_CONFIG reports version $version)])
511       fi
512       with_php=no
513       ;;
514     *)
515       AC_MSG_RESULT([$version])
516       PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
517       ;;
518     esac
519     AC_SUBST(PHP_MAJOR_VERSION)
521     if test no != "$with_php" ; then
522       AC_MSG_CHECKING([for PHP extension directory])
523       if test -z "$PHP_EXTENSION_DIR" ; then
524         PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
525       fi
526       AC_MSG_RESULT([$PHP_EXTENSION_DIR])
527       AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP extensions in])
528     fi
530     if test no != "$with_php" ; then
531       PHP_INC=`$PHP_CONFIG --includes`
532       AC_SUBST(PHP_INC)
533       save_CPPFLAGS=$CPPFLAGS
534       CPPFLAGS="$CPPFLAGS $PHP_INC"
535       dnl One of SGI's SuSE boxes has php-config but no headers.
536       AC_CHECK_HEADER(zend.h, [], [
537         if test yes = "$with_php" ; then
538           AC_MSG_ERROR(['$PHP_CONFIG --includes' reports '$PHP_INC' but zend.h can't be included from there])
539         fi
540         with_php=no], [ ])
541       CPPFLAGS=$save_CPPFLAGS
542     fi
544     if test no != "$with_php" ; then
545       if test x"$PHP" = x ; then
546         AC_MSG_CHECKING([for PHP interpreter])
547         dnl PHP5's php-config supports --php-binary, so just use that.
548         PHP=`$PHP_CONFIG --php-binary 2>/dev/null`
549         if test x"$PHP" != x ; then
550           if $PHP -r 'exit(0);' 2> /dev/null ; then
551             AC_MSG_RESULT([$PHP])
552           else
553             AC_MSG_RESULT([no ($PHP does not work)])
554             PHP=
555           fi
556         else
557           AC_MSG_RESULT([not found])
558         fi
559       else
560         AC_PATH_PROGS(PHP, ["$PHP"], [])
561       fi
562       if test x"$PHP" = x ; then
563         AC_MSG_WARN([No PHP interpreter found - PHP bindings tests will be skipped])
564         dnl The skiptest script just returns exit code 77.
565         PHP='$(top_srcdir)/skiptest'
566       else
567         AC_MSG_CHECKING([for PHP path separator])
568         PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
569         AC_SUBST([PHP_PATH_SEPARATOR])
570         AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
571       fi
573       case $host_os in
574       mingw* | pw32*)
575         dnl This is a bit of an informed guess, pending more information from
576         dnl someone who actually has mingw and wants to build the PHP bindings
577         dnl there.  FIXME.
578         PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
579       cygwin*)
580         PHP_LIBS="-lphp${PHP_MAJOR_VERSION}lib" ;;
581       *)
582         PHP_LIBS= ;;
583       esac
584       AC_SUBST(PHP_LIBS)
585       BINDINGS="$BINDINGS php"
586     fi
587   fi
590 if test no != "$with_tcl" ; then
591   dnl The documented minimum requirement is Tcl 8.5.  Older versions may work,
592   dnl but we don't test with them regularly, and they are no longer supported
593   dnl upstream.  Also ::tcl::pckconfig was added in Tcl 8.5, which makes the
594   dnl tests below simpler and more reliable.
595   dnl
596   dnl If you really want to build with an older version, run configure with
597   dnl a lower tcl_min and specify at least TCL_INC explicitly:
598   dnl
599   dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
600   dnl
601   dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
602   : ${tcl_min=8.5}
603   AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
604   AC_ARG_VAR(TCLSH, [Tcl interpreter])
605   if test -n "$TCLSH" ; then
606     AC_MSG_CHECKING([$TCLSH version])
607     if echo 'if {$tcl_version < '"$tcl_min"' } { exit 1 }'|$TCLSH 2> /dev/null ; then
608       tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
609       AC_MSG_RESULT([$tcl_version])
611       AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
612       if test -z "$TCL_LIB" ; then
613         [TCL_LIB=`echo 'foreach d $tcl_pkgPath {if {![regexp {/share(/|$)} $d]} {break}};puts $d'|$TCLSH`]
614       fi
615       AC_SUBST(TCL_LIB)
617       AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
618       if test -z "$TCL_INC" ; then
619         dnl ::tcl::pkgconfig was added in Tcl 8.5.
620         [TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
621       fi
623       dnl Check that the headers are there (the tcl8.N-dev package
624       dnl may not be installed).
625       TCL_CPPFLAGS=
626       AC_MSG_CHECKING([for tcl.h from Tcl $tcl_version])
627       if test x"$TCL_INC" != x && test -f "$TCL_INC/tcl.h" ; then
628         tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
629         if test x"$tcl_hdr_version" = x"$tcl_version" ; then
630           AC_MSG_RESULT([$TCL_INC/tcl.h])
631           BINDINGS="$BINDINGS tcl8"
632           if test x"$TCL_INC" != x"/usr/include" ; then
633             TCL_CPPFLAGS="-I$TCL_INC"
634           fi
635         else
636           AC_MSG_RESULT([not found])
637           if test yes = "$with_tcl" ; then
638             AC_MSG_ERROR([Found tcl.h from version $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
639           fi
640           TCLSH=
641         fi
642       else
643         AC_MSG_RESULT([not found])
644         if test yes = "$with_tcl" ; then
645           AC_MSG_ERROR([Can't find tcl.h])
646         fi
647         TCLSH=
648       fi
650       if test -n "$TCLSH" ; then
651         dnl Cygwin needs to link with -ltcl8.5 or similar.
652         TCL_LIBS=
653         case $host_os in
654         cygwin*)
655           AC_CHECK_LIB([tcl$tcl_version], [Tcl_Init],
656                        [TCL_LIBS="-ltcl$tcl_version"],
657                        [AC_MSG_ERROR([libtcl$tcl_version not found])])
658           ;;
659         *)
660           dnl ::tcl::pkgconfig was added in Tcl 8.5, but prior to 8.6 it isn't
661           dnl necessary to link against -ltclstub anyway.
662           [TCLCONFIG_SH=`echo 'puts [file join [::tcl::pkgconfig get libdir,runtime] tclConfig.sh]'|$TCLSH 2> /dev/null`]
663           if test -n "$TCLCONFIG_SH" && test -r "$TCLCONFIG_SH" ; then
664             eval "`sed 's/^TCL_STUB_LIB_SPEC=/TCL_LIBS=/p;d' $TCLCONFIG_SH`"
665           fi
666           TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS" ;;
667         esac
668       fi
670       AC_SUBST(TCL_CPPFLAGS)
671       AC_SUBST(TCL_LIBS)
672     else
673       AC_MSG_RESULT([< $tcl_min (too old)])
674       if test yes = "$with_tcl" ; then
675         AC_MSG_ERROR([$TCLSH too old (Tcl $tcl_min or newer required)])
676       fi
677     fi
678   else
679     if test yes = "$with_tcl" ; then
680       AC_MSG_ERROR([tclsh not found])
681     fi
682   fi
685 if test no != "$with_csharp" ; then
686   csc_note=
687   AC_ARG_VAR(CSC, [CSharp compiler command])
688   if test -n "$CSC" ; then
689     AC_PATH_PROGS(CSC, ["$CSC"], [])
690   fi
691   if test -z "$CSC" ; then
692     dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
693     dnl as "alternatives" which can be mapped to the CSharp compiler the admin
694     dnl favours.
695     AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
696     if test -z "$CSC" ; then
697       dnl mcs is the Mono CSharp compiler, which is a unified compiler
698       dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
699       dnl that's no longer relevant).
700       AC_PATH_PROGS(CSC, [mcs], [])
701       if test -n "$CSC" ; then
702         dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
703         dnl so we check that the mcs we found understands --version which is
704         dnl sufficient to distinguish mono's mcs from the Tru64 one.
705         AC_MSG_CHECKING([whether $CSC is from GNU Mono])
706         if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
707           AC_MSG_RESULT(yes)
708         else
709           AC_MSG_RESULT(no)
710           CSC=
711           csc_note="$csc_note (found different mcs program)"
712         fi
713       fi
714     fi
715     if test -z "$CSC" ; then
716       dnl gmcs, smcs, and dmcs are versions of the Mono CSharp compiler
717       dnl targeting various runtime versions, deprecated in favour of mcs
718       dnl (checked for above) as of Mono 2.11.
719       dnl
720       dnl cscc is the Portable.NET CSharp compiler.
721       AC_PATH_PROGS(CSC, [dmcs smcs gmcs cscc], [])
722     fi
723     if test -z "$CSC" ; then
724       dnl csc is the Microsoft CSharp compiler.
725       AC_PATH_PROGS(CSC, [csc], [])
726       if test -n "$CSC" ; then
727         dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
728         dnl check if the output from "csc -version" includes the word chicken
729         dnl which is sufficient to distinguish Chicken's csc from Microsoft's
730         dnl csc.exe.
731         AC_MSG_CHECKING([whether $CSC is for CSharp])
732         if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
733           AC_MSG_RESULT(no)
734           CSC=
735           csc_note="$csc_note (found Chicken csc program)"
736         else
737           AC_MSG_RESULT(yes)
738         fi
739       fi
740     fi
741   fi
743   if test -n "$CSC" ; then
744     AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
745     if test -n "$GACUTIL" ; then
746       AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
747     fi
748     if test -z "$GACUTIL" ; then
749       AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil ilgac], [])
750     fi
752     AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
753     if test -n "$SN" ; then
754       AC_PATH_PROGS(SN, ["$SN"], [])
755     fi
756     if test -z "$SN" ; then
757       AC_PATH_PROGS(SN, [cli-sn sn], [])
758     fi
759     if test -z "$SN" ; then
760       case $GACUTIL in
761       dnl Portable.net doesn't support strong naming yet and ilgac doesn't
762       dnl require assemblies to be strong named before adding them to the GAC.
763       *ilgac*) SN=/bin/true ;;
764       esac
765     fi
766     if test -n "$GACUTIL" -a -n "$SN" ; then
767       AC_MSG_CHECKING([whether the CSharp compiler works])
768       [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
769       if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
770         AC_MSG_RESULT(yes)
771         AC_MSG_CHECKING([whether CSharp programs can just be run])
772         if test OK = "`./conftest.exe 2> /dev/null`" ; then
773           AC_MSG_RESULT(yes)
774           RUN_CSHARP=
775         else
776           AC_MSG_RESULT(no)
777           AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
778           if test -z "$CLI" ; then
779             AC_PATH_PROGS(CLI, [mono ilrun], [])
780           fi
781           AC_ARG_VAR(CLI, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
782           if test -n "$CLI" ; then
783             AC_MSG_CHECKING([whether $CLI can run CSharp programs])
784             if test OK = "`$CLI ./conftest.exe 2> /dev/null`" ; then
785               AC_MSG_RESULT(yes)
786               RUN_CSHARP=$CLI
787             else
788               AC_MSG_RESULT([no - CSharp tests will be skipped])
789               RUN_CSHARP='\$(top_srcdir)/skiptest'
790             fi
791           else
792             AC_MSG_RESULT([not found - CSharp tests will be skipped])
793             RUN_CSHARP='\$(top_srcdir)/skiptest'
794           fi
795         fi
796         AC_SUBST(RUN_CSHARP)
798         AC_MSG_CHECKING([for extra flags for $GACUTIL])
799         GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
800         case $GACUTIL in
801         *ilgac*) ;;
802         *)
803           dnl Microsoft's gacutil accepts fewer options than Mono's
804           $GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
805           ;;
806         esac
807         AC_SUBST([GACUTIL_FLAGS])
808         if test -z "$GACUTIL_FLAGS" ; then
809           AC_MSG_RESULT([no])
810         else
811           AC_MSG_RESULT([$GACUTIL_FLAGS])
812         fi
814         BINDINGS="$BINDINGS csharp"
815       else
816         AC_MSG_RESULT(no)
817         if test yes = "$with_csharp" ; then
818           AC_MSG_ERROR([CSharp compiler $CSC doesn't work])
819         fi
820       fi
821     else
822       if test yes = "$with_csharp" ; then
823         if test -z "$GACUTIL" ; then
824           AC_MSG_ERROR([Mono gacutil not found])
825         elif test -z "$SN" ; then
826           AC_MSG_ERROR([Mono sn not found])
827         fi
828       fi
829     fi
830   else
831     if test yes = "$with_csharp" ; then
832       AC_MSG_ERROR([CSharp compiler not found$csc_note])
833     fi
834   fi
837 JAVA_CPPFLAGS=
838 if test no != "$with_java" ; then
839   AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
840         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
841   AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
842         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
843   AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
844         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
845   AC_ARG_VAR(JAVA, [Java interpreter command])
846   AC_ARG_VAR(JAVAC, [Java compiler command])
847   AC_ARG_VAR(JAR, [java jar utility])
848   AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
849   AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
850   AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
851   if test -n "$JAVA" -a -n "$JAVAC" -a -n "$JAR" ; then
852     dnl Eric says:
853     dnl  The JNI library *requires* "Java 2", which is 1.2 or better.
854     dnl
855     dnl So checking for jni.h presumably implicitly checks we have "Java 2".
856     dnl Note: jni.h #defines JNI_VERSION_1_[1246] (but not 3 or 5 it seems).
857     dnl So we could check for one of these if we want to check for a particular
858     dnl JDK version...
859     java_ok=no
860     AC_CHECK_HEADER([jni.h], [java_ok=yes], [
861       dnl We need to look for jni.h in /usr/lib/jvm/java-gcj/include on some
862       dnl Debian and Ubuntu boxes at least.  And on Mac OS X, jni.h lives
863       dnl in /System/Library/Frameworks/JavaVM.framework/Headers.
864       SAVE_CPPFLAGS=$CPPFLAGS
865       real_javac=$JAVAC
866       dnl Avoid endlessly traversing if there's a symlink loop.
867       for count in 1 2 3 4 5 6 7 8 9 ; do
868         r=`readlink "$real_javac"`
869         test -n "$r" || break
870         real_javac=$r
871       done
872       dnl Translate ".../bin/javac" to ".../include".
873       [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
874       for jnidir in \
875           $JNI_INCLUDE_DIR \
876           ${JAVA_HOME+"$JAVA_HOME/include"} \
877           ${JDK_HOME+"$JDK_HOME/include"} \
878           "$rel_jnidir" \
879           /System/Library/Frameworks/JavaVM.framework/Headers ; do
880         CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
881         AC_MSG_CHECKING([for jni.h in $jnidir])
882         if test -f "$jnidir/jni.h" ; then
883           AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
884           if test yes = $java_ok ; then
885             AC_MSG_RESULT([yes])
886             JAVA_CPPFLAGS=-I$jnidir
887             break
888           fi
890           dnl Sun's JDK requires the user to pass an extra -I for a
891           dnl subdirectory named after the host_os.  Sadly we seem to
892           dnl need to hardcode a list of the platform names.
893           jni_host_os=
894           case $host_os in
895             linux*)
896               jni_host_os=linux ;;
897             solaris*)
898               jni_host_os=solaris ;;
899             mingw* | pw32*)
900               jni_host_os=win32 ;;
901           esac
902           if test -n "$jni_host_os" ; then
903             CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
904             AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
905             if test yes = $java_ok ; then
906               AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
907               JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
908               break
909             fi
910           fi
911           AC_MSG_RESULT([found, but not usable])
913           CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
914         else
915           AC_MSG_RESULT([no])
916         fi
917       done
918       CPPFLAGS=$SAVE_CPPFLAGS
919       test noyes = $java_ok$with_java && AC_MSG_ERROR([jni.h not found])
920       ], [ ])
921     AC_SUBST(JAVA_CPPFLAGS)
922     if test yes = $java_ok ; then
923       AC_MSG_CHECKING([for Java path separator])
924       [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
925       if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
926         JAVA_PATHSEP=`$JAVA conftest 2>&5`
927         AC_SUBST(JAVA_PATHSEP)
928         if test -n "$JAVA_PATHSEP" ; then
929           AC_MSG_RESULT($JAVA_PATHSEP)
930           BINDINGS="$BINDINGS java"
931         else
932           AC_MSG_RESULT([failed to run test program])
933           java_ok=no
934         fi
935       else
936         AC_MSG_RESULT([failed to compile test program])
937         java_ok=no
938       fi
939       if test no = "$java_ok" ; then
940         test yes = "$with_java" && AC_MSG_ERROR([Couldn't compile and run a simple Java test program])
941       fi
942     fi
943   else
944     if test yes = "$with_java" ; then
945       if test -z "$JAVA" ; then
946         AC_MSG_ERROR([java not found])
947       elif test -z "$JAVAC" ; then
948         AC_MSG_ERROR([javac not found])
949       elif test -z "$JAR" ; then
950         AC_MSG_ERROR([jar not found])
951       fi
952     fi
953   fi
956 if test no != "$with_ruby" ; then
957   dnl See comment for AC_PATH_PROGS(SWIG, ...).
958   if test -n "$RUBY" ; then
959     AC_PATH_PROGS(RUBY, ["$RUBY"], [])
960   else
961     AC_PATH_PROGS(RUBY, [ruby], [])
962   fi
963   AC_ARG_VAR(RUBY, [Ruby interpreter])
964   if test -n "$RUBY" ; then
965     dnl Require Ruby 1.8 or newer.  Paul says:
966     dnl  I'm using 1.8.4.  I imagine anything in the 1.8.x series will be fine,
967     dnl  not sure about 1.6 but hardly anyone uses <1.8.
968     dnl
969     dnl Brief testing with Ruby 1.6.8 show the bindings probably work there,
970     dnl but smoketest.rb doesn't because the test/unit module isn't available.
971     AC_MSG_CHECKING([$RUBY version])
972     dnl RUBY_VERSION works with 1.6.  Once we've checked we have at least 1.8
973     dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8; Config
974     dnl gives a deprecation warning with Ruby 1.9.3).
975     version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
976     case $version in
977     "")
978       AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work])
979       if test yes = "$with_ruby" ; then
980         AC_MSG_ERROR([Working Ruby interpreter not found])
981       fi
982       RUBY=
983       ;;
984     [0.*|1.[0-7]|1.[0-7].*])
985       AC_MSG_RESULT([$version (too old)])
986       if test yes = "$with_ruby" ; then
987         AC_MSG_ERROR([Only Ruby 1.8 or newer is supported ($RUBY is $version)])
988       fi
989       RUBY=
990       ;;
991     esac
992     if test -n "$RUBY" ; then
993       AC_MSG_RESULT([$version])
994       AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
995       if test -z "$RUBY_INC" ; then
996         dnl Ruby 1.9 added rubyhdrdir; for older Ruby we use archdir.
997         [RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG["archdir"]'`]
998       fi
999       AC_SUBST(RUBY_INC)
1000       dnl Check that ruby.h is there, which is a good way to check that
1001       dnl the appropriate ruby-dev package has been installed.
1002       AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
1003       if test -f "$RUBY_INC/ruby.h" ; then
1004         AC_MSG_RESULT(yes)
1006         AC_MSG_CHECKING([for ruby/io.h])
1007         rm -f ruby/rubyio.h
1008         if test -f "$RUBY_INC/ruby/io.h" ; then
1009           AC_MSG_RESULT(yes)
1011           dnl In a VPATH build, the ruby subdirectory won't exist the first
1012           dnl time.
1013           AS_MKDIR_P([ruby])
1015           dnl Newer Ruby has ruby/io.h - older has rubyio.h.  Ruby doesn't
1016           dnl seem to provide any way to generate code which works with
1017           dnl both (and even the version number isn't a discriminator as
1018           dnl Debian etch has 1.9 without ruby/io.h).  The SWIG version
1019           dnl we're currently using assumes rubyio.h exists and luckily
1020           dnl it includes it with "", so we can just drop a rubyio.h
1021           dnl wrapper alongside ruby/xapian_wrap.cc.
1022           echo '#include <ruby/io.h>' > ruby/rubyio.h
1023         else
1024           AC_MSG_RESULT(no)
1025         fi
1027         AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found (needed from Ruby 1.9)])
1028         if test -z "$RUBY_INC_ARCH" ; then
1029           dnl Ruby 2.0 and later Ruby 1.9 have rubyarchhdrdir; for early 1.9,
1030           dnl use rubyhdrdir+"/"+arch.
1031           [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'd = RbConfig::CONFIG["rubyhdrdir"]; print RbConfig::CONFIG["rubyarchhdrdir"] || (d ? d + "/" + RbConfig::CONFIG["arch"] : "")'`]
1032           dnl Ruby 1.8 has no rubyhdrdir, so set RUBY_INC_ARCH=RUBY_INC.
1033           test x"$RUBY_INC_ARCH" != x || RUBY_INC_ARCH=$RUBY_INC
1034         fi
1035         AC_SUBST(RUBY_INC_ARCH)
1037         AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
1038         if test -z "$RUBY_LIB" ; then
1039           [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
1040         fi
1041         AC_SUBST(RUBY_LIB)
1043         AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
1044         if test -z "$RUBY_LIB_ARCH" ; then
1045           [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
1046         fi
1047         AC_SUBST(RUBY_LIB_ARCH)
1049         RUBY_LIBS=
1050         if test unsupported = "$allow_undefined_flag" ; then
1051           dnl For Microsoft Windows and a few other platforms.
1052           [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
1053         fi
1054         AC_SUBST(RUBY_LIBS)
1056         if test yes = "$enable_documentation" ; then
1057           if test -n "$RDOC" ; then
1058             AC_PATH_PROGS(RDOC, ["$RDOC"], [])
1059           else
1060             dnl Try replace the *last* 'ruby' with 'rdoc'.
1061             rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
1062             AC_PATH_PROGS(RDOC, ["$rdoc_best_guess"], [])
1063             if test -z "$RDOC"; then
1064               AC_PATH_PROGS(RDOC, [rdoc1.8 rdoc], [])
1065               test -n "$RDOC" || RDOC="$MISSING rdoc"
1066             fi
1067           fi
1068         fi
1070         BINDINGS="$BINDINGS ruby"
1071       else
1072         AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
1073         if test yes = "$with_ruby" ; then
1074           AC_MSG_ERROR([ruby.h not found])
1075         fi
1076       fi
1077       RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
1078       AC_SUBST(RUBY_DLEXT)
1079     fi
1080   fi
1083 if test no != "$with_perl" ; then
1084   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
1085   AC_ARG_VAR(PERL, [perl interpreter])
1086   if test -n "$PERL" ; then
1087     AC_PATH_PROGS(PROVE, ["${PROVE-prove}"], [])
1088     AC_ARG_VAR(PROVE, [Perl Test::Harness test runner])
1089     if test x"$PROVE" = x ; then
1090       AC_MSG_WARN([Perl 'prove' tool not found - Perl bindings tests will be skipped])
1091       dnl The skiptest script just returns exit code 77.
1092       PROVE='$(top_srcdir)/skiptest'
1093     fi
1095     if test -z "$PERL_INC" ; then
1096       PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
1097     fi
1098     AC_SUBST(PERL_INC)
1100     AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
1101     if test -z "$PERL_ARCH" ; then
1102       PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
1103     fi
1104     AC_SUBST(PERL_ARCH)
1106     AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
1107     if test -z "$PERL_LIB" ; then
1108       PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
1109     fi
1110     AC_SUBST(PERL_LIB)
1112     AC_ARG_VAR(PERL_SO, [Extension for compiled Perl modules])
1113     if test -z "$PERL_SO" ; then
1114       PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
1115     fi
1116     AC_SUBST(PERL_SO)
1118     if test -z "$PERL_XAPIAN_VERSION" ; then
1119       dnl snapshot versions look like 1.2.3_git123 or 1.2.3_svn14971
1120       case $PACKAGE_VERSION in
1121       *_git*)
1122         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
1123       *_svn*)
1124         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_svn/./'` ;;
1125       *)
1126         PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
1127       esac
1128     fi
1129     AC_SUBST(PERL_XAPIAN_VERSION)
1131     BINDINGS="$BINDINGS perl"
1132   else
1133     if test yes = "$with_perl" ; then
1134       AC_MSG_ERROR([perl not found])
1135     fi
1136   fi
1139 if test no != "$with_lua" ; then
1140   AC_PATH_PROGS(LUA, ["${LUA-lua}"], [])
1141   AC_ARG_VAR(LUA, [lua interpreter])
1142   if test -n "$LUA" ; then
1143     dnl We need Lua 5.1 or later.
1144     AC_MSG_CHECKING([$LUA version])
1145     lua_version=`$LUA -e 'print(_VERSION)' | cut -f 2 -d ' '`
1147     case $lua_version in
1148     [[01234]].*|5.0|5.0.*)
1149       AC_MSG_RESULT([$lua_version < 5.1 (too old)])
1150       if test yes = "$with_lua" ; then
1151         AC_MSG_ERROR([$LUA too old (Lua 5.1 or newer required)])
1152       fi
1153       LUA=
1154       ;;
1155     "")
1156       AC_MSG_RESULT([\$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' didn't work])
1158       if test yes = "$with_lua" ; then
1159         AC_MSG_ERROR([Working Lua interpreter not found])
1160       fi
1161       LUA=
1162       ;;
1163     esac
1165     if test -n "$LUA" ; then
1166       AC_MSG_RESULT([$lua_version])
1168       AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
1169       AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
1170       AC_MSG_CHECKING([for directory to install compiled Lua modules into])
1171       if test -z "$LUA_LIB" -o -z "$LUA_SO" ; then
1172         lua_cpath=`$LUA -e 'require("package") print(package.cpath)'`
1173         dnl Look for the first absolute path in lua_cpath which has leaf
1174         dnl "?.<ext>" and put the directory part into lua_lib and <ext> into
1175         dnl lua_so.  If LUA_SO was specified by the user, only consider
1176         dnl entries where <ext> matches LUA_SO.
1177         lua_lib=
1178         lua_so=
1179         case $LUA_SO in
1180           "")
1181            [lua_so_pat='[a-zA-Z][a-zA-Z]*'] ;;
1182           .*)
1183             dnl If LUA_SO has a leading '.', remove it.
1184             lua_so_pat=`AS_ECHO("$LUA_SO")|sed 's/^\.//'` ;;
1185           *)
1186             dnl If LUA_SO was specified without a leading '.', add one to the
1187             dnl value substituted into Makefile.in.
1188             lua_so_pat=$LUA_SO
1189             LUA_SO=.$LUA_SO
1190             ;;
1191         esac
1192         while test x"$lua_cpath" != x ; do
1193           [lua_lib=`expr X"$lua_cpath" : X'\([^;]*\)'`]
1194           lua_so=.`expr X"$lua_lib" : X'/.*/?\.\('"$lua_so_pat"'\)$'`
1195           case $lua_so in
1196             .|.lua)
1197               dnl If someone has foolishly put ?.lua in cpath, ignore them.
1198               lua_lib=
1199               ;;
1200             *)
1201               lua_lib=`expr X"$lua_lib" : X'\(/.*\)/?\.'"$lua_so_pat"'$'`
1202               break ;;
1203           esac
1204           [lua_cpath=`expr X"$lua_cpath" : X'[^;]*;*\(.*\)'`]
1205         done
1206         test -n "$LUA_LIB" || LUA_LIB=$lua_lib
1207         test -n "$LUA_SO" || LUA_SO=$lua_so
1208       fi
1209       if test -z "$LUA_LIB"; then
1210         AC_MSG_RESULT([not found])
1211       else
1212         AC_MSG_RESULT([$LUA_LIB])
1213       fi
1214       AC_SUBST([LUA_LIB])
1216       AC_MSG_CHECKING([for extension to use for compiled Lua modules])
1217       if test -z "$LUA_SO"; then
1218         AC_MSG_RESULT([not found])
1219       else
1220         AC_MSG_RESULT([$LUA_SO])
1221       fi
1222       AC_SUBST([LUA_SO])
1224       AC_MSG_CHECKING([for Lua header files])
1225       AC_ARG_VAR([LUA_INC], [Directory to include for lua headers])
1226       if test -z "$LUA_INC" ; then
1227         dirs="/usr/include/lua$lua_version /usr/local/include/lua$lua_version"
1228         for i in $dirs ; do
1229           if test -r "$i/lua.h"; then
1230             LUA_INC=$i
1231             break
1232           fi
1233         done
1234       fi
1236       if test -z "$LUA_INC" ; then
1237         AC_MSG_RESULT([not found])
1238       else
1239         AC_MSG_RESULT([$LUA_INC])
1240         BINDINGS="$BINDINGS lua"
1241         LUA_CPPFLAGS="-I$LUA_INC"
1242       fi
1243       AC_SUBST([LUA_CPPFLAGS])
1244     fi
1245   else
1246     if test yes = "$with_lua" ; then
1247       AC_MSG_ERROR([lua not found])
1248     fi
1249   fi
1252 AC_SUBST(BINDINGS)
1254 case $BINDINGS in
1255 *python*) dnl Matches python and/or python3
1256   dnl C++11 has thread_local
1257   dnl GCC and some others have __thread
1258   dnl MSVC and some others have __declspec(thread)
1259   AC_MSG_CHECKING([for thread-local storage qualifier])
1260   AC_ARG_VAR([THREAD_LOCAL], [thread-local storage qualifier])
1261   if test -z "$THREAD_LOCAL" ; then
1262     for t in thread_local __thread '__declspec(thread)' ; do
1263       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static $t void * p;]])],
1264                         [THREAD_LOCAL=$t; break])
1265     done
1266   fi
1267   if test -z "$THREAD_LOCAL" ; then
1268     AC_MSG_RESULT([unknown, disabling thread-local support])
1269   else
1270     AC_MSG_RESULT([$THREAD_LOCAL])
1271     AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
1272   fi
1273   ;;
1274 esac
1276 dnl Set flags to control warnings (enable more, or disable annoying ones)
1277 dnl and other compiler specific flags.
1278 SWIG_CXXFLAGS=
1279 if test yes = "$GXX" ; then
1280   dnl Python itself is compiled with -fno-strict-aliasing, and it appears
1281   dnl it's safest to follow this lead when compiling the SWIG generated
1282   dnl interface code.  E.g.:
1283   dnl   http://article.gmane.org/gmane.comp.gcc.devel/74692
1284   dnl The code SWIG generates for other languages seems to have similar
1285   dnl issues too, so just turn this on for all of them.
1286   dnl
1287   dnl There's no need to check -fno-strict-aliasing is supported as it works
1288   dnl with GCC 2.95 and we don't support anything older.
1289   SWIG_CXXFLAGS="-fno-strict-aliasing"
1291   dnl We need to explicitly link against -lstdc++ on OpenBSD (discovered
1292   dnl on OpenBSD 3.7 with GCC 3.3.5 but this appears to be due to a
1293   dnl deliberate decision on the part of OpenBSD developers).  Luckily
1294   dnl we can just always specify -lstdc++ explicitly if GCC is the
1295   dnl compiler and libtool will eliminate the duplicate on other
1296   dnl platforms.
1297   XAPIAN_LIBS="$XAPIAN_LIBS -lstdc++"
1299   dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
1300   dnl which we actually have.
1301   AC_EGREP_CPP(yes,
1302     [#ifdef __INTEL_COMPILER
1303      yes
1304      #endif
1305     ],
1306     [
1307       dnl Intel's compiler:
1308       dnl
1309       dnl -w1 stops the avalanche of uninteresting "remark" messages.
1310       dnl -wd... disables warnings which don't have good code workarounds.
1311       dnl
1312       dnl Swig generated code gives lots of unused and uninitialized warnings.
1313       dnl They're non-harmful, so suppress them.
1314       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
1315     ],
1316     [
1317       dnl GCC or clang:
1318       dnl
1319       dnl Swig generated code gives lots of unused and uninitialized warnings.
1320       dnl They're non-harmful, so suppress them.
1321       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fshow-column -Wall -Wno-unused -Wno-uninitialized"
1322     ])
1324   if test no != "$enable_visibility"; then
1325     dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1326     dnl on mingw).
1327     AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
1328     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
1329       AC_MSG_RESULT([yes])
1330       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden"
1331     else
1332       AC_MSG_RESULT([no])
1333     fi
1334   fi
1336 AC_SUBST(SWIG_CXXFLAGS)
1338 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1339 CXXFLAGS=$save_CXXFLAGS
1341 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1342 : ${AUTOM4TE=autom4te}
1343 AC_SUBST([AUTOM4TE])
1345 AC_CONFIG_FILES([Makefile
1346  doxygen_xml.conf
1347  xapian-version.h
1348  python/Makefile python/docs/conf.py python/version.i
1349  python3/Makefile python3/docs/conf.py python3/version.i
1350  php/Makefile
1351  java/Makefile
1352  tcl8/Makefile tcl8/pkgIndex.tcl
1353  csharp/Makefile csharp/AssemblyInfo.cs
1354  ruby/Makefile
1355  perl/Makefile perl/util.i
1356  lua/Makefile
1357  xapian-bindings.spec
1358  ])
1359 AC_OUTPUT
1361 echo ""
1362 if test -z "$BINDINGS" ; then
1363   echo "*** Not found the required tools for building bindings for any"
1364   echo "*** supported language!"
1365   echo "***"
1366   echo "*** You may need to install -dev or -devel packages for the languages"
1367   echo "*** you want to build bindings for."
1368   echo "***"
1369   echo "*** For details of how to point configure at tools not on PATH, see:"
1370   echo "***     ./configure --help"
1371 else
1372   echo "*** Building bindings for languages:" $BINDINGS
1374 echo ""
1375 if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
1376   release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
1377   case $XAPIAN_VERSION in
1378   $release_series*) ;;
1379   *)
1380     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.])
1381     ;;
1382   esac
1383   dnl 0.8.2 was the first version which set XAPIAN_VERSION
1384   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.])