[java] Improve build on FreeBSD and DragonFlyBSD
[xapian.git] / xapian-bindings / configure.ac
blob923118668a63ee3b8291fa7c58d663df0b15709a
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.5.0])
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.13 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_DIRS([m4])
19 AC_CANONICAL_HOST
21 dnl Use libtool to manage our libraries, but don't build static libraries as
22 dnl the bindings only have a use for dynamic ones.
23 LT_PREREQ([2.2.6])
24 LT_INIT([disable-static])
26 dnl Make the name of libtool's `.libs`/`_libs` available in makefiles.
27 _libs=$objdir
28 AC_SUBST([_libs])
30 dnl -no-undefined causes problems on macOS with at least some
31 dnl MACOSX_DEPLOYMENT_TARGET settings, so only pass -no-undefined on
32 dnl platforms where it is required in order to link a shared library at
33 dnl all (Windows is the main one).
34 NO_UNDEFINED=
35 if test unsupported = "$allow_undefined_flag" ; then
36   NO_UNDEFINED=-no-undefined
38 AC_SUBST(NO_UNDEFINED)
40 dnl Checks for programs.
41 AC_PROG_CXX
43 # Checked: dragonfly6.4 freebsd8.0 netbsd9.3 openbsd4.6 solaris2.9 solaris2.10
44 case $host_os in
45   linux* | k*bsd*-gnu | dragonfly* | freebsd* | netbsd* | openbsd* | solaris*)
46     dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
47     link_all_deplibs_CXX=no
48     ;;
49 esac
51 case $host_os in
52   linux*)
53     dnl Extract search path from ldconfig which is more reliable than the way
54     dnl vanilla libtool extracts them from ld.so.conf.
55     d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
56     test -z "$d" || sys_lib_dlsearch_path_spec=$d
57     ;;
58 esac
60 dnl Run tests using the C++ compiler.
61 AC_LANG([C++])
63 dnl Probe for any options needed to enable C++17 support.
64 AX_CXX_COMPILE_STDCXX([17])
66 dnl Check for xapian-core.
67 XO_LIB_XAPIAN([], [],
68     [xapian-config]regexp(project_version,
69                           [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
70 XO_REQUIRE([1.4.0])
72 NEED_JNILIB_EXT=no
73 NEED_INTREE_DYLD=no
74 INTREE_DYLD_PATH=
75 case $host_os in
76 darwin*)
77   NEED_JNILIB_EXT=yes
78   dnl If we're building against an uninstalled xapian-core, xapian-config
79   dnl --libs will give an error.
80   if $XAPIAN_CONFIG --libs >/dev/null 2>/dev/null ; then
81     :
82   else
83     NEED_INTREE_DYLD=yes
84     dnl $XAPIAN_LIBS may have some options first, so grab the last argument,
85     dnl which should be the .la file.
86     set x $XAPIAN_LIBS
87     as_fn_arith $# - 1
88     shift $as_val
89     INTREE_DYLD_PATH=$1
90     dnl Make sure the path is absolute.
91     case $INTREE_DYLD_PATH in
92       /*) ;;
93       *) INTREE_DYLD_PATH=`pwd`/$INTREE_DYLD_PATH ;;
94     esac
95     dnl Add .libs or equivalent.
96     INTREE_DYLD_PATH=`echo "$INTREE_DYLD_PATH"|sed 's,\(.*/\).*,\1,'`$_libs
97     AC_SUBST([INTREE_DYLD_PATH])
98   fi
99   ;;
100 esac
101 AM_CONDITIONAL(NEED_JNILIB_EXT, test yes = "$NEED_JNILIB_EXT")
102 AM_CONDITIONAL(NEED_INTREE_DYLD, test yes = "$NEED_INTREE_DYLD")
104 dnl We want XAPIAN_CXXFLAGS to be used for configure tests, so add it to
105 dnl CXXFLAGS for the duration of configure.
106 save_CXXFLAGS=$CXXFLAGS
107 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
109 dnl COMPAT_VERSION is the version of xapian-core that "matches" our version.
110 dnl We allow for bindings being version 0.8.5.1 while xapian-core is 0.8.5.
111 dnl COMPAT_VERSION also ignores any _git123 suffix which snapshots will have.
112 COMPAT_VERSION=[`echo "$PACKAGE_VERSION"|sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`]
113 AC_SUBST(COMPAT_VERSION)
115 dnl VERSION_NO_SNAPSHOT simply has any _git123 suffix removed.
116 VERSION_NO_SNAPSHOT=[`echo "$PACKAGE_VERSION"|sed 's/_.*$//'`]
117 AC_SUBST(VERSION_NO_SNAPSHOT)
119 dnl We only need to set docdir for compatibility with autoconf < 2.60 - this
120 dnl code can be removed once we move to requiring autoconf 2.60 or newer.
121 test -n "$docdir" || docdir='${datadir}/doc/${PACKAGE_TARNAME}'
122 AC_SUBST(docdir)
124 AC_ARG_ENABLE(visibility,
125   [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
126   [case ${enableval} in
127     yes|no) ;;
128     *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
129   esac])
131 dnl Only probe for SWIG and enable SWIG rules in makefiles if
132 dnl configure --enable-maintainer-mode is used.
133 AM_MAINTAINER_MODE
135 AC_ARG_ENABLE(documentation,
136   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild shipped documentation [default=maintainer-mode]])],
137   [case ${enableval} in
138     yes|no) ;;
139     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
140   esac])
141 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
142 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
143 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
145 if test yes = "$enable_documentation" ; then
146   dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
147   dnl Also look for rst2html.py, which archlinux reportedly installs it as.
148   AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
149   AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
150   test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python3-docutils)])
153 if test x$USE_MAINTAINER_MODE = xyes; then
154   dnl Check for swig - this does most of the work for the bindings.
155   dnl AC_PATH_PROGS only honours an already set SWIG if it's a full
156   dnl path.  Listing it in the "to be searched" list like this allows
157   dnl ./configure SWIG=myswig to work.
158   swigoverridden=${SWIG+yes}
159   AC_PATH_PROGS(SWIG, ["${SWIG-swig}"], [])
160   AC_ARG_VAR(SWIG, [SWIG interface generator (only needed by Xapian developers)])
161   if test -z "$SWIG" ; then
162     AC_MSG_ERROR([Can't find SWIG utility])
163   fi
164   dnl Check for new enough SWIG.
165   dnl
166   dnl 4.1.0 adds support for PHP 8
167   v=`$SWIG -version 2>&1|sed 's/^SWIG Version \([[0-9\.]]*\).*/\1/p;d'`
168   case $v in
169     [[0123].*|4.0.*|""])
170       msg="SWIG >= 4.1.0 required (you have ${v:-an unknown version})"
171       if test -n "$swigoverridden" ; then
172         dnl If SWIG was explicitly set, make this a warning only.
173         AC_MSG_WARN([$msg])
174       else
175         AC_MSG_ERROR([$msg])
176       fi ;;
177   esac
178   SWIG_FLAGS=`$XAPIAN_CONFIG --swigflags`
179   AC_SUBST(SWIG_FLAGS)
180   XAPIAN_HEADER_DIRS=
181   XAPIAN_HEADERS=
182   for a in $SWIG_FLAGS ; do
183     case $a in
184     -I*)
185       d=`echo "x$a"|sed 's/^x-I//'`
186       dnl Quote each entry in XAPIAN_HEADER_DIRS with "".
187       XAPIAN_HEADER_DIRS=$XAPIAN_HEADER_DIRS' "'$d'"'
188       for f in "$d/"*.h "$d/xapian/*.h" ; do
189         if test -f "$f" ; then
190           XAPIAN_HEADERS="$XAPIAN_HEADERS $f"
191         fi
192       done
193       ;;
194     esac
195   done
196   AC_SUBST([XAPIAN_HEADER_DIRS])
197   AC_SUBST([XAPIAN_HEADERS])
199   dnl Need perl in maintainer mode to generate except.i files for several
200   dnl languages.
201   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
202   test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
203   dnl Need doxygen in maintainer mode to convert C++ doxygen comments to Python
204   dnl docstrings.
205   AC_PATH_PROG(DOXYGEN, doxygen, [])
206   AC_ARG_VAR([DOXYGEN], [Doxygen documentation system])
207   test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
210 AC_ARG_WITH(python3,
211   AS_HELP_STRING([--with-python3], [enable Python 3 bindings]),
212   [],
213   [with_python3=])
215 AC_ARG_WITH(php,
216   AS_HELP_STRING([--with-php], [enable PHP bindings]),
217   [],
218   [with_php=])
220 AC_ARG_WITH(ruby,
221   AS_HELP_STRING([--with-ruby], [enable Ruby bindings]),
222   [],
223   [with_ruby=])
225 AC_ARG_WITH(tcl,
226   AS_HELP_STRING([--with-tcl], [enable Tcl bindings]),
227   [],
228   [with_tcl=])
230 AC_ARG_WITH(csharp,
231   AS_HELP_STRING([--with-csharp], [enable CSharp bindings]),
232   [],
233   [with_csharp=])
235 AC_ARG_WITH(java,
236   AS_HELP_STRING([--with-java], [enable Java bindings]),
237   [],
238   [with_java=])
240 AC_ARG_WITH(perl,
241   AS_HELP_STRING([--with-perl], [enable Perl bindings]),
242   [],
243   [with_perl=])
245 AC_ARG_WITH(lua,
246   AS_HELP_STRING([--with-lua], [enable Lua bindings]),
247   [],
248   [with_lua=])
250 case $with_python3$with_php$with_ruby$with_tcl$with_csharp$with_java$with_perl$with_lua in
251 *yes*)
252   dnl Default unspecified values to no.
253   test -z "$with_python3" && with_python3=no
254   test -z "$with_php" && with_php=no
255   test -z "$with_tcl" && with_tcl=no
256   test -z "$with_csharp" && with_csharp=no
257   test -z "$with_java" && with_java=no
258   test -z "$with_ruby" && with_ruby=no
259   test -z "$with_perl" && with_perl=no
260   test -z "$with_lua" && with_lua=no
261   ;;
262 esac
264 BINDINGS=
266 if test no != "$with_python3" ; then
267   python3_ok=no
268   dnl See comment for AC_PATH_PROGS(SWIG, ...).
269   if test -n "$PYTHON3" ; then
270     AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
271   else
272     AC_PATH_PROGS(PYTHON3, [python3 python], [])
273   fi
274   AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
275   if test -n "$PYTHON3" ; then
276     python3_ok=yes
277     dnl Require Python 3.3 or newer, as that's the oldest version we can
278     dnl easily test with.  If anyone's keen to support older versions, please
279     dnl test and send in any patches needed to get it to work.
280     AC_MSG_CHECKING([$PYTHON3 version])
281     version=`$PYTHON3 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
282     case $version in
283     [3.[3-9]*|3.[12][0-9]*|[4-9].*])
284       AC_MSG_RESULT([$version])
285       ;;
286     *)
287       AC_MSG_RESULT([$version (too old, only 3.3 or newer is supported)])
288       python3_ok=no
289       ;;
290     esac
291     if test yes = "$python3_ok" ; then
292       PYTHON3_INC=`$PYTHON3 -c 'import os,sysconfig;print(sysconfig.get_path("include").replace(os.sep,"/"))' 2>/dev/null`
293       AC_SUBST(PYTHON3_INC)
295       AC_MSG_CHECKING([for python3 sphinx module])
296       if $PYTHON3 -c 'import sphinx' >&5 2>&5 ; then
297         AC_MSG_RESULT([yes])
298       else
299         AC_MSG_RESULT([no (try installing package python3-sphinx])
300         python3_ok=no
301       fi
302     fi
303     if test yes = "$python3_ok" ; then
304       dnl Check that Python.h is there, which is a good way to check that
305       dnl the appropriate python3-dev package has been installed.
306       AC_MSG_CHECKING([for $PYTHON3_INC/Python.h])
307       if test -f "$PYTHON3_INC/Python.h" ; then
308         AC_MSG_RESULT(yes)
309         AC_MSG_CHECKING([for directory to install python3 bindings in])
310         if test -z "$PYTHON3_LIB" ; then
311           PYTHON3_LIB=`$PYTHON3 -c 'import os,sysconfig;print(sysconfig.get_path("platlib").replace(os.sep,"/"))'`
312         fi
313         AC_MSG_RESULT([$PYTHON3_LIB])
314         AC_ARG_VAR(PYTHON3_LIB, [Directory to install python3 bindings in])
316         AC_MSG_CHECKING([for python3 libraries to link against])
317         case $host_os in
318         mingw* | pw32*)
319           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
320         cygwin*)
321           PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
322         *)
323           PYTHON3_LIBS= ;;
324         esac
325         AC_SUBST(PYTHON3_LIBS)
326         AC_MSG_RESULT([$PYTHON3_LIBS])
328         AC_MSG_CHECKING([for python3 module extension])
329         dnl Encodes the Python version the module is built for, and ends with
330         dnl the platform-dependent shared object extension (which is `.so` on
331         dnl most Unix-like platforms) - e.g. `.cpython-310-x86_64-linux-gnu.so`
332         PYTHON3_EXT_SUFFIX=`$PYTHON3 -c 'import sysconfig;print(sysconfig.get_config_var("EXT_SUFFIX"))'`
333         AC_SUBST(PYTHON3_EXT_SUFFIX)
334         AC_MSG_RESULT([$PYTHON3_EXT_SUFFIX])
336         AC_MSG_CHECKING([for tag for cached compiled scripts])
337         PYTHON3_CACHE_TAG=`$PYTHON3 -c 'import sys;print(sys.implementation.cache_tag)'`
338         AC_SUBST(PYTHON3_CACHE_TAG)
339         AC_MSG_RESULT([$PYTHON3_CACHE_TAG])
341         AC_MSG_CHECKING([for extension of cached and optimized python3 bytecode])
342         dnl We use -O instead of cache_from_source()'s optimization parameter
343         dnl as the latter was only added in Python 3.5.  The fallback is needed
344         dnl as cache_from_source() itself is new in Python 3.4.
345         dnl
346         dnl Some Python versions (or maybe packages) need us to explicitly
347         dnl `import importlib.util` here, but others work without it.
348         dnl
349         dnl This needs a shell-level || because Python one line program support
350         dnl is poor.
351         PYTHON3_CACHE_OPT1_EXT=`$PYTHON3 -O -c 'import importlib,importlib.util,sys;print("{1}{2}".format(*importlib.util.cache_from_source("").rpartition(sys.implementation.cache_tag)))' 2>/dev/null || $PYTHON3 -c 'import imp;print(imp.get_tag()+".pyo")'`
352         AC_SUBST(PYTHON3_CACHE_OPT1_EXT)
353         AC_MSG_RESULT([$PYTHON3_CACHE_OPT1_EXT])
354       else
355         AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
356         python3_ok=no
357       fi
358     fi
359   fi
360   if test yes = "$python3_ok" ; then
361     BINDINGS="$BINDINGS python3"
362   elif test yes = "$with_python3" ; then
363     AC_MSG_ERROR([Python3 bindings build dependencies not found])
364   fi
367 if test x$USE_MAINTAINER_MODE = xyes; then
368   dnl Need python in maintainer mode to run doxy2swig.py.
369   if test -n "$PYTHON3" ; then
370     PYTHON=$PYTHON3
371   else
372     dnl Either Python 2 or 3 is OK so no need to check the version.
373     AC_PATH_PROGS(PYTHON, [python3 python], [])
374   fi
375   test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
378 if test no != "$with_php" ; then
379   php_ok=no
380   dnl See comment for AC_PATH_PROGS(SWIG, ...).
381   if test -n "$PHP_CONFIG" ; then
382     AC_PATH_PROGS(PHP_CONFIG, ["$PHP_CONFIG"], [])
383   fi
384   if test -z "$PHP_CONFIG" ; then
385     AC_PATH_PROGS(PHP_CONFIG, [php-config8.4 php-config8.3 php-config8.2 php-config8.1 php-config8.0 php-config], [])
386   fi
387   AC_ARG_VAR(PHP_CONFIG, [php-config utility for PHP])
388   AC_ARG_VAR(PHP, [PHP interpreter (optional - only needed to run PHP testsuite with)])
389   if test -n "$PHP_CONFIG" ; then
390     php_ok=yes
391     AC_MSG_CHECKING([$PHP_CONFIG version])
392     version=`$PHP_CONFIG --version 2>/dev/null`
393     case $version in
394     [[01234567].*])
395       AC_MSG_RESULT([$version (not supported, PHP bindings need PHP >= 8)])
396       php_ok=no
397       ;;
398     *)
399       AC_MSG_RESULT([$version])
400       PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
401       ;;
402     esac
403     AC_SUBST(PHP_MAJOR_VERSION)
405     if test yes = "$php_ok" ; then
406       AC_MSG_CHECKING([for PHP extension directory])
407       if test -z "$PHP_EXTENSION_DIR" ; then
408         PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
409       fi
410       AC_MSG_RESULT([$PHP_EXTENSION_DIR])
411       AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP extensions in])
413       PHP_INC=`$PHP_CONFIG --includes`
414       AC_SUBST(PHP_INC)
416       if test x"$PHP" = x ; then
417         AC_MSG_CHECKING([for PHP interpreter])
418         PHP=`$PHP_CONFIG --php-binary 2>/dev/null`
419         if test x"$PHP" != x ; then
420           if $PHP -r 'exit(0);' 2> /dev/null ; then
421             if $PHP -r 'exit(PHP_MAJOR_VERSION>=8?0:1);' 2> /dev/null ; then
422               AC_MSG_RESULT([$PHP])
423             else
424               AC_MSG_RESULT([no ($PHP isn't PHP >= 8)])
425               PHP=
426             fi
427           else
428             AC_MSG_RESULT([no ($PHP does not work)])
429             PHP=
430           fi
431         else
432           AC_MSG_RESULT([not found])
433         fi
434       else
435         AC_PATH_PROGS(PHP, ["$PHP"], [])
436       fi
437       if test x"$PHP" = x ; then
438         AC_MSG_WARN([No PHP interpreter found - PHP bindings tests will be skipped])
439         dnl The skiptest script just returns exit code 77.
440         PHP='$(top_srcdir)/skiptest'
441       else
442         AC_MSG_CHECKING([for PHP path separator])
443         PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
444         AC_SUBST([PHP_PATH_SEPARATOR])
445         AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
447         AC_MSG_CHECKING([for PHP shared library suffix])
448         PHP_SHLIB_SUFFIX=`$PHP -r 'echo PHP_SHLIB_SUFFIX;'`
449         AC_SUBST([PHP_SHLIB_SUFFIX])
450         AC_MSG_RESULT([$PHP_SHLIB_SUFFIX])
451       fi
453       case $host_os in
454       mingw* | pw32*)
455         dnl This is a bit of an informed guess, pending more information from
456         dnl someone who actually has mingw and wants to build the PHP bindings
457         dnl there.  FIXME.
458         PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
459       cygwin*)
460         PHP_LIBS="-lphp${PHP_MAJOR_VERSION}" ;;
461       *)
462         PHP_LIBS= ;;
463       esac
464       AC_SUBST(PHP_LIBS)
465     fi
466   fi
467   if test yes = "$php_ok" ; then
468     BINDINGS="$BINDINGS php"
469   elif test yes = "$with_php" ; then
470     AC_MSG_ERROR([PHP bindings build dependencies not found])
471   fi
474 if test no != "$with_tcl" ; then
475   tcl_ok=no
476   dnl The documented minimum requirement is Tcl 8.5.  Older versions may work,
477   dnl but we don't test with them regularly, and they are no longer supported
478   dnl upstream.  Also ::tcl::pkgconfig was added in Tcl 8.5, which makes the
479   dnl tests below simpler and more reliable.
480   dnl
481   dnl If you really want to build with an older version, run configure with
482   dnl a lower tcl_min and specify at least TCL_INC explicitly:
483   dnl
484   dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
485   dnl
486   dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
487   : ${tcl_min=8.5}
488   AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
489   AC_ARG_VAR(TCLSH, [Tcl interpreter])
490   if test -n "$TCLSH" ; then
491     tcl_ok=yes
492     AC_MSG_CHECKING([$TCLSH version])
493     if echo 'if {$tcl_version < '"$tcl_min"' } { exit 1 }'|$TCLSH 2> /dev/null ; then
494       tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
495       AC_MSG_RESULT([$tcl_version])
497       AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
498       if test -z "$TCL_LIB" ; then
499         [TCL_LIB=`echo 'foreach d [expr {[info exists tcl_pkgPath]?$tcl_pkgPath:$auto_path}] {if {![regexp {/share(/|$)} $d]} {break}}; puts $d'|$TCLSH`]
500       fi
501       AC_SUBST(TCL_LIB)
503       AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
504       if test -z "$TCL_INC" ; then
505         dnl ::tcl::pkgconfig was added in Tcl 8.5.
506         [TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
507       fi
509       dnl Check that the headers are there (the tcl8.N-dev package
510       dnl may not be installed).
511       TCL_CPPFLAGS=
512       AC_MSG_CHECKING([for tcl.h from Tcl $tcl_version])
513       if test x"$TCL_INC" != x && test -f "$TCL_INC/tcl.h" ; then
514         tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
515         if test x"$tcl_hdr_version" = x"$tcl_version" ; then
516           AC_MSG_RESULT([$TCL_INC/tcl.h])
517           if test x"$TCL_INC" != x"/usr/include" ; then
518             TCL_CPPFLAGS="-I$TCL_INC"
519           fi
520         else
521           AC_MSG_RESULT([$TCL_INC/tcl.h from Tcl $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
522           tcl_ok=no
523         fi
524       else
525         AC_MSG_RESULT([not found])
526         tcl_ok=no
527       fi
529       TCL_LIBS=
530       TCL_SHLIB_EXT=
531       if test yes = "$tcl_ok" ; then
532         dnl ::tcl::pkgconfig was added in Tcl 8.5.  Prior to 8.6 it's only
533         dnl actually necessary to link against -ltclstub on platforms which
534         dnl don't allow libraries to have unresolved symbols (cygwin, mingw,
535         dnl msvc, etc)
536         [tcl_libdir_runtime=`echo 'puts [::tcl::pkgconfig get libdir,runtime]'|$TCLSH 2> /dev/null`]
537         if test -n "$tcl_libdir_runtime" ; then
538           for x in "/tcl$tcl_version" "" ; do
539             TCLCONFIG_SH=$tcl_libdir_runtime$x/tclConfig.sh
540             if test -r "$TCLCONFIG_SH" ; then
541               TCL_LIBS=`. $TCLCONFIG_SH && printf '%s' "$TCL_STUB_LIB_SPEC"`
542               break
543             fi
544           done
545         fi
546         TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS"
547         [TCL_SHLIB_EXT=`echo 'puts [info sharedlibextension]'|$TCLSH 2> /dev/null`]
548       fi
550       AC_SUBST(TCL_CPPFLAGS)
551       AC_SUBST(TCL_LIBS)
552       AC_SUBST(TCL_SHLIB_EXT)
553     else
554       AC_MSG_RESULT([< $tcl_min (too old)])
555       tcl_ok=no
556     fi
557   fi
558   if test yes = "$tcl_ok" ; then
559     BINDINGS="$BINDINGS tcl8"
560   elif test yes = "$with_tcl" ; then
561     AC_MSG_ERROR([Tcl bindings build dependencies not found])
562   fi
565 if test no != "$with_csharp" ; then
566   csharp_ok=no
567   AC_ARG_VAR(CSC, [CSharp compiler command])
568   if test -n "$CSC" ; then
569     AC_PATH_PROGS(CSC, ["$CSC"], [])
570   fi
571   if test -z "$CSC" ; then
572     dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
573     dnl as "alternatives" which can be mapped to the CSharp compiler the admin
574     dnl favours.
575     AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
576     if test -z "$CSC" ; then
577       dnl mcs is the Mono CSharp compiler, which is a unified compiler
578       dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
579       dnl that's no longer relevant).
580       AC_PATH_PROGS(CSC, [mcs], [])
581       if test -n "$CSC" ; then
582         dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
583         dnl so we check that the mcs we found understands --version which is
584         dnl sufficient to distinguish mono's mcs from the Tru64 one.
585         AC_MSG_CHECKING([whether $CSC is from GNU Mono])
586         if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
587           AC_MSG_RESULT(yes)
588           csharp_ok=yes
589         else
590           AC_MSG_RESULT([no (ignoring $CSC)])
591         fi
592       fi
593     fi
594     if test no = "$csharp_ok" ; then
595       dnl csc is the Microsoft CSharp compiler.
596       AC_PATH_PROGS(CSC, [csc], [])
597       if test -n "$CSC" ; then
598         dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
599         dnl check if the output from "csc -version" includes the word chicken
600         dnl which is sufficient to distinguish Chicken's csc from Microsoft's
601         dnl csc.exe.
602         AC_MSG_CHECKING([whether $CSC is for CSharp])
603         if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
604           AC_MSG_RESULT([no (ignoring $CSC from Chicken)])
605         else
606           AC_MSG_RESULT(yes)
607           csharp_ok=yes
608         fi
609       fi
610     fi
611   fi
613   if test yes = "$csharp_ok" ; then
614     AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
615     if test -n "$GACUTIL" ; then
616       AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
617     fi
618     if test -z "$GACUTIL" ; then
619       AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil], [])
620     fi
622     AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
623     if test -n "$SN" ; then
624       AC_PATH_PROGS(SN, ["$SN"], [])
625     fi
626     if test -z "$SN" ; then
627       AC_PATH_PROGS(SN, [cli-sn sn], [])
628     fi
629     if test -n "$GACUTIL" && test -n "$SN" ; then
630       AC_MSG_CHECKING([whether the CSharp compiler works])
631       [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
632       if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
633         AC_MSG_RESULT(yes)
634         AC_MSG_CHECKING([whether CSharp programs can just be run])
635         if test OK = "`./conftest.exe 2> /dev/null`" ; then
636           AC_MSG_RESULT(yes)
637           RUN_CSHARP=
638         else
639           AC_MSG_RESULT(no)
640           AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
641           if test -z "$CLI" ; then
642             AC_PATH_PROGS(CLI, [mono ilrun], [])
643           fi
644           AC_ARG_VAR(CLI, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
645           if test -n "$CLI" ; then
646             AC_MSG_CHECKING([whether $CLI can run CSharp programs])
647             if test OK = "`$CLI ./conftest.exe 2> /dev/null`" ; then
648               AC_MSG_RESULT(yes)
649               RUN_CSHARP=$CLI
650             else
651               AC_MSG_RESULT([no - CSharp tests will be skipped])
652               RUN_CSHARP='\$(top_srcdir)/skiptest'
653             fi
654           else
655             AC_MSG_RESULT([not found - CSharp tests will be skipped])
656             RUN_CSHARP='\$(top_srcdir)/skiptest'
657           fi
658         fi
659         AC_SUBST(RUN_CSHARP)
661         AC_MSG_CHECKING([for extra flags for $GACUTIL])
662         GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
663         dnl Microsoft's gacutil accepts fewer options than Mono's
664         $GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
665         AC_SUBST([GACUTIL_FLAGS])
666         if test -z "$GACUTIL_FLAGS" ; then
667           AC_MSG_RESULT([no])
668         else
669           AC_MSG_RESULT([$GACUTIL_FLAGS])
670         fi
671       else
672         AC_MSG_RESULT(no)
673         csharp_ok=no
674       fi
675     else
676       csharp_ok=no
677     fi
678   fi
679   if test yes = "$csharp_ok" ; then
680     BINDINGS="$BINDINGS csharp"
681   elif test yes = "$with_csharp" ; then
682     AC_MSG_ERROR([CSharp bindings build dependencies not found])
683   fi
686 JAVA_CPPFLAGS=
687 if test no != "$with_java" ; then
688   java_ok=no
689   AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
690         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
691   AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
692         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
693   AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
694         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
695   AC_ARG_VAR(JAVA, [Java interpreter command])
696   AC_ARG_VAR(JAVAC, [Java compiler command])
697   AC_ARG_VAR(JAR, [java jar utility])
698   AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
699   AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
700   AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
701   if test -n "$JAVA" && test -n "$JAVAC" && test -n "$JAR" ; then
702     dnl Eric says:
703     dnl  The JNI library *requires* "Java 2", which is 1.2 or better.
704     dnl
705     dnl So checking for jni.h presumably implicitly checks we have "Java 2".
706     dnl Note: jni.h #defines JNI_VERSION_1_[12468] (but not 3, 5 or 7 it seems).
707     dnl So we could check for one of these if we want to check for a particular
708     dnl JDK version...
709     AC_CHECK_HEADER([jni.h], [java_ok=yes], [
710       SAVE_CPPFLAGS=$CPPFLAGS
711       real_javac=$JAVAC
712       dnl Avoid endlessly traversing if there's a symlink loop.
713       for count in 1 2 3 4 5 6 7 8 9 ; do
714         r=`readlink "$real_javac"`
715         test -n "$r" || break
716         real_javac=$r
717       done
718       dnl Translate ".../bin/javac" to ".../include".
719       [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
720       dnl Try the location for macOS system Java too, but last.
721       for jnidir in \
722           $JNI_INCLUDE_DIR \
723           ${JAVA_HOME+"$JAVA_HOME/include"} \
724           ${JDK_HOME+"$JDK_HOME/include"} \
725           "$rel_jnidir" \
726           /System/Library/Frameworks/JavaVM.framework/Headers ; do
727         CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
728         AC_MSG_CHECKING([for jni.h in $jnidir])
729         if test -f "$jnidir/jni.h" ; then
730           AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
731           if test yes = $java_ok ; then
732             AC_MSG_RESULT([yes])
733             JAVA_CPPFLAGS=-I$jnidir
734             break
735           fi
737           dnl For OpenJDK (and maybe others) we have to specify an extra -I
738           dnl option for an OS-specific subdirectory containing a "jni_md.h"
739           dnl header which is included by "jni.h".  Sadly we seem to need to
740           dnl hardcode a mapping for these platform names - the list below
741           dnl was determined by inspecting the source code of OpenJDK 8.
742           jni_host_os=
743           case $host_os in
744             linux*)
745               jni_host_os=linux ;;
746             solaris*)
747               jni_host_os=solaris ;;
748             mingw* | pw32* | cygwin*)
749               jni_host_os=win32 ;;
750             darwin*)
751               jni_host_os=darwin ;;
752             dragonfly*)
753               dnl Correct for Dragonfly openjdk17 package; also in `freebsd/`.
754               jni_host_os=dragonfly ;;
755             freebsd*)
756               dnl Correct for FreeBSD openjdk17 package.
757               jni_host_os=freebsd ;;
758             *bsd*)
759               jni_host_os=bsd ;;
760             aix*)
761               jni_host_os=aix ;;
762           esac
763           if test -n "$jni_host_os" ; then
764             CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
765             AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
766             if test yes = $java_ok ; then
767               AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
768               JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
769               break
770             fi
771           fi
772           AC_MSG_RESULT([found, but not usable])
774           CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
775         else
776           AC_MSG_RESULT([no])
777         fi
778       done
779       CPPFLAGS=$SAVE_CPPFLAGS
780       ], [ ])
781     AC_SUBST(JAVA_CPPFLAGS)
782     if test yes = $java_ok ; then
783       AC_MSG_CHECKING([for Java path separator])
784       [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
785       if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
786         JAVA_PATHSEP=`$JAVA conftest 2>&5`
787         AC_SUBST(JAVA_PATHSEP)
788         if test -n "$JAVA_PATHSEP" ; then
789           AC_MSG_RESULT($JAVA_PATHSEP)
791           dnl If -Xcheck:jni is supported then run tests with it.
792           dnl
793           dnl ... except that with OpenJDK 8 and 9 -Xcheck:jni seems to report
794           dnl false positives and so can't usefully be turned on in this
795           dnl situation.  Recheck this with future versions.
796 dnl       AC_MSG_CHECKING([for $JAVA -Xcheck:jni option])
797 dnl       JAVA_PATHSEP2=`$JAVA conftest 2>&5`
798           JAVA_CHECK_JNI_OPTION=
799 dnl       if test "$JAVA_PATHSEP" = "$JAVA_PATHSEP2" ; then
800 dnl         JAVA_CHECK_JNI_OPTION=-Xcheck:jni
801 dnl         AC_MSG_RESULT([yes])
802 dnl       else
803 dnl         AC_MSG_RESULT([no])
804 dnl       fi
805           AC_SUBST([JAVA_CHECK_JNI_OPTION])
806         else
807           AC_MSG_RESULT([failed to run Java test program])
808           java_ok=no
809         fi
810       else
811         AC_MSG_RESULT([failed to compile Java test program])
812         java_ok=no
813       fi
814     fi
815   fi
816   if test yes = "$java_ok" ; then
817     BINDINGS="$BINDINGS java"
818   elif test yes = "$with_java" ; then
819     AC_MSG_ERROR([Java bindings build dependencies not found])
820   fi
823 if test no != "$with_ruby" ; then
824   ruby_ok=no
825   dnl See comment for AC_PATH_PROGS(SWIG, ...).
826   if test -n "$RUBY" ; then
827     AC_PATH_PROGS(RUBY, ["$RUBY"], [])
828   else
829     AC_PATH_PROGS(RUBY, [ruby], [])
830   fi
831   AC_ARG_VAR(RUBY, [Ruby interpreter])
832   if test -n "$RUBY" ; then
833     dnl Require Ruby 2.1 or newer.
834     AC_MSG_CHECKING([$RUBY version])
835     dnl RUBY_VERSION works with 1.6.  Once we've checked we have at least 1.8
836     dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8).
837     version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
838     case $version in
839     "")
840       AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work]) ;;
841     [[01].*|2.0.*])
842       AC_MSG_RESULT([$version (too old, only Ruby 2.1 or newer is supported)]) ;;
843     *)
844       ruby_ok=yes ;;
845     esac
846     if test yes = "$ruby_ok" ; then
847       AC_MSG_RESULT([$version])
848       AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
849       if test -z "$RUBY_INC" ; then
850         dnl Ruby 1.9 added rubyhdrdir.
851         [RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]'`]
852       fi
853       AC_SUBST(RUBY_INC)
854       dnl Check that ruby.h is there, which is a good way to check that
855       dnl the appropriate ruby-dev package has been installed.
856       AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
857       if test -f "$RUBY_INC/ruby.h" ; then
858         AC_MSG_RESULT(yes)
860         AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found])
861         if test -z "$RUBY_INC_ARCH" ; then
862           dnl Ruby 2.0 and later have rubyarchhdrdir.
863           [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]'`]
864         fi
865         AC_SUBST(RUBY_INC_ARCH)
867         AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
868         if test -z "$RUBY_LIB" ; then
869           [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
870         fi
871         AC_SUBST(RUBY_LIB)
873         AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
874         if test -z "$RUBY_LIB_ARCH" ; then
875           [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
876         fi
877         AC_SUBST(RUBY_LIB_ARCH)
879         RUBY_LIBS=
880         if test unsupported = "$allow_undefined_flag" ; then
881           dnl For Microsoft Windows and a few other platforms.
882           [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
883         fi
884         AC_SUBST(RUBY_LIBS)
886         dnl rdoc is included as part of the Ruby core distribution, so run it
887         dnl at build time rather shipping the rather large generated output in
888         dnl our source tarball.
889         if test -z "$RDOC" ; then
890           dnl Try replace the *last* 'ruby' with 'rdoc'.
891           rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
892           if test -x "$rdoc_best_guess" ; then
893             RDOC=$rdoc_best_guess
894           fi
895         fi
896         AC_PATH_PROGS(RDOC, [rdoc], [])
897         if test -z "$RDOC"; then
898           ruby_ok=no
899         fi
900         AC_ARG_VAR([RDOC], [Ruby documentation generator])
902         RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
903         AC_SUBST(RUBY_DLEXT)
904       else
905         AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
906         ruby_ok=no
907       fi
908     fi
909   fi
910   if test yes = "$ruby_ok" ; then
911     BINDINGS="$BINDINGS ruby"
912   elif test yes = "$with_ruby" ; then
913     AC_MSG_ERROR([Ruby bindings build dependencies not found])
914   fi
917 if test no != "$with_perl" ; then
918   perl_ok=no
919   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
920   AC_ARG_VAR(PERL, [Perl interpreter])
921   if test -n "$PERL" ; then
922     perl_ok=yes
923     if test -z "$PERL_INC" ; then
924       PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
925     fi
926     AC_SUBST(PERL_INC)
928     AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
929     if test -z "$PERL_ARCH" ; then
930       PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
931     fi
932     AC_SUBST(PERL_ARCH)
934     AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
935     if test -z "$PERL_LIB" ; then
936       PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
937     fi
938     AC_SUBST(PERL_LIB)
940     AC_ARG_VAR(PERL_SO, [Extension for compiled Perl modules])
941     if test -z "$PERL_SO" ; then
942       PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
943     fi
944     AC_SUBST(PERL_SO)
946     if test -z "$PERL_XAPIAN_VERSION" ; then
947       dnl snapshot versions look like 1.2.3_git123
948       case $PACKAGE_VERSION in
949       *_git*)
950         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
951       *)
952         PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
953       esac
954     fi
955     AC_SUBST(PERL_XAPIAN_VERSION)
956   fi
957   if test yes = "$perl_ok" ; then
958     BINDINGS="$BINDINGS perl"
959   elif test yes = "$with_perl" ; then
960     AC_MSG_ERROR([Perl bindings build dependencies not found])
961   fi
964 if test no != "$with_lua" ; then
965   lua_ok=no
966   if test -n "$LUA" ; then
967     AC_PATH_PROGS(LUA, ["$LUA"], [])
968   fi
969   if test -z "$LUA" ; then
970     AC_PATH_PROGS(LUA, [lua lua5.4 lua54 lua5.3 lua53 lua5.2 lua52 lua5.1 lua51], [])
971   fi
972   AC_ARG_VAR(LUA, [lua interpreter])
973   if test -n "$LUA" ; then
974     lua_ok=yes
975     AC_MSG_CHECKING([$LUA version])
976     lua_version=`$LUA -e 'print(_VERSION:sub(_VERSION:find(" ")+1))' 2>&AS_MESSAGE_LOG_FD`
977     if test -n "$lua_version"; then
978       AC_MSG_RESULT([$lua_version])
979       dnl We need Lua 5.1 or later.  Unhelpfully there are different naming
980       dnl schemes for Lua in pkg-config on different platforms.
981       PKG_CHECK_MODULES([LUA], [lua$lua_version >= 5.1], [], [
982         PKG_CHECK_MODULES([LUA], [lua-$lua_version >= 5.1], [], [
983           if test yes = "$with_lua" ; then
984             AC_MSG_ERROR([pkg-config module for LUA $lua_version not found])
985           fi
986           lua_ok=no
987         ])
988       ])
989     else
990       AC_MSG_RESULT([could not determine])
991     fi
993     if test yes = "$lua_ok" ; then
994       AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
995       AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
996       if test -z "$LUA_LIB" || test -z "$LUA_SO" ; then
997         dnl If LUA_SO is specified, ensure it has a leading `.`.
998         case $LUA_SO in
999           "") ;;
1000           .*) ;;
1001           *) LUA_SO=.$LUA_SO ;;
1002         esac
1003         dnl Look for the first absolute path in lua_cpath which has leaf
1004         dnl "?.<ext>" where <ext> is not "lua".  If LUA_SO was specified by the
1005         dnl user, only consider entries where <ext> matches LUA_SO.
1006         lua_lib_and_so=`$LUA "$srcdir/lua/unpick-cpath.lua" "$LUA_SO"`
1007         test -n "$LUA_LIB" || LUA_LIB=`expr X"$lua_lib_and_so" : X'\(.*\);'`
1008         test -n "$LUA_SO" || LUA_SO=`expr X"$lua_lib_and_so" : '.*;\(.*\)'`
1009       fi
1010       AC_MSG_CHECKING([for directory to install compiled Lua modules into])
1011       if test -z "$LUA_LIB"; then
1012         AC_MSG_RESULT([not found])
1013         lua_ok=no
1014       else
1015         AC_MSG_RESULT([$LUA_LIB])
1016       fi
1017       AC_SUBST([LUA_LIB])
1019       AC_MSG_CHECKING([for extension to use for compiled Lua modules])
1020       if test -z "$LUA_SO"; then
1021         AC_MSG_RESULT([not found])
1022         lua_ok=no
1023       else
1024         AC_MSG_RESULT([$LUA_SO])
1025       fi
1026       AC_SUBST([LUA_SO])
1027     fi
1028   fi
1030   if test yes = "$lua_ok" ; then
1031     BINDINGS="$BINDINGS lua"
1032   elif test yes = "$with_lua" ; then
1033     AC_MSG_ERROR([lua not found])
1034   fi
1037 AC_SUBST(BINDINGS)
1039 case $BINDINGS in
1040 *python3*)
1041   dnl C++11 has thread_local
1042   dnl GCC and some others have __thread
1043   dnl MSVC and some others have __declspec(thread)
1044   AC_MSG_CHECKING([for thread-local storage qualifier])
1045   AC_ARG_VAR([THREAD_LOCAL], [thread-local storage qualifier])
1046   if test -z "$THREAD_LOCAL" ; then
1047     for t in thread_local __thread '__declspec(thread)' ; do
1048       AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static $t void * p;]])],
1049                         [THREAD_LOCAL=$t; break])
1050     done
1051   fi
1052   if test -z "$THREAD_LOCAL" ; then
1053     AC_MSG_RESULT([unknown, disabling thread-local support])
1054   else
1055     AC_MSG_RESULT([$THREAD_LOCAL])
1056     AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
1057   fi
1058   ;;
1059 esac
1061 dnl Set flags to control warnings (enable more, or disable annoying ones)
1062 dnl and other compiler specific flags.
1063 SWIG_CXXFLAGS=
1064 if test yes = "$GXX" ; then
1065   dnl Python itself is compiled with -fno-strict-aliasing, and it appears
1066   dnl it's safest to follow this lead when compiling the SWIG generated
1067   dnl interface code.  E.g.:
1068   dnl   https://article.gmane.org/gmane.comp.gcc.devel/74692
1069   dnl The code SWIG generates for other languages seems to have similar
1070   dnl issues too, so just turn this on for all of them.
1071   dnl
1072   dnl There's no need to check -fno-strict-aliasing is supported as it works
1073   dnl with GCC 2.95 and we don't support anything older.
1074   SWIG_CXXFLAGS="-fno-strict-aliasing"
1076   dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
1077   dnl which we actually have.
1078   AC_EGREP_CPP(yes,
1079     [#ifdef __INTEL_COMPILER
1080      yes
1081      #endif
1082     ],
1083     [
1084       dnl Intel's compiler:
1085       dnl
1086       dnl -w1 stops the avalanche of uninteresting "remark" messages.
1087       dnl -wd... disables warnings which don't have good code workarounds.
1088       dnl
1089       dnl Swig generated code gives lots of unused and uninitialized warnings.
1090       dnl They're non-harmful, so suppress them.
1091       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
1092     ],
1093     [
1094       dnl GCC or clang:
1095       dnl
1096       dnl Swig generated code gives lots of unused and uninitialized warnings.
1097       dnl They're non-harmful, so suppress them.
1098       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -Wno-unused -Wno-uninitialized"
1099     ])
1101   if test no != "$enable_visibility"; then
1102     dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1103     dnl supported on mingw and visibility attributes result in warnings).
1104     AC_MSG_CHECKING([if $CXX -fvisibility=hidden -fvisibility-inlines-hidden works])
1105     if echo 'int bar() __attribute__((visibility("default"))); int baz() __attribute__((visibility("internal"))); int bar() { return 6; } int baz() { return 7; } int foo() {return 42;}'|$CXX -Werror -fvisibility=hidden -fvisibility-inlines-hidden -c -oconftest.o -xc++ - >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1106       AC_MSG_RESULT([yes])
1107       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
1108     else
1109       AC_MSG_RESULT([no])
1110     fi
1111   fi
1113 AC_SUBST(SWIG_CXXFLAGS)
1115 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1116 CXXFLAGS=$save_CXXFLAGS
1118 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1119 : ${AUTOM4TE=autom4te}
1120 AC_SUBST([AUTOM4TE])
1122 AC_CONFIG_FILES([Makefile
1123  doxygen_xml.conf
1124  xapian-version.h
1125  python3/Makefile python3/docs/conf.py python3/version.i
1126  php/Makefile
1127  java/Makefile
1128  tcl8/Makefile tcl8/pkgIndex.tcl
1129  csharp/Makefile csharp/AssemblyInfo.cs
1130  ruby/Makefile
1131  perl/Makefile
1132  lua/Makefile
1133  ])
1134 AC_OUTPUT
1136 echo ""
1137 if test -z "$BINDINGS" ; then
1138   echo "*** Not found the required tools for building bindings for any"
1139   echo "*** supported language!"
1140   echo "***"
1141   echo "*** You may need to install -dev or -devel packages for the languages"
1142   echo "*** you want to build bindings for."
1143   echo "***"
1144   echo "*** For details of how to point configure at tools not on PATH, see:"
1145   echo "***     ./configure --help"
1146 else
1147   echo "*** Building bindings for languages:" $BINDINGS
1149 echo ""
1150 if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
1151   release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
1152   case $XAPIAN_VERSION in
1153   $release_series*) ;;
1154   *)
1155     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.])
1156     ;;
1157   esac
1158   dnl 0.8.2 was the first version which set XAPIAN_VERSION
1159   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.])