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
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
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])
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.
24 LT_INIT([disable-static])
26 dnl Make the name of libtool's `.libs`/`_libs` available in makefiles.
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).
35 if test unsupported = "$allow_undefined_flag" ; then
36 NO_UNDEFINED=-no-undefined
38 AC_SUBST(NO_UNDEFINED)
40 dnl Checks for programs.
43 # Checked: dragonfly6.4 freebsd8.0 netbsd9.3 openbsd4.6 solaris2.9 solaris2.10
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
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
60 dnl Run tests using the C++ compiler.
63 dnl Probe for any options needed to enable C++17 support.
64 AX_CXX_COMPILE_STDCXX([17])
66 dnl Check for xapian-core.
68 [xapian-config]regexp(project_version,
69 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
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
84 dnl $XAPIAN_LIBS may have some options first, so grab the last argument,
85 dnl which should be the .la file.
90 dnl Make sure the path is absolute.
91 case $INTREE_DYLD_PATH in
93 *) INTREE_DYLD_PATH=`pwd`/$INTREE_DYLD_PATH ;;
95 dnl Add .libs or equivalent.
96 INTREE_DYLD_PATH=`echo "$INTREE_DYLD_PATH"|sed 's,\(.*/\).*,\1,'`$_libs
97 AC_SUBST([INTREE_DYLD_PATH])
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}'
124 AC_ARG_ENABLE(visibility,
125 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
126 [case ${enableval} in
128 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
131 dnl Only probe for SWIG and enable SWIG rules in makefiles if
132 dnl configure --enable-maintainer-mode is used.
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
139 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
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])
164 dnl Check for new enough SWIG.
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'`
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.
178 SWIG_FLAGS=`$XAPIAN_CONFIG --swigflags`
182 for a in $SWIG_FLAGS ; do
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"
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
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
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])
211 AS_HELP_STRING([--with-python3], [enable Python 3 bindings]),
216 AS_HELP_STRING([--with-php], [enable PHP bindings]),
221 AS_HELP_STRING([--with-ruby], [enable Ruby bindings]),
226 AS_HELP_STRING([--with-tcl], [enable Tcl bindings]),
231 AS_HELP_STRING([--with-csharp], [enable CSharp bindings]),
236 AS_HELP_STRING([--with-java], [enable Java bindings]),
241 AS_HELP_STRING([--with-perl], [enable Perl bindings]),
246 AS_HELP_STRING([--with-lua], [enable Lua bindings]),
250 case $with_python3$with_php$with_ruby$with_tcl$with_csharp$with_java$with_perl$with_lua in
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
266 if test no != "$with_python3" ; then
267 dnl See comment for AC_PATH_PROGS(SWIG, ...).
268 if test -n "$PYTHON3" ; then
269 AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
271 AC_PATH_PROGS(PYTHON3, [python3 python], [])
273 AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
274 if test -n "$PYTHON3" ; then
275 dnl Require Python 3.3 or newer, as that's the oldest version we can
276 dnl easily test with. If anyone's keen to support older versions, please
277 dnl test and send in any patches needed to get it to work.
278 AC_MSG_CHECKING([$PYTHON3 version])
279 version=`$PYTHON3 -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
281 [3.[3-9]*|3.[12][0-9]*|[4-9].*])
282 AC_MSG_RESULT([$version])
285 AC_MSG_RESULT([$version (too old)])
286 if test yes = "$with_python3" ; then
287 AC_MSG_ERROR([Only Python 3.3 or newer is supported ($python3 is $version)])
292 if test -n "$PYTHON3" ; then
293 PYTHON3_INC=`$PYTHON3 -c 'import os,sysconfig;print(sysconfig.get_path("include").replace(os.sep,"/"))' 2>/dev/null`
294 AC_SUBST(PYTHON3_INC)
296 AC_MSG_CHECKING([for python3 sphinx module])
297 if $PYTHON3 -c 'import sphinx' >&5 2>&5 ; then
301 if test yes = "$with_python3" ; then
302 AC_MSG_ERROR([Couldn't import sphinx module for Python3 - try package python3-sphinx])
306 if test -n "$PYTHON3" ; then
307 dnl Check that Python.h is there, which is a good way to check that
308 dnl the appropriate python3-dev package has been installed.
309 AC_MSG_CHECKING([for $PYTHON3_INC/Python.h])
310 if test -f "$PYTHON3_INC/Python.h" ; then
312 AC_MSG_CHECKING([for directory to install python3 bindings in])
313 if test -z "$PYTHON3_LIB" ; then
314 PYTHON3_LIB=`$PYTHON3 -c 'import os,sysconfig;print(sysconfig.get_path("platlib").replace(os.sep,"/"))'`
316 AC_MSG_RESULT([$PYTHON3_LIB])
317 AC_ARG_VAR(PYTHON3_LIB, [Directory to install python3 bindings in])
319 AC_MSG_CHECKING([for python3 libraries to link against])
322 PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
324 PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
328 AC_SUBST(PYTHON3_LIBS)
329 AC_MSG_RESULT([$PYTHON3_LIBS])
331 AC_MSG_CHECKING([for python3 module extension])
332 dnl Encodes the Python version the module is built for, and ends with
333 dnl the platform-dependent shared object extension (which is `.so` on
334 dnl most Unix-like platforms) - e.g. `.cpython-310-x86_64-linux-gnu.so`
335 PYTHON3_EXT_SUFFIX=`$PYTHON3 -c 'import sysconfig;print(sysconfig.get_config_var("EXT_SUFFIX"))'`
336 AC_SUBST(PYTHON3_EXT_SUFFIX)
337 AC_MSG_RESULT([$PYTHON3_EXT_SUFFIX])
339 AC_MSG_CHECKING([for tag for cached compiled scripts])
340 PYTHON3_CACHE_TAG=`$PYTHON3 -c 'import sys;print(sys.implementation.cache_tag)'`
341 AC_SUBST(PYTHON3_CACHE_TAG)
342 AC_MSG_RESULT([$PYTHON3_CACHE_TAG])
344 AC_MSG_CHECKING([for extension of cached and optimized python3 bytecode])
345 dnl We use -O instead of cache_from_source()'s optimization parameter
346 dnl as the latter was only added in Python 3.5. The fallback is needed
347 dnl as cache_from_source() itself is new in Python 3.4.
349 dnl Some Python versions (or maybe packages) need us to explicitly
350 dnl `import importlib.util` here, but others work without it.
352 dnl This needs a shell-level || because Python one line program support
354 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")'`
355 AC_SUBST(PYTHON3_CACHE_OPT1_EXT)
356 AC_MSG_RESULT([$PYTHON3_CACHE_OPT1_EXT])
358 BINDINGS="$BINDINGS python3"
360 AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
361 if test yes = "$with_python3" ; then
362 AC_MSG_ERROR([Python.h not found])
369 if test x$USE_MAINTAINER_MODE = xyes; then
370 dnl Need python in maintainer mode to run doxy2swig.py.
371 if test -n "$PYTHON3" ; then
374 dnl Either Python 2 or 3 is OK so no need to check the version.
375 AC_PATH_PROGS(PYTHON, [python3 python], [])
377 test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
380 if test no != "$with_php" ; then
381 dnl See comment for AC_PATH_PROGS(SWIG, ...).
382 if test -n "$PHP_CONFIG" ; then
383 AC_PATH_PROGS(PHP_CONFIG, ["$PHP_CONFIG"], [])
385 if test -z "$PHP_CONFIG" ; then
386 AC_PATH_PROGS(PHP_CONFIG, [php-config8.2 php-config8.1 php-config8.0 php-config], [])
388 AC_ARG_VAR(PHP_CONFIG, [php-config utility for PHP])
389 AC_ARG_VAR(PHP, [PHP interpreter (optional - only needed to run PHP testsuite with)])
390 if test -n "$PHP_CONFIG" ; then
391 AC_MSG_CHECKING([$PHP_CONFIG version])
392 version=`$PHP_CONFIG --version 2>/dev/null`
395 AC_MSG_RESULT([$version (not supported, PHP bindings need PHP >= 8)])
396 if test yes = "$with_php" ; then
397 AC_MSG_ERROR([$PHP_CONFIG reports version $version - PHP bindings PHP >= 8])
402 AC_MSG_RESULT([$version])
403 PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
406 AC_SUBST(PHP_MAJOR_VERSION)
408 if test no != "$with_php" ; then
409 AC_MSG_CHECKING([for PHP extension directory])
410 if test -z "$PHP_EXTENSION_DIR" ; then
411 PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
413 AC_MSG_RESULT([$PHP_EXTENSION_DIR])
414 AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP extensions in])
417 if test no != "$with_php" ; then
418 PHP_INC=`$PHP_CONFIG --includes`
422 if test no != "$with_php" ; then
423 if test x"$PHP" = x ; then
424 AC_MSG_CHECKING([for PHP interpreter])
425 PHP=`$PHP_CONFIG --php-binary 2>/dev/null`
426 if test x"$PHP" != x ; then
427 if $PHP -r 'exit(0);' 2> /dev/null ; then
428 if $PHP -r 'exit(PHP_MAJOR_VERSION>=8?0:1);' 2> /dev/null ; then
429 AC_MSG_RESULT([$PHP])
431 AC_MSG_RESULT([no ($PHP isn't PHP >= 8)])
435 AC_MSG_RESULT([no ($PHP does not work)])
439 AC_MSG_RESULT([not found])
442 AC_PATH_PROGS(PHP, ["$PHP"], [])
444 if test x"$PHP" = x ; then
445 AC_MSG_WARN([No PHP interpreter found - PHP bindings tests will be skipped])
446 dnl The skiptest script just returns exit code 77.
447 PHP='$(top_srcdir)/skiptest'
449 AC_MSG_CHECKING([for PHP path separator])
450 PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
451 AC_SUBST([PHP_PATH_SEPARATOR])
452 AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
454 AC_MSG_CHECKING([for PHP shared library suffix])
455 PHP_SHLIB_SUFFIX=`$PHP -r 'echo PHP_SHLIB_SUFFIX;'`
456 AC_SUBST([PHP_SHLIB_SUFFIX])
457 AC_MSG_RESULT([$PHP_SHLIB_SUFFIX])
462 dnl This is a bit of an informed guess, pending more information from
463 dnl someone who actually has mingw and wants to build the PHP bindings
465 PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
467 PHP_LIBS="-lphp${PHP_MAJOR_VERSION}" ;;
472 BINDINGS="$BINDINGS php"
477 if test no != "$with_tcl" ; then
478 dnl The documented minimum requirement is Tcl 8.5. Older versions may work,
479 dnl but we don't test with them regularly, and they are no longer supported
480 dnl upstream. Also ::tcl::pkgconfig was added in Tcl 8.5, which makes the
481 dnl tests below simpler and more reliable.
483 dnl If you really want to build with an older version, run configure with
484 dnl a lower tcl_min and specify at least TCL_INC explicitly:
486 dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
488 dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
490 AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
491 AC_ARG_VAR(TCLSH, [Tcl interpreter])
492 if test -n "$TCLSH" ; then
493 AC_MSG_CHECKING([$TCLSH version])
494 if echo 'if {$tcl_version < '"$tcl_min"' } { exit 1 }'|$TCLSH 2> /dev/null ; then
495 tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
496 AC_MSG_RESULT([$tcl_version])
498 AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
499 if test -z "$TCL_LIB" ; then
500 [TCL_LIB=`echo 'if {[info exists tcl_pkgPath]} {foreach d $tcl_pkgPath {if {![regexp {/share(/|$)} $d]} {break}};puts $d}else{foreach d $auto_path {if {![regexp {/share(/|$)} $d]} {break}};puts $d}'|$TCLSH`]
504 AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
505 if test -z "$TCL_INC" ; then
506 dnl ::tcl::pkgconfig was added in Tcl 8.5.
507 [TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
510 dnl Check that the headers are there (the tcl8.N-dev package
511 dnl may not be installed).
513 AC_MSG_CHECKING([for tcl.h from Tcl $tcl_version])
514 if test x"$TCL_INC" != x && test -f "$TCL_INC/tcl.h" ; then
515 tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
516 if test x"$tcl_hdr_version" = x"$tcl_version" ; then
517 AC_MSG_RESULT([$TCL_INC/tcl.h])
518 BINDINGS="$BINDINGS tcl8"
519 if test x"$TCL_INC" != x"/usr/include" ; then
520 TCL_CPPFLAGS="-I$TCL_INC"
523 AC_MSG_RESULT([not found])
524 if test yes = "$with_tcl" ; then
525 AC_MSG_ERROR([Found tcl.h from version $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
530 AC_MSG_RESULT([not found])
531 if test yes = "$with_tcl" ; then
532 AC_MSG_ERROR([Can't find tcl.h])
539 if test -n "$TCLSH" ; then
540 dnl ::tcl::pkgconfig was added in Tcl 8.5. Prior to 8.6 it's only
541 dnl actually necessary to link against -ltclstub on platforms which
542 dnl don't allow libraries to have unresolved symbols (cygwin, mingw,
544 [tcl_libdir_runtime=`echo 'puts [::tcl::pkgconfig get libdir,runtime]'|$TCLSH 2> /dev/null`]
545 if test -n "$tcl_libdir_runtime" ; then
546 for x in "/tcl$tcl_version" "" ; do
547 TCLCONFIG_SH=$tcl_libdir_runtime$x/tclConfig.sh
548 if test -r "$TCLCONFIG_SH" ; then
549 TCL_LIBS=`. $TCLCONFIG_SH && printf '%s' "$TCL_STUB_LIB_SPEC"`
554 TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS"
555 [TCL_SHLIB_EXT=`echo 'puts [info sharedlibextension]'|$TCLSH 2> /dev/null`]
558 AC_SUBST(TCL_CPPFLAGS)
560 AC_SUBST(TCL_SHLIB_EXT)
562 AC_MSG_RESULT([< $tcl_min (too old)])
563 if test yes = "$with_tcl" ; then
564 AC_MSG_ERROR([$TCLSH too old (Tcl $tcl_min or newer required)])
568 if test yes = "$with_tcl" ; then
569 AC_MSG_ERROR([tclsh not found])
574 if test no != "$with_csharp" ; then
576 AC_ARG_VAR(CSC, [CSharp compiler command])
577 if test -n "$CSC" ; then
578 AC_PATH_PROGS(CSC, ["$CSC"], [])
580 if test -z "$CSC" ; then
581 dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
582 dnl as "alternatives" which can be mapped to the CSharp compiler the admin
584 AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
585 if test -z "$CSC" ; then
586 dnl mcs is the Mono CSharp compiler, which is a unified compiler
587 dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
588 dnl that's no longer relevant).
589 AC_PATH_PROGS(CSC, [mcs], [])
590 if test -n "$CSC" ; then
591 dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
592 dnl so we check that the mcs we found understands --version which is
593 dnl sufficient to distinguish mono's mcs from the Tru64 one.
594 AC_MSG_CHECKING([whether $CSC is from GNU Mono])
595 if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
600 csc_note="$csc_note (found different mcs program)"
604 if test -z "$CSC" ; then
605 dnl csc is the Microsoft CSharp compiler.
606 AC_PATH_PROGS(CSC, [csc], [])
607 if test -n "$CSC" ; then
608 dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
609 dnl check if the output from "csc -version" includes the word chicken
610 dnl which is sufficient to distinguish Chicken's csc from Microsoft's
612 AC_MSG_CHECKING([whether $CSC is for CSharp])
613 if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
616 csc_note="$csc_note (found Chicken csc program)"
624 if test -n "$CSC" ; then
625 AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
626 if test -n "$GACUTIL" ; then
627 AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
629 if test -z "$GACUTIL" ; then
630 AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil], [])
633 AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
634 if test -n "$SN" ; then
635 AC_PATH_PROGS(SN, ["$SN"], [])
637 if test -z "$SN" ; then
638 AC_PATH_PROGS(SN, [cli-sn sn], [])
640 if test -n "$GACUTIL" -a -n "$SN" ; then
641 AC_MSG_CHECKING([whether the CSharp compiler works])
642 [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
643 if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
645 AC_MSG_CHECKING([whether CSharp programs can just be run])
646 if test OK = "`./conftest.exe 2> /dev/null`" ; then
651 AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
652 if test -z "$CLI" ; then
653 AC_PATH_PROGS(CLI, [mono ilrun], [])
655 AC_ARG_VAR(CLI, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
656 if test -n "$CLI" ; then
657 AC_MSG_CHECKING([whether $CLI can run CSharp programs])
658 if test OK = "`$CLI ./conftest.exe 2> /dev/null`" ; then
662 AC_MSG_RESULT([no - CSharp tests will be skipped])
663 RUN_CSHARP='\$(top_srcdir)/skiptest'
666 AC_MSG_RESULT([not found - CSharp tests will be skipped])
667 RUN_CSHARP='\$(top_srcdir)/skiptest'
672 AC_MSG_CHECKING([for extra flags for $GACUTIL])
673 GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
674 dnl Microsoft's gacutil accepts fewer options than Mono's
675 $GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
676 AC_SUBST([GACUTIL_FLAGS])
677 if test -z "$GACUTIL_FLAGS" ; then
680 AC_MSG_RESULT([$GACUTIL_FLAGS])
683 BINDINGS="$BINDINGS csharp"
686 if test yes = "$with_csharp" ; then
687 AC_MSG_ERROR([CSharp compiler $CSC doesn't work])
691 if test yes = "$with_csharp" ; then
692 if test -z "$GACUTIL" ; then
693 AC_MSG_ERROR([Mono gacutil not found])
694 elif test -z "$SN" ; then
695 AC_MSG_ERROR([Mono sn not found])
700 if test yes = "$with_csharp" ; then
701 AC_MSG_ERROR([CSharp compiler not found$csc_note])
707 if test no != "$with_java" ; then
708 AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
709 [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
710 AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
711 [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
712 AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
713 [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
714 AC_ARG_VAR(JAVA, [Java interpreter command])
715 AC_ARG_VAR(JAVAC, [Java compiler command])
716 AC_ARG_VAR(JAR, [java jar utility])
717 AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
718 AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
719 AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
720 if test -n "$JAVA" -a -n "$JAVAC" -a -n "$JAR" ; then
722 dnl The JNI library *requires* "Java 2", which is 1.2 or better.
724 dnl So checking for jni.h presumably implicitly checks we have "Java 2".
725 dnl Note: jni.h #defines JNI_VERSION_1_[12468] (but not 3, 5 or 7 it seems).
726 dnl So we could check for one of these if we want to check for a particular
729 AC_CHECK_HEADER([jni.h], [java_ok=yes], [
730 SAVE_CPPFLAGS=$CPPFLAGS
732 dnl Avoid endlessly traversing if there's a symlink loop.
733 for count in 1 2 3 4 5 6 7 8 9 ; do
734 r=`readlink "$real_javac"`
735 test -n "$r" || break
738 dnl Translate ".../bin/javac" to ".../include".
739 [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
740 dnl Try the location for macOS system Java too, but last.
743 ${JAVA_HOME+"$JAVA_HOME/include"} \
744 ${JDK_HOME+"$JDK_HOME/include"} \
746 /System/Library/Frameworks/JavaVM.framework/Headers ; do
747 CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
748 AC_MSG_CHECKING([for jni.h in $jnidir])
749 if test -f "$jnidir/jni.h" ; then
750 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
751 if test yes = $java_ok ; then
753 JAVA_CPPFLAGS=-I$jnidir
757 dnl For OpenJDK (and maybe others) we have to specify an extra -I
758 dnl option for an OS-specific subdirectory containing a "jni_md.h"
759 dnl header which is included by "jni.h". Sadly we seem to need to
760 dnl hardcode a mapping for these platform names - the list below
761 dnl was determined by inspecting the source code of OpenJDK 8.
767 jni_host_os=solaris ;;
768 mingw* | pw32* | cygwin*)
771 jni_host_os=darwin ;;
777 if test -n "$jni_host_os" ; then
778 CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
779 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
780 if test yes = $java_ok ; then
781 AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
782 JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
786 AC_MSG_RESULT([found, but not usable])
788 CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
793 CPPFLAGS=$SAVE_CPPFLAGS
794 test noyes = $java_ok$with_java && AC_MSG_ERROR([jni.h not found])
796 AC_SUBST(JAVA_CPPFLAGS)
797 if test yes = $java_ok ; then
798 AC_MSG_CHECKING([for Java path separator])
799 [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
800 if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
801 JAVA_PATHSEP=`$JAVA conftest 2>&5`
802 AC_SUBST(JAVA_PATHSEP)
803 if test -n "$JAVA_PATHSEP" ; then
804 AC_MSG_RESULT($JAVA_PATHSEP)
805 BINDINGS="$BINDINGS java"
807 dnl If -Xcheck:jni is supported then run tests with it.
809 dnl ... except that with OpenJDK 8 and 9 -Xcheck:jni seems to report
810 dnl false positives and so can't usefully be turned on in this
811 dnl situation. Recheck this with future versions.
812 dnl AC_MSG_CHECKING([for $JAVA -Xcheck:jni option])
813 dnl JAVA_PATHSEP2=`$JAVA conftest 2>&5`
814 JAVA_CHECK_JNI_OPTION=
815 dnl if test "$JAVA_PATHSEP" = "$JAVA_PATHSEP2" ; then
816 dnl JAVA_CHECK_JNI_OPTION=-Xcheck:jni
817 dnl AC_MSG_RESULT([yes])
819 dnl AC_MSG_RESULT([no])
821 AC_SUBST([JAVA_CHECK_JNI_OPTION])
823 AC_MSG_RESULT([failed to run test program])
827 AC_MSG_RESULT([failed to compile test program])
830 if test no = "$java_ok" ; then
831 test yes = "$with_java" && AC_MSG_ERROR([Couldn't compile and run a simple Java test program])
835 if test yes = "$with_java" ; then
836 if test -z "$JAVA" ; then
837 AC_MSG_ERROR([java not found])
838 elif test -z "$JAVAC" ; then
839 AC_MSG_ERROR([javac not found])
840 elif test -z "$JAR" ; then
841 AC_MSG_ERROR([jar not found])
847 if test no != "$with_ruby" ; then
848 dnl See comment for AC_PATH_PROGS(SWIG, ...).
849 if test -n "$RUBY" ; then
850 AC_PATH_PROGS(RUBY, ["$RUBY"], [])
852 AC_PATH_PROGS(RUBY, [ruby], [])
854 AC_ARG_VAR(RUBY, [Ruby interpreter])
855 if test -n "$RUBY" ; then
856 dnl Require Ruby 2.1 or newer.
857 AC_MSG_CHECKING([$RUBY version])
858 dnl RUBY_VERSION works with 1.6. Once we've checked we have at least 1.8
859 dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8).
860 version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
863 AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work])
864 if test yes = "$with_ruby" ; then
865 AC_MSG_ERROR([Working Ruby interpreter not found])
870 AC_MSG_RESULT([$version (too old)])
871 if test yes = "$with_ruby" ; then
872 AC_MSG_ERROR([Only Ruby 2.1 or newer is supported ($RUBY is $version)])
877 if test -n "$RUBY" ; then
878 AC_MSG_RESULT([$version])
879 AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
880 if test -z "$RUBY_INC" ; then
881 dnl Ruby 1.9 added rubyhdrdir.
882 [RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"]'`]
885 dnl Check that ruby.h is there, which is a good way to check that
886 dnl the appropriate ruby-dev package has been installed.
887 AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
888 if test -f "$RUBY_INC/ruby.h" ; then
891 AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found])
892 if test -z "$RUBY_INC_ARCH" ; then
893 dnl Ruby 2.0 and later have rubyarchhdrdir.
894 [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyarchhdrdir"]'`]
896 AC_SUBST(RUBY_INC_ARCH)
898 AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
899 if test -z "$RUBY_LIB" ; then
900 [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
904 AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
905 if test -z "$RUBY_LIB_ARCH" ; then
906 [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
908 AC_SUBST(RUBY_LIB_ARCH)
911 if test unsupported = "$allow_undefined_flag" ; then
912 dnl For Microsoft Windows and a few other platforms.
913 [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
917 dnl rdoc is included as part of the Ruby core distribution, so run it
918 dnl at build time rather shipping the rather large generated output in
919 dnl our source tarball.
920 if test -z "$RDOC" ; then
921 dnl Try replace the *last* 'ruby' with 'rdoc'.
922 rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
923 if test -x "$rdoc_best_guess" ; then
924 RDOC=$rdoc_best_guess
927 AC_PATH_PROGS(RDOC, [rdoc], [])
928 if test -n "$RDOC"; then
929 BINDINGS="$BINDINGS ruby"
931 AC_ARG_VAR([RDOC], [Ruby documentation generator])
933 AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
934 if test yes = "$with_ruby" ; then
935 AC_MSG_ERROR([ruby.h not found])
938 RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
944 if test no != "$with_perl" ; then
945 AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
946 AC_ARG_VAR(PERL, [Perl interpreter])
947 if test -n "$PERL" ; then
948 if test -z "$PERL_INC" ; then
949 PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
953 AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
954 if test -z "$PERL_ARCH" ; then
955 PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
959 AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
960 if test -z "$PERL_LIB" ; then
961 PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
965 AC_ARG_VAR(PERL_SO, [Extension for compiled Perl modules])
966 if test -z "$PERL_SO" ; then
967 PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
971 if test -z "$PERL_XAPIAN_VERSION" ; then
972 dnl snapshot versions look like 1.2.3_git123
973 case $PACKAGE_VERSION in
975 PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
977 PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
980 AC_SUBST(PERL_XAPIAN_VERSION)
982 BINDINGS="$BINDINGS perl"
984 if test yes = "$with_perl" ; then
985 AC_MSG_ERROR([perl not found])
990 if test no != "$with_lua" ; then
991 AC_PATH_PROGS(LUA, ["${LUA-lua}"], [])
992 AC_ARG_VAR(LUA, [lua interpreter])
993 if test -n "$LUA" ; then
994 dnl We need Lua 5.1 or later.
995 PKG_CHECK_MODULES([LUA], [lua$lua_version >= 5.1], [], [LUA=])
997 if test -n "$LUA" ; then
998 AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
999 AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
1000 AC_MSG_CHECKING([for directory to install compiled Lua modules into])
1001 if test -z "$LUA_LIB" -o -z "$LUA_SO" ; then
1002 lua_cpath=`$LUA -e 'require("package") print(package.cpath)'`
1003 dnl Look for the first absolute path in lua_cpath which has leaf
1004 dnl "?.<ext>" and put the directory part into lua_lib and <ext> into
1005 dnl lua_so. If LUA_SO was specified by the user, only consider
1006 dnl entries where <ext> matches LUA_SO.
1011 [lua_so_pat='[a-zA-Z][a-zA-Z]*'] ;;
1013 dnl If LUA_SO has a leading '.', remove it.
1014 lua_so_pat=`AS_ECHO("$LUA_SO")|sed 's/^\.//'` ;;
1016 dnl If LUA_SO was specified without a leading '.', add one to the
1017 dnl value substituted into Makefile.in.
1022 while test x"$lua_cpath" != x ; do
1023 [lua_lib=`expr X"$lua_cpath" : X'\([^;]*\)'`]
1024 lua_so=.`expr X"$lua_lib" : X'/.*/?\.\('"$lua_so_pat"'\)$'`
1027 dnl If someone has foolishly put ?.lua in cpath, ignore them.
1031 lua_lib=`expr X"$lua_lib" : X'\(/.*\)/?\.'"$lua_so_pat"'$'`
1034 [lua_cpath=`expr X"$lua_cpath" : X'[^;]*;*\(.*\)'`]
1036 test -n "$LUA_LIB" || LUA_LIB=$lua_lib
1037 test -n "$LUA_SO" || LUA_SO=$lua_so
1039 if test -z "$LUA_LIB"; then
1040 AC_MSG_RESULT([not found])
1043 AC_MSG_RESULT([$LUA_LIB])
1047 AC_MSG_CHECKING([for extension to use for compiled Lua modules])
1048 if test -z "$LUA_SO"; then
1049 AC_MSG_RESULT([not found])
1052 AC_MSG_RESULT([$LUA_SO])
1058 if test -n "$LUA" ; then
1059 BINDINGS="$BINDINGS lua"
1060 elif test yes = "$with_lua" ; then
1061 AC_MSG_ERROR([lua not found])
1069 dnl C++11 has thread_local
1070 dnl GCC and some others have __thread
1071 dnl MSVC and some others have __declspec(thread)
1072 AC_MSG_CHECKING([for thread-local storage qualifier])
1073 AC_ARG_VAR([THREAD_LOCAL], [thread-local storage qualifier])
1074 if test -z "$THREAD_LOCAL" ; then
1075 for t in thread_local __thread '__declspec(thread)' ; do
1076 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[static $t void * p;]])],
1077 [THREAD_LOCAL=$t; break])
1080 if test -z "$THREAD_LOCAL" ; then
1081 AC_MSG_RESULT([unknown, disabling thread-local support])
1083 AC_MSG_RESULT([$THREAD_LOCAL])
1084 AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
1089 dnl Set flags to control warnings (enable more, or disable annoying ones)
1090 dnl and other compiler specific flags.
1092 if test yes = "$GXX" ; then
1093 dnl Python itself is compiled with -fno-strict-aliasing, and it appears
1094 dnl it's safest to follow this lead when compiling the SWIG generated
1095 dnl interface code. E.g.:
1096 dnl https://article.gmane.org/gmane.comp.gcc.devel/74692
1097 dnl The code SWIG generates for other languages seems to have similar
1098 dnl issues too, so just turn this on for all of them.
1100 dnl There's no need to check -fno-strict-aliasing is supported as it works
1101 dnl with GCC 2.95 and we don't support anything older.
1102 SWIG_CXXFLAGS="-fno-strict-aliasing"
1104 dnl We need to explicitly link against -lstdc++ on OpenBSD (discovered
1105 dnl on OpenBSD 3.7 with GCC 3.3.5 but this appears to be due to a
1106 dnl deliberate decision on the part of OpenBSD developers). Luckily
1107 dnl we can just always specify -lstdc++ explicitly if GCC is the
1108 dnl compiler and libtool will eliminate the duplicate on other
1110 XAPIAN_LIBS="$XAPIAN_LIBS -lstdc++"
1112 dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
1113 dnl which we actually have.
1115 [#ifdef __INTEL_COMPILER
1120 dnl Intel's compiler:
1122 dnl -w1 stops the avalanche of uninteresting "remark" messages.
1123 dnl -wd... disables warnings which don't have good code workarounds.
1125 dnl Swig generated code gives lots of unused and uninitialized warnings.
1126 dnl They're non-harmful, so suppress them.
1127 SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
1132 dnl Swig generated code gives lots of unused and uninitialized warnings.
1133 dnl They're non-harmful, so suppress them.
1134 SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -Wno-unused -Wno-uninitialized"
1137 if test no != "$enable_visibility"; then
1138 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1139 dnl supported on mingw and visibility attributes result in warnings).
1140 AC_MSG_CHECKING([if $CXX -fvisibility=hidden -fvisibility-inlines-hidden works])
1141 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
1142 AC_MSG_RESULT([yes])
1143 SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
1149 AC_SUBST(SWIG_CXXFLAGS)
1151 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1152 CXXFLAGS=$save_CXXFLAGS
1154 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1155 : ${AUTOM4TE=autom4te}
1156 AC_SUBST([AUTOM4TE])
1158 AC_CONFIG_FILES([Makefile
1161 python3/Makefile python3/docs/conf.py python3/version.i
1164 tcl8/Makefile tcl8/pkgIndex.tcl
1165 csharp/Makefile csharp/AssemblyInfo.cs
1173 if test -z "$BINDINGS" ; then
1174 echo "*** Not found the required tools for building bindings for any"
1175 echo "*** supported language!"
1177 echo "*** You may need to install -dev or -devel packages for the languages"
1178 echo "*** you want to build bindings for."
1180 echo "*** For details of how to point configure at tools not on PATH, see:"
1181 echo "*** ./configure --help"
1183 echo "*** Building bindings for languages:" $BINDINGS
1186 if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
1187 release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
1188 case $XAPIAN_VERSION in
1189 $release_series*) ;;
1191 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.])
1194 dnl 0.8.2 was the first version which set XAPIAN_VERSION
1195 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.])