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
268 dnl See comment for AC_PATH_PROGS(SWIG, ...).
269 if test -n "$PYTHON3" ; then
270 AC_PATH_PROGS(PYTHON3, ["$PYTHON3"], [])
272 AC_PATH_PROGS(PYTHON3, [python3 python], [])
274 AC_ARG_VAR(PYTHON3, [Python 3 interpreter])
275 if test -n "$PYTHON3" ; then
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`
283 [3.[3-9]*|3.[12][0-9]*|[4-9].*])
284 AC_MSG_RESULT([$version])
287 AC_MSG_RESULT([$version (too old, only 3.3 or newer is supported)])
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
299 AC_MSG_RESULT([no (try installing package python3-sphinx])
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
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,"/"))'`
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])
319 PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
321 PYTHON3_LIBS=`$PYTHON3 -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
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.
346 dnl Some Python versions (or maybe packages) need us to explicitly
347 dnl `import importlib.util` here, but others work without it.
349 dnl This needs a shell-level || because Python one line program support
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])
355 AC_MSG_RESULT([no (install python3-dev or python3-devel package or similar)])
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])
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
372 dnl Either Python 2 or 3 is OK so no need to check the version.
373 AC_PATH_PROGS(PYTHON, [python3 python], [])
375 test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
378 if test no != "$with_php" ; then
380 dnl See comment for AC_PATH_PROGS(SWIG, ...).
381 if test -n "$PHP_CONFIG" ; then
382 AC_PATH_PROGS(PHP_CONFIG, ["$PHP_CONFIG"], [])
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], [])
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
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)])
399 AC_MSG_RESULT([$version])
400 PHP_MAJOR_VERSION=`echo "$version"|cut -d. -f1`
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`
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`
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])
424 AC_MSG_RESULT([no ($PHP isn't PHP >= 8)])
428 AC_MSG_RESULT([no ($PHP does not work)])
432 AC_MSG_RESULT([not found])
435 AC_PATH_PROGS(PHP, ["$PHP"], [])
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'
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])
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
458 PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
460 PHP_LIBS="-lphp${PHP_MAJOR_VERSION}" ;;
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])
474 if test no != "$with_tcl" ; then
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.
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:
484 dnl ./configure tcl_min=8.4 TCL_INC=/usr/include/tcl8.4
486 dnl We definitely need at least Tcl 8.1 for TCL_STUBS.
488 AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
489 AC_ARG_VAR(TCLSH, [Tcl interpreter])
490 if test -n "$TCLSH" ; then
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`]
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`]
509 dnl Check that the headers are there (the tcl8.N-dev package
510 dnl may not be installed).
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"
521 AC_MSG_RESULT([$TCL_INC/tcl.h from Tcl $tcl_hdr_version, not $tcl_version - specify TCL_INC on configure command line])
525 AC_MSG_RESULT([not found])
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,
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"`
546 TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS"
547 [TCL_SHLIB_EXT=`echo 'puts [info sharedlibextension]'|$TCLSH 2> /dev/null`]
550 AC_SUBST(TCL_CPPFLAGS)
552 AC_SUBST(TCL_SHLIB_EXT)
554 AC_MSG_RESULT([< $tcl_min (too old)])
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])
565 if test no != "$with_csharp" ; then
567 AC_ARG_VAR(CSC, [CSharp compiler command])
568 if test -n "$CSC" ; then
569 AC_PATH_PROGS(CSC, ["$CSC"], [])
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
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
590 AC_MSG_RESULT([no (ignoring $CSC)])
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
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)])
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"], [])
618 if test -z "$GACUTIL" ; then
619 AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil], [])
622 AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
623 if test -n "$SN" ; then
624 AC_PATH_PROGS(SN, ["$SN"], [])
626 if test -z "$SN" ; then
627 AC_PATH_PROGS(SN, [cli-sn sn], [])
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
634 AC_MSG_CHECKING([whether CSharp programs can just be run])
635 if test OK = "`./conftest.exe 2> /dev/null`" ; then
640 AC_PATH_PROGS(CLI, ["${CLI-cli}"], [])
641 if test -z "$CLI" ; then
642 AC_PATH_PROGS(CLI, [mono ilrun], [])
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
651 AC_MSG_RESULT([no - CSharp tests will be skipped])
652 RUN_CSHARP='\$(top_srcdir)/skiptest'
655 AC_MSG_RESULT([not found - CSharp tests will be skipped])
656 RUN_CSHARP='\$(top_srcdir)/skiptest'
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
669 AC_MSG_RESULT([$GACUTIL_FLAGS])
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])
687 if test no != "$with_java" ; then
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
703 dnl The JNI library *requires* "Java 2", which is 1.2 or better.
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
709 AC_CHECK_HEADER([jni.h], [java_ok=yes], [
710 SAVE_CPPFLAGS=$CPPFLAGS
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
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.
723 ${JAVA_HOME+"$JAVA_HOME/include"} \
724 ${JDK_HOME+"$JDK_HOME/include"} \
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
733 JAVA_CPPFLAGS=-I$jnidir
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.
747 jni_host_os=solaris ;;
748 mingw* | pw32* | cygwin*)
751 jni_host_os=darwin ;;
753 dnl Correct for Dragonfly openjdk17 package; also in `freebsd/`.
754 jni_host_os=dragonfly ;;
756 dnl Correct for FreeBSD openjdk17 package.
757 jni_host_os=freebsd ;;
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"
772 AC_MSG_RESULT([found, but not usable])
774 CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
779 CPPFLAGS=$SAVE_CPPFLAGS
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.
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])
803 dnl AC_MSG_RESULT([no])
805 AC_SUBST([JAVA_CHECK_JNI_OPTION])
807 AC_MSG_RESULT([failed to run Java test program])
811 AC_MSG_RESULT([failed to compile Java test program])
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])
823 if test no != "$with_ruby" ; then
825 dnl See comment for AC_PATH_PROGS(SWIG, ...).
826 if test -n "$RUBY" ; then
827 AC_PATH_PROGS(RUBY, ["$RUBY"], [])
829 AC_PATH_PROGS(RUBY, [ruby], [])
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`
840 AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work]) ;;
842 AC_MSG_RESULT([$version (too old, only Ruby 2.1 or newer is supported)]) ;;
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"]'`]
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
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"]'`]
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"]'`]
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"]'`]
877 AC_SUBST(RUBY_LIB_ARCH)
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"]'`]
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
896 AC_PATH_PROGS(RDOC, [rdoc], [])
897 if test -z "$RDOC"; then
900 AC_ARG_VAR([RDOC], [Ruby documentation generator])
902 RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
905 AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
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])
917 if test no != "$with_perl" ; then
919 AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
920 AC_ARG_VAR(PERL, [Perl interpreter])
921 if test -n "$PERL" ; then
923 if test -z "$PERL_INC" ; then
924 PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
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}'`
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}'`
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}'`
946 if test -z "$PERL_XAPIAN_VERSION" ; then
947 dnl snapshot versions look like 1.2.3_git123
948 case $PACKAGE_VERSION in
950 PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
952 PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
955 AC_SUBST(PERL_XAPIAN_VERSION)
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])
964 if test no != "$with_lua" ; then
966 if test -n "$LUA" ; then
967 AC_PATH_PROGS(LUA, ["$LUA"], [])
969 if test -z "$LUA" ; then
970 AC_PATH_PROGS(LUA, [lua lua5.4 lua54 lua5.3 lua53 lua5.2 lua52 lua5.1 lua51], [])
972 AC_ARG_VAR(LUA, [lua interpreter])
973 if test -n "$LUA" ; then
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])
990 AC_MSG_RESULT([could not determine])
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 `.`.
1001 *) LUA_SO=.$LUA_SO ;;
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" : '.*;\(.*\)'`
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])
1015 AC_MSG_RESULT([$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])
1024 AC_MSG_RESULT([$LUA_SO])
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])
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])
1052 if test -z "$THREAD_LOCAL" ; then
1053 AC_MSG_RESULT([unknown, disabling thread-local support])
1055 AC_MSG_RESULT([$THREAD_LOCAL])
1056 AC_DEFINE_UNQUOTED([THREAD_LOCAL], [$THREAD_LOCAL], [Thread local storage qualifier (undefined if no TLS)])
1061 dnl Set flags to control warnings (enable more, or disable annoying ones)
1062 dnl and other compiler specific flags.
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.
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.
1079 [#ifdef __INTEL_COMPILER
1084 dnl Intel's compiler:
1086 dnl -w1 stops the avalanche of uninteresting "remark" messages.
1087 dnl -wd... disables warnings which don't have good code workarounds.
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"
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"
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"
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
1125 python3/Makefile python3/docs/conf.py python3/version.i
1128 tcl8/Makefile tcl8/pkgIndex.tcl
1129 csharp/Makefile csharp/AssemblyInfo.cs
1137 if test -z "$BINDINGS" ; then
1138 echo "*** Not found the required tools for building bindings for any"
1139 echo "*** supported language!"
1141 echo "*** You may need to install -dev or -devel packages for the languages"
1142 echo "*** you want to build bindings for."
1144 echo "*** For details of how to point configure at tools not on PATH, see:"
1145 echo "*** ./configure --help"
1147 echo "*** Building bindings for languages:" $BINDINGS
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*) ;;
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.])
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.])