Update for 1.2.24
[xapian.git] / xapian-bindings / configure.ac
blob955a9c31d207ef3061b49aa16b9cb6e46b06a2cc
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 AC_INIT([xapian-bindings], [1.2.24], [https://xapian.org/bugs])
9 dnl See xapian-core's HACKING document for details of the reasons for required
10 dnl versions.
11 AM_INIT_AUTOMAKE([1.11.2 -Wportability tar-ustar no-dist-gzip dist-xz])
12 AC_CONFIG_SRCDIR([xapian.i])
14 AC_CONFIG_HEADERS([config.h])
16 AC_CONFIG_MACRO_DIR([m4])
18 dnl Mac OS X needs MACOSX_DEPLOYMENT_TARGET set to 10.3 (or higher) to
19 dnl successfully link the SWIG generated modules.  The link always fails
20 dnl on earlier versions of Mac OS X (10.1.4 and 10.2.8 tested), so always
21 dnl setting MACOSX_DEPLOYMENT_TARGET to at least 10.3 seems to be the
22 dnl appropriate thing to do.  Most Mac OS X developers will have upgraded
23 dnl from 10.1 and 10.2 by now anyhow.
24 dnl
25 dnl NB we must do this *BEFORE* LT_INIT since that is what checks
26 dnl MACOSX_DEPLOYMENT_TARGET.
27 AC_CANONICAL_HOST
28 OVERRIDE_MACOSX_DEPLOYMENT_TARGET=
29 case $host in
30 *86*-darwin8*|*-darwin[[91]]*)
31   dnl On 10.5 or later, and 10.4 on x86, the deployment target defaults to the
32   dnl OS version, so we don't need to override on these.
33   ;;
34 *-darwin*)
35   case $MACOSX_DEPLOYMENT_TARGET in
36   "")
37     OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
38   10.[[012]])
39     AC_MSG_WARN([Overriding MACOSX_DEPLOYMENT_TARGET from $MACOSX_DEPLOYMENT_TARGET to 10.3])
40     OVERRIDE_MACOSX_DEPLOYMENT_TARGET=10.3 ;;
41   esac
42   ;;
43 esac
44 AM_CONDITIONAL(OVERRIDE_MACOSX_DEPLOYMENT_TARGET, test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET")
45 AC_SUBST(OVERRIDE_MACOSX_DEPLOYMENT_TARGET)
46 if test -n "$OVERRIDE_MACOSX_DEPLOYMENT_TARGET" ; then
47   MACOSX_DEPLOYMENT_TARGET=$OVERRIDE_MACOSX_DEPLOYMENT_TARGET
50 dnl Use libtool to manage our libraries, but don't build static libraries as
51 dnl the bindings only have a use for dynamic ones.
52 LT_PREREQ([2.2.6])
53 LT_INIT([disable-static])
55 dnl -no-undefined causes problems on Mac OS X with at least some
56 dnl MACOSX_DEPLOYMENT_TARGET settings, so only pass -no-undefined on
57 dnl platforms where it is required in order to link a shared library at
58 dnl all (Windows is the main one).
59 NO_UNDEFINED=
60 if test unsupported = "$allow_undefined_flag" ; then
61   NO_UNDEFINED=-no-undefined
63 AC_SUBST(NO_UNDEFINED)
65 dnl Checks for programs.
66 AC_PROG_CXX
68 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
69 case $host_os in
70   linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
71     dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
72     link_all_deplibs_CXX=no
73     ;;
74 esac
76 case $host_os in
77   linux*)
78     dnl Extract search path from ldconfig which is more reliable than the way
79     dnl vanilla libtool extracts them from ld.so.conf.
80     d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
81     test -z "$d" || sys_lib_dlsearch_path_spec=$d
82     ;;
83 esac
85 dnl Run tests using the C++ compiler.
86 AC_LANG_CPLUSPLUS
88 dnl Check for xapian-core.
89 XO_LIB_XAPIAN([], [], [xapian-config])
91 NEED_JNILIB_EXT=no
92 NEED_INTREE_DYLD=no
93 INTREE_DYLD_PATH=
94 case $host_os in
95 darwin*)
96   NEED_JNILIB_EXT=yes
97   dnl If we're building against an uninstalled xapian-core, xapian-config
98   dnl --libs will give an error.
99   if $XAPIAN_CONFIG --libs >/dev/null 2>/dev/null ; then
100     :
101   else
102     NEED_INTREE_DYLD=yes
103     dnl $XAPIAN_LIBS may have some options first, so grab the last argument,
104     dnl which should be the .la file.
105     set x $XAPIAN_LIBS
106     as_fn_arith $# - 1
107     shift $as_val
108     INTREE_DYLD_PATH=$1
109     dnl Make sure the path is absolute.
110     case $INTREE_DYLD_PATH in
111       /*) ;;
112       *) INTREE_DYLD_PATH=`pwd`/$INTREE_DYLD_PATH ;;
113     esac
114     dnl Add .libs or equivalent.
115     INTREE_DYLD_PATH=`echo "$INTREE_DYLD_PATH"|sed 's,\(.*/\).*,\1,'`$lt_cv_objdir
116     AC_SUBST([INTREE_DYLD_PATH])
117   fi
118   ;;
119 esac
120 AM_CONDITIONAL(NEED_JNILIB_EXT, test yes = "$NEED_JNILIB_EXT")
121 AM_CONDITIONAL(NEED_INTREE_DYLD, test yes = "$NEED_INTREE_DYLD")
123 dnl We want XAPIAN_CXXFLAGS to be used for configure tests, so add it to
124 dnl CXXFLAGS for the duration of configure.
125 save_CXXFLAGS=$CXXFLAGS
126 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
128 dnl COMPAT_VERSION is the version of xapian-core that "matches" our version.
129 dnl We allow for bindings being version 0.8.5.1 while xapian-core is 0.8.5.
130 dnl COMPAT_VERSION also ignores any _git123 suffix which snapshots will have.
131 COMPAT_VERSION=[`echo "$PACKAGE_VERSION"|sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/'`]
132 AC_SUBST(COMPAT_VERSION)
134 dnl VERSION_NO_SNAPSHOT simply has any _git123 suffix removed.
135 VERSION_NO_SNAPSHOT=[`echo "$PACKAGE_VERSION"|sed 's/_.*$//'`]
136 AC_SUBST(VERSION_NO_SNAPSHOT)
138 dnl We only need to set docdir for compatibility with autoconf < 2.60 - this
139 dnl code can be removed once we move to requiring autoconf 2.60 or newer.
140 test -n "$docdir" || docdir='${datadir}/doc/${PACKAGE_TARNAME}'
141 AC_SUBST(docdir)
143 AC_ARG_ENABLE(quiet,
144   [AS_HELP_STRING([--enable-quiet], [enable quiet building [default=no]])],
145   [case ${enableval} in
146     yes|no) ;;
147     *) AC_MSG_ERROR([bad value ${enableval} for --enable-quiet]) ;;
148   esac])
150 dnl Pass `--quiet' to libtool if quiet building is requested.  Using an
151 dnl AC_SUBST-ed value like this allows the choice to be easily overridden
152 dnl if you want to see exactly what make and libtool are up to - just run
153 dnl make like this: `make QUIET='
154 QUIET=
155 if test yes = "$enable_quiet"; then
156   QUIET=--quiet
158 AC_SUBST(QUIET)
160 dnl Only probe for SWIG and enable SWIG rules in makefiles if
161 dnl configure --enable-maintainer-mode is used.
162 AM_MAINTAINER_MODE
164 AC_ARG_ENABLE(documentation,
165   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
166   [case ${enableval} in
167     yes|no) ;;
168     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
169   esac])
170 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
171 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
172 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
174 if test x$USE_MAINTAINER_MODE = xyes; then
175   dnl Check for swig - this does most of the work for the bindings.
176   dnl AC_PATH_PROGS only honours an already set SWIG if it's a full
177   dnl path.  Listing it in the "to be searched" list like this allows
178   dnl ./configure SWIG=myswig to work.
179   swigoverridden=${SWIG+yes}
180   AC_PATH_PROGS(SWIG, ["${SWIG-swig}"], [])
181   AC_ARG_VAR(SWIG, [SWIG interface generator (only needed by Xapian developers)])
182   if test -z "$SWIG" ; then
183     AC_MSG_ERROR([Can't find SWIG utility])
184   fi
185   dnl Check for new enough SWIG.
186   dnl
187   dnl 2.0.5 avoids E_NOTICE from generating 'return $r;' when $r isn't set.
188   v=`$SWIG -version 2>&1|sed 's/^SWIG Version \([[0-9\.]]*\).*/\1/p;d'`
189   case $v in
190     [[01].*|2.0.[0-4]|""])
191       msg="SWIG >= 2.0.5 (commit 210266c) required (you have ${v:-an unknown version})"
192       if test -n "$swigoverridden" ; then
193         dnl If SWIG was explicitly set, make this a warning only.
194         AC_MSG_WARN([$msg])
195       else
196         AC_MSG_ERROR([$msg])
197       fi ;;
198   esac
199   SWIG_FLAGS="`$XAPIAN_CONFIG --swigflags` -Werror"
200   AC_SUBST(SWIG_FLAGS)
202   dnl Need perl in maintainer mode to generate the except.i file for python.
203   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
204   test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
205   dnl Need python in maintainer mode to run doxy2swig.py.
206   AC_PATH_PROGS(PYTHON, ["${PYTHON-python2 python}"], [])
207   test -z "$PYTHON" && AC_MSG_ERROR([python is required in maintainer mode])
210 AC_ARG_WITH(python,
211   AC_HELP_STRING([--with-python], [enable Python bindings]),
212   [],
213   [with_python=])
215 AC_ARG_WITH(php,
216   AC_HELP_STRING([--with-php], [enable PHP bindings]),
217   [],
218   [with_php=])
220 AC_ARG_WITH(ruby,
221   AC_HELP_STRING([--with-ruby], [enable Ruby bindings]),
222   [],
223   [with_ruby=])
225 AC_ARG_WITH(tcl,
226   AC_HELP_STRING([--with-tcl], [enable Tcl bindings]),
227   [],
228   [with_tcl=])
230 AC_ARG_WITH(csharp,
231   AC_HELP_STRING([--with-csharp], [enable CSharp bindings]),
232   [],
233   [with_csharp=])
235 AC_ARG_WITH(java,
236   AC_HELP_STRING([--with-java], [enable Java bindings]),
237   [],
238   [with_java=])
240 AC_ARG_WITH(perl,
241   AC_HELP_STRING([--with-perl], [enable Perl bindings]),
242   [],
243   [with_perl=])
245 AC_ARG_WITH(lua,
246   AC_HELP_STRING([--with-lua], [enable Lua bindings]),
247   [],
248   [with_lua=])
250 case $with_python$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_python" && with_python=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_python" ; then
267   dnl See comment for AC_PATH_PROGS(SWIG, ...).
268   AC_PATH_PROGS(PYTHON, ["${PYTHON-python2 python}"], [])
269   AC_ARG_VAR(PYTHON, [Python interpreter])
270   if test -n "$PYTHON" ; then
271     dnl Require Python 2.3 or newer.  It's now > 4.5 years since the last
272     dnl 2.2.x release, so 2.2 is essentially unsupported upstream.
273     AC_MSG_CHECKING([$PYTHON version])
274     version=`$PYTHON -c 'import sys;print("%d.%d" % sys.version_info[[:2]])' 2>/dev/null`
275     case $version in
276     [2.[3-9]*|2.[12][0-9][0-9]*])
277       AC_MSG_RESULT([$version])
278       ;;
279     [[3-9].*])
280       AC_MSG_RESULT([$version (too new - only Python 2 is supported by Xapian 1.2.x)])
281       if test yes = "$with_python" ; then
282         AC_MSG_ERROR([Only Python 2 is supported by Xapian 1.2.x ($python is $version)])
283       fi
284       PYTHON=
285       ;;
286     *)
287       AC_MSG_RESULT([$version (too old)])
288       if test yes = "$with_python" ; then
289         AC_MSG_ERROR([Only python 2.3 or newer is supported ($python is $version)])
290       fi
291       PYTHON=
292       ;;
293     esac
294     if test -n "$PYTHON" ; then
295       if $PYTHON -c 'import distutils.sysconfig' 2>/dev/null ; then
296         PYTHON_INC=`$PYTHON -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_inc().replace(os.sep,"/"))'`
297         AC_SUBST(PYTHON_INC)
298       else
299         if test yes = "$with_python" ; then
300           AC_MSG_ERROR([Couldn't import Python module distutils.sysconfig - you probably need to install a python-dev or python-devel package])
301         else
302           AC_MSG_WARN([Couldn't import Python module distutils.sysconfig - you probably don't have a python-dev or python-devel package installed])
303           PYTHON=
304         fi
305       fi
306     fi
307     if test -n "$PYTHON" ; then
308       dnl Check that Python.h is there, which is a good way to check that
309       dnl the appropriate python-dev package has been installed.
310       AC_MSG_CHECKING([for $PYTHON_INC/Python.h])
311       if test -f "$PYTHON_INC/Python.h" ; then
312         AC_MSG_RESULT(yes)
313         AC_MSG_CHECKING([for directory to install python bindings in])
314         if test -z "$PYTHON_LIB" ; then
315           PYTHON_LIB=`$PYTHON -c 'import os,distutils.sysconfig;print(distutils.sysconfig.get_python_lib(1).replace(os.sep,"/"))'`
316         fi
317         AC_MSG_RESULT([$PYTHON_LIB])
318         AC_ARG_VAR(PYTHON_LIB, [Directory to install python bindings in])
320         AC_MSG_CHECKING([for python libraries to link against])
321         case $host_os in
322         mingw* | pw32*)
323           PYTHON_LIBS=`$PYTHON -c 'import os,sys;print("-L"+os.path.join(sys.prefix,"libs").replace(os.sep,"/")+" -lpython"+sys.version[[:3]].replace(".",""))'` ;;
324         cygwin*)
325           PYTHON_LIBS=`$PYTHON -c 'import os,sys;print("-L"+os.path.join(sys.path[[3]],"config")+" -lpython"+sys.version[[:3]])'` ;;
326         *)
327           PYTHON_LIBS= ;;
328         esac
329         AC_SUBST(PYTHON_LIBS)
330         AC_MSG_RESULT([$PYTHON_LIBS])
332         AC_MSG_CHECKING([for python module extension])
333         dnl Usually ".so", but for example, Mac OS X uses ".dylib".
334         PYTHON_SO=`$PYTHON -c 'import distutils.sysconfig;print(distutils.sysconfig.get_config_vars("SO")[[0]])'`
335         AC_SUBST(PYTHON_SO)
336         AC_MSG_RESULT([$PYTHON_SO])
338         BINDINGS="$BINDINGS python"
339       else
340         AC_MSG_RESULT([no (install python-dev or python-devel package or similar)])
341         if test yes = "$with_python" ; then
342           AC_MSG_ERROR([Python.h not found])
343         fi
344       fi
345     fi
346   fi
349 if test no != "$with_php" ; then
350   dnl See comment for AC_PATH_PROGS(SWIG, ...).
351   AC_PATH_PROGS(PHP_CONFIG, ["${PHP_CONFIG-php-config}"], [])
352   AC_ARG_VAR(PHP_CONFIG, [php-config utility])
353   AC_ARG_VAR(PHP, [php interpreter (optional - only needed to run PHP testsuite with)])
354   if test -n "$PHP_CONFIG" ; then
355     AC_MSG_CHECKING([$PHP_CONFIG version])
356     version=`$PHP_CONFIG --version 2>/dev/null`
357     case $version in
358     5.*)
359       AC_MSG_RESULT([$version])
360       PHP_MAJOR_VERSION=5
361       ;;
362     7.*)
363       AC_MSG_RESULT([$version (not supported, SWIG doesn't support PHP7 yet)])
364       if test yes = "$with_php" ; then
365         AC_MSG_ERROR([SWIG doesn't yet support PHP7 ($PHP_CONFIG reports version $version)])
366       fi
367       with_php=no
368       ;;
369     *)
370       AC_MSG_RESULT([$version (not supported)])
371       if test yes = "$with_php" ; then
372         AC_MSG_ERROR([Only PHP5 is supported ($PHP_CONFIG reports version $version)])
373       fi
374       with_php=no
375       ;;
376     esac
377     AC_SUBST(PHP_MAJOR_VERSION)
379     if test no != "$with_php" ; then
380       AC_MSG_CHECKING([for PHP extension directory])
381       if test -z "$PHP_EXTENSION_DIR" ; then
382         PHP_EXTENSION_DIR=`$PHP_CONFIG --extension-dir`
383       fi
384       AC_MSG_RESULT([$PHP_EXTENSION_DIR])
385       AC_ARG_VAR(PHP_EXTENSION_DIR, [Directory to install PHP extensions in])
386     fi
388     if test no != "$with_php" ; then
389       PHP_INC=`$PHP_CONFIG --includes`
390       AC_SUBST(PHP_INC)
391       save_CPPFLAGS=$CPPFLAGS
392       CPPFLAGS="$CPPFLAGS $PHP_INC"
393       dnl One of SGI's SuSE boxes has php-config but no headers.
394       AC_CHECK_HEADER(zend.h, [], [
395         if test yes = "$with_php" ; then
396           AC_MSG_ERROR(['$PHP_CONFIG --includes' reports '$PHP_INC' but zend.h can't be included from there])
397         fi
398         with_php=no], [ ])
399       CPPFLAGS=$save_CPPFLAGS
400     fi
402     if test no != "$with_php" ; then
403       PHP_found=no
404       case $PHP in
405         "")
406           dnl PHP5's php-config has --php-binary which gives the path to the
407           dnl PHP interpreter.  Otherwise, try "$prefix/bin/php$N" then
408           dnl "$prefix/bin/php".
409           php_prefix=`$PHP_CONFIG --prefix 2>/dev/null`
410           php_bin=$php_prefix/bin/php
411           php_binary=
412           php_binary_major=
413           if $PHP_CONFIG --php_binary > /dev/null 2>&1 ; then
414             php_binary=`$PHP_CONFIG --php-binary 2>/dev/null`
415             case $php_binary in
416               *[0-9]) ;;
417               *) php_binary_major=$php_binary$PHP_MAJOR_VERSION ;;
418             esac
419           fi
420           for php in $php_binary $php_binary_major $php_bin$PHP_MAJOR_VERSION $php_bin ; do
421             AC_MSG_CHECKING([for $php])
422             for ac_exec_ext in '' $ac_executable_extensions; do
423               if $as_executable_p "$php$ac_exec_ext"; then
424                 dnl We get /usr/bin/php on Debian, which might be PHP7:
425                 dnl https://bugs.debian.org/819139
426                 if $php$ac_exec_ext -r 'exit(PHP_MAJOR_VERSION=='"$PHP_MAJOR_VERSION"'?0:1);' 2> /dev/null ; then
427                   PHP=$php$ac_exec_ext
428                   AC_MSG_RESULT([$PHP])
429                   PHP_found=yes
430                   break 2
431                 fi
432               fi
433             done
434             AC_MSG_RESULT([no])
435           done
436           ;;
437         [[\\/]* | ?:[\\/]*]) ;;
438         *)
439           dnl Handle PHP passed in without a path - e.g. PHP=php5
440           AC_PATH_PROGS(PHP, ["$PHP"], [])
441           test -n "$PHP" && PHP_found=yes
442           ;;
443       esac
444       if test yes != "$PHP_found" ; then
445         dnl Try phpN then php.  If the PHP interpreter can't be found, skip the
446         dnl PHP bindings tests.
447         AC_PATH_PROGS(PHP, [php$PHP_MAJOR_VERSION php], [])
448       fi
449       if test -z "$PHP" ; then
450         AC_MSG_WARN([No PHP interpreter found - PHP bindings tests will be skipped])
451         dnl The skiptest script just returns exit code 77.
452         PHP='$(top_srcdir)/skiptest'
453       else
454         AC_MSG_CHECKING([for PHP path separator])
455         PHP_PATH_SEPARATOR=`$PHP -r 'echo PATH_SEPARATOR;'`
456         AC_SUBST([PHP_PATH_SEPARATOR])
457         AC_MSG_RESULT([$PHP_PATH_SEPARATOR])
458       fi
460       case $host_os in
461       mingw* | pw32*)
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
464         dnl there.  FIXME.
465         PHP_LIBS="-L`$PHP_CONFIG --prefix` -lphp${PHP_MAJOR_VERSION}ts" ;;
466       cygwin*)
467         PHP_LIBS="-lphp${PHP_MAJOR_VERSION}lib" ;;
468       *)
469         PHP_LIBS= ;;
470       esac
471       AC_SUBST(PHP_LIBS)
472       BINDINGS="$BINDINGS php"
473     fi
474   fi
477 if test no != "$with_tcl" ; then
478   AC_PATH_PROGS(TCLSH, ["${TCLSH-tclsh}"], [])
479   AC_ARG_VAR(TCLSH, [Tcl interpreter])
480   if test -n "$TCLSH" ; then
481     dnl We need Tcl 8.1 or later for TCL_STUBS.
482     dnl Note: The bindings can easily be made to work with Tcl 8.0 (just
483     dnl don't pass -DUSE_TCL_STUBS when compiling) should you need that.
484     AC_MSG_CHECKING([$TCLSH version])
485     if echo 'if {$tcl_version < 8.1 } { exit 1 }'|$TCLSH 2> /dev/null ; then
486       tcl_version=`echo 'puts "$tcl_version"'|$TCLSH`
487       AC_MSG_RESULT([$tcl_version])
489       AC_ARG_VAR(TCL_LIB, [Directory to install Tcl files into])
490       if test -z "$TCL_LIB" ; then
491         [TCL_LIB=`echo 'foreach d $tcl_pkgPath {if {![regexp {/share(/|$)} $d]} {break}};puts $d'|$TCLSH`]
492       fi
493       AC_SUBST(TCL_LIB)
495       AC_ARG_VAR([TCL_INC], [Directory to include for Tcl headers])
496       if test -z "$TCL_INC" ; then
497         dnl ::tcl::pkgconfig was added in Tcl 8.5.
498         [TCL_INC=`echo 'puts [::tcl::pkgconfig get includedir,runtime]'|$TCLSH 2> /dev/null`]
499         if test -z "$TCL_INC" ; then
500           dnl Prior to Tcl 8.5, there's no good way to get
501           dnl "/usr/include/tcl8.N" directly - tclConfig.sh contains it, but
502           dnl there's no reliable way to locate that prior to Tcl 8.5!
503           dnl
504           dnl So first we find the prefix Tcl is installed under (e.g. "/usr")
505           dnl from the path on TCLSH (or default to /usr if the path doesn't
506           dnl contain "/bin/"), and then we append "/include/tcl" and
507           dnl $tcl_version.
508           tcl_prefix=`echo "$TCLSH"|sed 's!/bin/.*!!p;d'`
509           test -n "$tcl_prefix" || tcl_prefix=/usr
510           TCL_INC=${tcl_prefix}/include/tcl${tcl_version}
511           test -f "$TCL_INC/tcl.h" || TCL_INC=/usr/include
512         fi
513       fi
515       dnl Check that the headers are there (the tcl8.N-dev package
516       dnl may not be installed).
517       TCL_CPPFLAGS=
518       AC_MSG_CHECKING([for tcl.h for version $tcl_version])
519       if test -f "$TCL_INC/tcl.h" ; then
520         tcl_hdr_version=`awk '($1 == "#define" && $2 == "TCL_VERSION") {print $3}' "$TCL_INC/tcl.h"|sed 's/"//g'`
521         if test x"$tcl_hdr_version" = x"$tcl_version" ; then
522           AC_MSG_RESULT([$TCL_INC/tcl.h])
523           BINDINGS="$BINDINGS tcl8"
524           if test x"$TCL_INC" != x"/usr/include" ; then
525             TCL_CPPFLAGS="-I$TCL_INC"
526           fi
527         else
528           AC_MSG_RESULT([not found])
529           if test yes = "$with_tcl" ; then
530             AC_MSG_ERROR([Found tcl.h for version $tcl_hdr_version, not $tcl_version])
531           fi
532           TCLSH=
533         fi
534       else
535         AC_MSG_RESULT([not found])
536         if test yes = "$with_tcl" ; then
537           AC_MSG_ERROR([Can't find tcl.h])
538         fi
539         TCLSH=
540       fi
542       if test -n "$TCLSH" ; then
543         dnl Cygwin needs to link with -ltcl8.5 or similar.
544         TCL_LIBS=
545         case $host_os in
546         cygwin*)
547           AC_CHECK_LIB([tcl$tcl_version], [Tcl_Init],
548                        [TCL_LIBS="-ltcl$tcl_version"],
549                        [AC_MSG_ERROR([libtcl$tcl_version not found])])
550           ;;
551         *)
552           dnl ::tcl::pkgconfig was added in Tcl 8.5, but prior to 8.6 it isn't
553           dnl necessary to link against -ltclstub anyway.
554           [TCLCONFIG_SH=`echo 'puts [file join [::tcl::pkgconfig get libdir,runtime] tclConfig.sh]'|$TCLSH 2> /dev/null`]
555           if test -n "$TCLCONFIG_SH" && test -r "$TCLCONFIG_SH" ; then
556             eval "`grep ^TCL_STUB_LIB_SPEC= $TCLCONFIG_SH`"
557             TCL_LIBS=$TCL_STUB_LIB_SPEC
558           fi
559           TCL_CPPFLAGS="$TCL_CPPFLAGS -DUSE_TCL_STUBS" ;;
560         esac
561       fi
563       AC_SUBST(TCL_CPPFLAGS)
564       AC_SUBST(TCL_LIBS)
565     else
566       AC_MSG_RESULT([< 8.1 (too old)])
567       if test yes = "$with_tcl" ; then
568         AC_MSG_ERROR([$TCLSH too old (Tcl 8.1 or newer required)])
569       fi
570     fi
571   else
572     if test yes = "$with_tcl" ; then
573       AC_MSG_ERROR([tclsh not found])
574     fi
575   fi
578 if test no != "$with_csharp" ; then
579   csc_note=
580   AC_ARG_VAR(CSC, [CSharp compiler command])
581   if test -n "$CSC" ; then
582     AC_PATH_PROGS(CSC, ["$CSC"], [])
583   fi
584   if test -z "$CSC" ; then
585     dnl First we try cli-csc and mono-csc, which are used by Debian and Ubuntu
586     dnl as "alternatives" which can be mapped to the CSharp compiler the admin
587     dnl favours.
588     AC_PATH_PROGS(CSC, [cli-csc mono-csc], [])
589     if test -z "$CSC" ; then
590       dnl mcs is the Mono CSharp compiler, which is a unified compiler
591       dnl available from Mono 2.11 (and also the compiler in Mono 1.0, but
592       dnl that's no longer relevant).
593       AC_PATH_PROGS(CSC, [mcs], [])
594       if test -n "$CSC" ; then
595         dnl There are other tools called mcs (such as /usr/bin/mcs on Tru64),
596         dnl so we check that the mcs we found understands --version which is
597         dnl sufficient to distinguish mono's mcs from the Tru64 one.
598         AC_MSG_CHECKING([whether $CSC is from GNU Mono])
599         if (exec >&5 2>&5;$CSC --version </dev/null;exit $?) ; then
600           AC_MSG_RESULT(yes)
601         else
602           AC_MSG_RESULT(no)
603           CSC=
604           csc_note="$csc_note (found different mcs program)"
605         fi
606       fi
607     fi
608     if test -z "$CSC" ; then
609       dnl gmcs, smcs, and dmcs are versions of the Mono CSharp compiler
610       dnl targeting various runtime versions, deprecated in favour of mcs
611       dnl (checked for above) as of Mono 2.11.
612       dnl
613       dnl cscc is the Portable.NET CSharp compiler.
614       AC_PATH_PROGS(CSC, [dmcs smcs gmcs cscc], [])
615     fi
616     if test -z "$CSC" ; then
617       dnl csc is the Microsoft CSharp compiler.
618       AC_PATH_PROGS(CSC, [csc], [])
619       if test -n "$CSC" ; then
620         dnl Chicken (the Scheme-to-C compiler) includes a tool called csc so we
621         dnl check if the output from "csc -version" includes the word chicken
622         dnl which is sufficient to distinguish Chicken's csc from Microsoft's
623         dnl csc.exe.
624         AC_MSG_CHECKING([whether $CSC is for CSharp])
625         if $CSC -version 2>/dev/null|grep chicken > /dev/null ; then
626           AC_MSG_RESULT(no)
627           CSC=
628           csc_note="$csc_note (found Chicken csc program)"
629         else
630           AC_MSG_RESULT(yes)
631         fi
632       fi
633     fi
634   fi
636   if test -n "$CSC" ; then
637     AC_ARG_VAR(GACUTIL, [gacutil utility to use for CSharp bindings])
638     if test -n "$GACUTIL" ; then
639       AC_PATH_PROGS(GACUTIL, ["$GACUTIL"], [])
640     fi
641     if test -z "$GACUTIL" ; then
642       AC_PATH_PROGS(GACUTIL, [cli-gacutil gacutil ilgac], [])
643     fi
645     AC_ARG_VAR(SN, [sn utility to use for CSharp bindings])
646     if test -n "$SN" ; then
647       AC_PATH_PROGS(SN, ["$SN"], [])
648     fi
649     if test -z "$SN" ; then
650       AC_PATH_PROGS(SN, [cli-sn sn], [])
651     fi
652     if test -z "$SN" ; then
653       case $GACUTIL in
654       dnl Portable.net doesn't support strong naming yet and ilgac doesn't
655       dnl require assemblies to be strong named before adding them to the GAC.
656       *ilgac*) SN=/bin/true ;;
657       esac
658     fi
659     if test -n "$GACUTIL" -a -n "$SN" ; then
660       AC_MSG_CHECKING([whether the CSharp compiler works])
661       [echo 'class conftest { public static void Main() { System.Console.WriteLine("OK"); } }' > conftest.cs]
662       if (exec >&5 2>&5;$CSC /out:conftest.exe conftest.cs;exit $?) ; then
663         AC_MSG_RESULT(yes)
664         AC_MSG_CHECKING([whether CSharp programs can just be run])
665         if test OK = "`./conftest.exe 2> /dev/null`" ; then
666           AC_MSG_RESULT(yes)
667           RUN_CSHARP=
668         else
669           AC_MSG_RESULT(no)
670           AC_PATH_PROGS(MONO, ["${MONO-mono}"], [])
671           if test -z "$MONO" ; then
672             AC_PATH_PROGS(MONO, [ilrun], [])
673           fi
674           AC_ARG_VAR(MONO, [CSharp bytecode interpreter (optional - only needed to run CSharp testsuite with)])
675           if test -n "$MONO" ; then
676             AC_MSG_CHECKING([whether $MONO can run CSharp programs])
677             if test OK = "`$MONO ./conftest.exe 2> /dev/null`" ; then
678               AC_MSG_RESULT(yes)
679               RUN_CSHARP=mono
680             else
681               AC_MSG_RESULT([no - CSharp tests will be skipped])
682               RUN_CSHARP='\$(top_srcdir)/skiptest'
683             fi
684           else
685             AC_MSG_RESULT([not found - CSharp tests will be skipped])
686             RUN_CSHARP='\$(top_srcdir)/skiptest'
687           fi
688         fi
689         AC_SUBST(RUN_CSHARP)
691         AC_MSG_CHECKING([for extra flags for $GACUTIL])
692         GACUTIL_FLAGS='/package $(ASSEMBLY) /gacdir $(libdir) /root $(DESTDIR)$(libdir)'
693         case $GACUTIL in
694         *ilgac*) ;;
695         *)
696           dnl Microsoft's gacutil accepts fewer options than Mono's
697           $GACUTIL /\?|grep '\<Mono\>' >/dev/null || GACUTIL_FLAGS=
698           ;;
699         esac
700         AC_SUBST([GACUTIL_FLAGS])
701         if test -z "$GACUTIL_FLAGS" ; then
702           AC_MSG_RESULT([no])
703         else
704           AC_MSG_RESULT([$GACUTIL_FLAGS])
705         fi
707         BINDINGS="$BINDINGS csharp"
708       else
709         AC_MSG_RESULT(no)
710         if test yes = "$with_csharp" ; then
711           AC_MSG_ERROR([CSharp compiler $CSC doesn't work])
712         fi
713       fi
714     else
715       if test yes = "$with_csharp" ; then
716         if test -z "$GACUTIL" ; then
717           AC_MSG_ERROR([Mono gacutil not found])
718         elif test -z "$SN" ; then
719           AC_MSG_ERROR([Mono sn not found])
720         fi
721       fi
722     fi
723   else
724     if test yes = "$with_csharp" ; then
725       AC_MSG_ERROR([CSharp compiler not found$csc_note])
726     fi
727   fi
730 JAVA_CPPFLAGS=
731 if test no != "$with_java" ; then
732   AC_PATH_PROGS(JAVA, ["${JAVA-java}"], [],
733         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
734   AC_PATH_PROGS(JAVAC, ["${JAVAC-javac}"], [],
735         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
736   AC_PATH_PROGS(JAR, ["${JAR-jar}"], [],
737         [${JAVA_HOME+$JAVA_HOME/bin:}${JDK_HOME+$JDK_HOME/bin:}$PATH])
738   AC_ARG_VAR(JAVA, [Java interpreter command])
739   AC_ARG_VAR(JAVAC, [Java compiler command])
740   AC_ARG_VAR(JAR, [java jar utility])
741   AC_ARG_VAR(JAVA_HOME, [Pathname of the directory where the JDK is installed])
742   AC_ARG_VAR(JDK_HOME, [Pathname of the directory where the JDK is installed])
743   AC_ARG_VAR(JNI_INCLUDE_DIR, [Pathname of the directory where jni.h is installed])
744   if test -n "$JAVA" -a -n "$JAVAC" -a -n "$JAR" ; then
745     dnl Eric says:
746     dnl  The JNI library *requires* "Java 2", which is 1.2 or better.
747     dnl
748     dnl So checking for jni.h presumably implicitly checks we have "Java 2".
749     dnl Note: jni.h #defines JNI_VERSION_1_[1246] (but not 3 or 5 it seems).
750     dnl So we could check for one of these if we want to check for a particular
751     dnl JDK version...
752     java_ok=no
753     AC_CHECK_HEADER([jni.h], [java_ok=yes], [
754       dnl We need to look for jni.h in /usr/lib/jvm/java-gcj/include on some
755       dnl Debian and Ubuntu boxes at least.  And on Mac OS X, jni.h lives
756       dnl in /System/Library/Frameworks/JavaVM.framework/Headers.
757       SAVE_CPPFLAGS=$CPPFLAGS
758       real_javac=$JAVAC
759       dnl Avoid endlessly traversing if there's a symlink loop.
760       for count in 1 2 3 4 5 6 7 8 9 ; do
761         r=`readlink "$real_javac"`
762         test -n "$r" || break
763         real_javac=$r
764       done
765       dnl Translate ".../bin/javac" to ".../include".
766       [rel_jnidir=`echo "$real_javac"|sed 's!/[^/]*/[^/]*$!/include!'`]
767       for jnidir in \
768           $JNI_INCLUDE_DIR \
769           ${JAVA_HOME+"$JAVA_HOME/include"} \
770           ${JDK_HOME+"$JDK_HOME/include"} \
771           "$rel_jnidir" \
772           /System/Library/Frameworks/JavaVM.framework/Headers ; do
773         CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
774         AC_MSG_CHECKING([for jni.h in $jnidir])
775         if test -f "$jnidir/jni.h" ; then
776           AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
777           if test yes = $java_ok ; then
778             AC_MSG_RESULT([yes])
779             JAVA_CPPFLAGS=-I$jnidir
780             break
781           fi
783           dnl For OpenJDK (and maybe others) we have to specify an extra -I
784           dnl option for an OS-specific subdirectory containing a "jni_md.h"
785           dnl header which is included by "jni.h".  Sadly we seem to need to
786           dnl hardcode a mapping for these platform names - the list below
787           dnl was determined by inspecting the source code of OpenJDK 8.
788           jni_host_os=
789           case $host_os in
790             linux*)
791               jni_host_os=linux ;;
792             solaris*)
793               jni_host_os=solaris ;;
794             mingw* | pw32* | cygwin*)
795               jni_host_os=win32 ;;
796             darwin*)
797               jni_host_os=darwin ;;
798             *bsd*)
799               jni_host_os=bsd ;;
800             aix*)
801               jni_host_os=aix ;;
802           esac
803           if test -n "$jni_host_os" ; then
804             CPPFLAGS="$CPPFLAGS -I$jnidir/$jni_host_os"
805             AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <jni.h>]])], [java_ok=yes])
806             if test yes = $java_ok ; then
807               AC_MSG_RESULT([yes, requires additional -I$jnidir/$jni_host_os])
808               JAVA_CPPFLAGS="-I$jnidir -I$jnidir/$jni_host_os"
809               break
810             fi
811           fi
812           AC_MSG_RESULT([found, but not usable])
814           CPPFLAGS="$SAVE_CPPFLAGS -I$jnidir"
815         else
816           AC_MSG_RESULT([no])
817         fi
818       done
819       CPPFLAGS=$SAVE_CPPFLAGS
820       test noyes = $java_ok$with_java && AC_MSG_ERROR([jni.h not found])
821       ], [ ])
822     AC_SUBST(JAVA_CPPFLAGS)
823     if test yes = $java_ok ; then
824       AC_MSG_CHECKING([for Java path separator])
825       [echo 'public class conftest { public static void main(String[] args) { System.out.println(System.getProperty("path.separator")); } }' > conftest.java]
826       if (exec >&5 2>&5;$JAVAC conftest.java;exit $?) ; then
827         JAVA_PATHSEP=`$JAVA conftest 2>&5`
828         AC_SUBST(JAVA_PATHSEP)
829         if test -n "$JAVA_PATHSEP" ; then
830           AC_MSG_RESULT($JAVA_PATHSEP)
831           BINDINGS="$BINDINGS java"
832         else
833           AC_MSG_RESULT([failed to run test program])
834           java_ok=no
835         fi
836       else
837         AC_MSG_RESULT([failed to compile test program])
838         java_ok=no
839       fi
840       if test no = "$java_ok" ; then
841         test yes = "$with_java" && AC_MSG_ERROR([Couldn't compile and run a simple Java test program])
842       fi
843     fi
844   else
845     if test yes = "$with_java" ; then
846       if test -z "$JAVA" ; then
847         AC_MSG_ERROR([java not found])
848       elif test -z "$JAVAC" ; then
849         AC_MSG_ERROR([javac not found])
850       elif test -z "$JAR" ; then
851         AC_MSG_ERROR([jar not found])
852       fi
853     fi
854   fi
857 if test no != "$with_ruby" ; then
858   dnl See comment for AC_PATH_PROGS(SWIG, ...).
859   if test -n "$RUBY" ; then
860     AC_PATH_PROGS(RUBY, ["$RUBY"], [])
861   else
862     AC_PATH_PROGS(RUBY, [ruby1.8 ruby], [])
863   fi
864   AC_ARG_VAR(RUBY, [Ruby interpreter])
865   if test -n "$RUBY" ; then
866     dnl Require Ruby 1.8 or newer.  Paul says:
867     dnl  I'm using 1.8.4.  I imagine anything in the 1.8.x series will be fine,
868     dnl  not sure about 1.6 but hardly anyone uses <1.8.
869     dnl
870     dnl Brief testing with Ruby 1.6.8 show the bindings probably work there,
871     dnl but smoketest.rb doesn't because the test/unit module isn't available.
872     AC_MSG_CHECKING([$RUBY version])
873     dnl RUBY_VERSION works with 1.6.  Once we've checked we have at least 1.8
874     dnl we can safely use RbConfig below (RbConfig requires Ruby 1.8; Config
875     dnl gives a deprecation warning with Ruby 1.9.3).
876     version=`$RUBY -e 'print RUBY_VERSION' 2>/dev/null`
877     case $version in
878     "")
879       AC_MSG_RESULT([\$RUBY -e 'print RUBY_VERSION' didn't work])
880       if test yes = "$with_ruby" ; then
881         AC_MSG_ERROR([Working Ruby interpreter not found])
882       fi
883       RUBY=
884       ;;
885     [0.*|1.[0-7]|1.[0-7].*])
886       AC_MSG_RESULT([$version (too old)])
887       if test yes = "$with_ruby" ; then
888         AC_MSG_ERROR([Only Ruby 1.8 or newer is supported ($RUBY is $version)])
889       fi
890       RUBY=
891       ;;
892     esac
893     if test -n "$RUBY" ; then
894       AC_MSG_RESULT([$version])
895       AC_ARG_VAR(RUBY_INC, [Directory where ruby.h can be found])
896       if test -z "$RUBY_INC" ; then
897         dnl Ruby 1.9 added rubyhdrdir; for older Ruby we use archdir.
898         [RUBY_INC=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["rubyhdrdir"] || RbConfig::CONFIG["archdir"]'`]
899       fi
900       AC_SUBST(RUBY_INC)
901       dnl Check that ruby.h is there, which is a good way to check that
902       dnl the appropriate ruby-dev package has been installed.
903       AC_MSG_CHECKING([for $RUBY_INC/ruby.h])
904       if test -f "$RUBY_INC/ruby.h" ; then
905         AC_MSG_RESULT(yes)
907         AC_MSG_CHECKING([for ruby/io.h])
908         rm -f ruby/rubyio.h
909         if test -f "$RUBY_INC/ruby/io.h" ; then
910           AC_MSG_RESULT(yes)
912           dnl In a VPATH build, the ruby subdirectory won't exist the first
913           dnl time.
914           test -d ruby || mkdir ruby
916           dnl Newer Ruby has ruby/io.h - older has rubyio.h.  Ruby doesn't
917           dnl seem to provide any way to generate code which works with
918           dnl both (and even the version number isn't a discriminator as
919           dnl Debian etch has 1.9 without ruby/io.h).  The SWIG version
920           dnl we're currently using assumes rubyio.h exists and luckily
921           dnl it includes it with "", so we can just drop a rubyio.h
922           dnl wrapper alongside ruby/xapian_wrap.cc.
923           echo '#include <ruby/io.h>' > ruby/rubyio.h
924         else
925           AC_MSG_RESULT(no)
926         fi
928         AC_ARG_VAR(RUBY_INC_ARCH, [Directory where ruby/config.h can be found (needed from Ruby 1.9)])
929         if test -z "$RUBY_INC_ARCH" ; then
930           dnl Ruby 2.0 and later Ruby 1.9 have rubyarchhdrdir; for early 1.9,
931           dnl use rubyhdrdir+"/"+arch.
932           [RUBY_INC_ARCH=`$RUBY -rrbconfig -e 'd = RbConfig::CONFIG["rubyhdrdir"]; print RbConfig::CONFIG["rubyarchhdrdir"] || (d ? d + "/" + RbConfig::CONFIG["arch"] : "")'`]
933           dnl Ruby 1.8 has no rubyhdrdir, so set RUBY_INC_ARCH=RUBY_INC.
934           test x"$RUBY_INC_ARCH" != x || RUBY_INC_ARCH=$RUBY_INC
935         fi
936         AC_SUBST(RUBY_INC_ARCH)
938         AC_ARG_VAR(RUBY_LIB, [Directory to install ruby files into])
939         if test -z "$RUBY_LIB" ; then
940           [RUBY_LIB=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitelibdir"]'`]
941         fi
942         AC_SUBST(RUBY_LIB)
944         AC_ARG_VAR(RUBY_LIB_ARCH, [Directory to install ruby binary modules into])
945         if test -z "$RUBY_LIB_ARCH" ; then
946           [RUBY_LIB_ARCH=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["sitearchdir"]'`]
947         fi
948         AC_SUBST(RUBY_LIB_ARCH)
950         RUBY_LIBS=
951         if test unsupported = "$allow_undefined_flag" ; then
952           dnl For Microsoft Windows and a few other platforms.
953           [RUBY_LIBS=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG["LIBRUBYARG"]'`]
954         fi
955         AC_SUBST(RUBY_LIBS)
957         if test yes = "$enable_documentation" ; then
958           if test -n "$RDOC" ; then
959             AC_PATH_PROGS(RDOC, ["$RDOC"], [])
960           else
961             dnl Try replace the *last* 'ruby' with 'rdoc'.
962             rdoc_best_guess=`echo "$RUBY"|sed 's,\(.*\)ruby,\1rdoc,'`
963             AC_PATH_PROGS(RDOC, ["$rdoc_best_guess"], [])
964             if test -z "$RDOC"; then
965               AC_PATH_PROGS(RDOC, [rdoc], [])
966               test -n "$RDOC" || RDOC="$MISSING rdoc"
967             fi
968           fi
969         fi
971         BINDINGS="$BINDINGS ruby"
972       else
973         AC_MSG_RESULT([no (install ruby-dev or ruby-devel package or similar)])
974         if test yes = "$with_ruby" ; then
975           AC_MSG_ERROR([ruby.h not found])
976         fi
977       fi
978       RUBY_DLEXT=`$RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]'`
979       AC_SUBST(RUBY_DLEXT)
980     fi
981   fi
984 if test no != "$with_perl" ; then
985   AC_PATH_PROGS(PERL, ["${PERL-perl}"], [])
986   AC_ARG_VAR(PERL, [perl interpreter])
987   if test -n "$PERL" ; then
988     AC_ARG_VAR(PERL_INC, [Directory to include for XSUB,h and other Perl API headers])
989     if test -z "$PERL_INC" ; then
990       PERL_INC=`$PERL -MConfig -e 'print $Config{archlibexp}, "/CORE"'`
991     fi
992     AC_SUBST(PERL_INC)
994     AC_ARG_VAR(PERL_ARCH, [Directory to install architecture-dependent perl files into])
995     if test -z "$PERL_ARCH" ; then
996       PERL_ARCH=`$PERL -MConfig -e 'print $Config{installsitearch}'`
997     fi
998     AC_SUBST(PERL_ARCH)
1000     AC_ARG_VAR(PERL_LIB, [Directory to install architecture-independent perl files into])
1001     if test -z "$PERL_LIB" ; then
1002       PERL_LIB=`$PERL -MConfig -e 'print $Config{installsitelib}'`
1003     fi
1004     AC_SUBST(PERL_LIB)
1006     AC_ARG_VAR(PERL_SO, [for perl module extension])
1007     if test -z "$PERL_SO" ; then
1008       PERL_SO=`$PERL -MConfig -e 'print ".", $Config{dlext}'`
1009     fi
1010     AC_SUBST(PERL_SO)
1012     if test -z "$PERL_XAPIAN_VERSION" ; then
1013       dnl snapshot versions look like 1.2.3_git123 or 1.2.3_svn14971
1014       case $PACKAGE_VERSION in
1015       *_git*)
1016         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_git/./'` ;;
1017       *_svn*)
1018         PERL_XAPIAN_VERSION=`echo "$PACKAGE_VERSION"|sed 's/_svn/./'` ;;
1019       *)
1020         PERL_XAPIAN_VERSION=$PACKAGE_VERSION.0 ;;
1021       esac
1022     fi
1023     AC_SUBST(PERL_XAPIAN_VERSION)
1025     BINDINGS="$BINDINGS perl"
1026   else
1027     if test yes = "$with_perl" ; then
1028       AC_MSG_ERROR([perl not found])
1029     fi
1030   fi
1033 if test no != "$with_lua" ; then
1034   AC_PATH_PROGS(LUA, ["${LUA-lua}"], [])
1035   AC_ARG_VAR(LUA, [lua interpreter])
1036   if test -n "$LUA" ; then
1037     dnl We need Lua 5.1 or later.
1038     AC_MSG_CHECKING([$LUA version])
1039     lua_version=`$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' 2>&AS_MESSAGE_LOG_FD`
1041     case $lua_version in
1042     [[01234]].*|5.0|5.0.*)
1043       AC_MSG_RESULT([$lua_version < 5.1 (too old)])
1044       if test yes = "$with_lua" ; then
1045         AC_MSG_ERROR([$LUA too old (Lua 5.1 or newer required)])
1046       fi
1047       LUA=
1048       ;;
1049     "")
1050       AC_MSG_RESULT([\$LUA -e 'print(_VERSION)' | cut -f 2 -d ' ' didn't work])
1052       if test yes = "$with_lua" ; then
1053         AC_MSG_ERROR([Working Lua interpreter not found])
1054       fi
1055       LUA=
1056       ;;
1057     esac
1059     if test -n "$LUA" ; then
1060       AC_MSG_RESULT([$lua_version])
1062       AC_ARG_VAR([LUA_LIB], [Directory to install compiled Lua modules into])
1063       AC_ARG_VAR([LUA_SO], [Extension for compiled Lua modules (e.g. LUA_SO=.so)])
1064       AC_MSG_CHECKING([for directory to install compiled Lua modules into])
1065       if test -z "$LUA_LIB" -o -z "$LUA_SO" ; then
1066         lua_cpath=`$LUA -e 'require("package") print(package.cpath)'`
1067         dnl Look for the first absolute path in lua_cpath which has leaf
1068         dnl "?.<ext>" and put the directory part into lua_lib and <ext> into
1069         dnl lua_so.  If LUA_SO was specified by the user, only consider
1070         dnl entries where <ext> matches LUA_SO.
1071         lua_lib=
1072         lua_so=
1073         case $LUA_SO in
1074           "")
1075            [lua_so_pat='[a-zA-Z][a-zA-Z]*'] ;;
1076           .*)
1077             dnl If LUA_SO has a leading '.', remove it.
1078             lua_so_pat=`AS_ECHO("$LUA_SO")|sed 's/^\.//'` ;;
1079           *)
1080             dnl If LUA_SO was specified without a leading '.', add one to the
1081             dnl value substituted into Makefile.in.
1082             lua_so_pat=$LUA_SO
1083             LUA_SO=.$LUA_SO
1084             ;;
1085         esac
1086         while test x"$lua_cpath" != x ; do
1087           [lua_lib=`expr X"$lua_cpath" : X'\([^;]*\)'`]
1088           lua_so=.`expr X"$lua_lib" : X'/.*/?\.\('"$lua_so_pat"'\)$'`
1089           case $lua_so in
1090             .|.lua)
1091               dnl If someone has foolishly put ?.lua in cpath, ignore them.
1092               lua_lib=
1093               ;;
1094             *)
1095               lua_lib=`expr X"$lua_lib" : X'\(/.*\)/?\.'"$lua_so_pat"'$'`
1096               break ;;
1097           esac
1098           [lua_cpath=`expr X"$lua_cpath" : X'[^;]*;*\(.*\)'`]
1099         done
1100         test -n "$LUA_LIB" || LUA_LIB=$lua_lib
1101         test -n "$LUA_SO" || LUA_SO=$lua_so
1102       fi
1103       if test -z "$LUA_LIB"; then
1104         AC_MSG_RESULT([not found])
1105       else
1106         AC_MSG_RESULT([$LUA_LIB])
1107       fi
1108       AC_SUBST([LUA_LIB])
1110       AC_MSG_CHECKING([for extension to use for compiled Lua modules])
1111       if test -z "$LUA_SO"; then
1112         AC_MSG_RESULT([not found])
1113       else
1114         AC_MSG_RESULT([$LUA_SO])
1115       fi
1116       AC_SUBST([LUA_SO])
1118       AC_MSG_CHECKING([for Lua header files])
1119       AC_ARG_VAR([LUA_INC], [Directory to include for lua headers])
1120       if test -z "$LUA_INC" ; then
1121         dirs="/usr/include/lua$lua_version /usr/local/include/lua$lua_version"
1122         for i in $dirs ; do
1123           if test -r "$i/lua.h"; then
1124             LUA_INC=$i
1125             break
1126           fi
1127         done
1128       fi
1130       if test -z "$LUA_INC" ; then
1131         AC_MSG_RESULT([not found])
1132       else
1133         AC_MSG_RESULT([$LUA_INC])
1134         BINDINGS="$BINDINGS lua"
1135         LUA_CPPFLAGS="-I$LUA_INC"
1136       fi
1137       AC_SUBST([LUA_CPPFLAGS])
1138     fi
1139   else
1140     if test yes = "$with_lua" ; then
1141       AC_MSG_ERROR([lua not found])
1142     fi
1143   fi
1146 AC_SUBST(BINDINGS)
1148 dnl Set flags to control warnings (enable more, or disable annoying ones)
1149 dnl and other compiler specific flags.
1150 SWIG_CXXFLAGS=
1151 JAVA_CXXFLAGS=
1152 if test yes = "$GXX" ; then
1153   dnl Python itself is compiled with -fno-strict-aliasing, and it appears
1154   dnl it's safest to follow this lead when compiling the SWIG generated
1155   dnl interface code.  E.g.:
1156   dnl   http://article.gmane.org/gmane.comp.gcc.devel/74692
1157   dnl The code SWIG generates for other languages seems to have similar
1158   dnl issues too, so just turn this on for all of them.
1159   dnl
1160   dnl There's no need to check -fno-strict-aliasing is supported as it works
1161   dnl with GCC 2.95 and we don't support anything older.
1162   SWIG_CXXFLAGS="-fno-strict-aliasing"
1164   dnl We need to explicitly link against -lstdc++ on OpenBSD (discovered
1165   dnl on OpenBSD 3.7 with GCC 3.3.5 but this appears to be due to a
1166   dnl deliberate decision on the part of OpenBSD developers).  Luckily
1167   dnl we can just always specify -lstdc++ explicitly if GCC is the
1168   dnl compiler and libtool will eliminate the duplicate on other
1169   dnl platforms.
1170   XAPIAN_LIBS="$XAPIAN_LIBS -lstdc++"
1172   dnl Intel's C++ compiler is identified as "GXX" by autoconf's test - check
1173   dnl which we actually have.
1174   AC_EGREP_CPP(yes,
1175     [#ifdef __INTEL_COMPILER
1176      yes
1177      #endif
1178     ],
1179     [
1180       dnl Intel's compiler:
1181       dnl
1182       dnl -w1 stops the avalanche of uninteresting "remark" messages.
1183       dnl -wd... disables warnings which don't have good code workarounds.
1184       dnl
1185       dnl Swig generated code gives lots of unused and uninitialized warnings.
1186       dnl They're non-harmful, so suppress them.
1187       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -w1 -wd177,1572"
1188       dnl The Java JNI wrappers have a few unused variables.
1189       JAVA_CXXFLAGS="-Wall -w1 -wd177,1572"
1190     ],
1191     [
1192       dnl GCC:
1193       dnl
1194       dnl Swig generated code gives lots of unused and uninitialized warnings.
1195       dnl They're non-harmful, so suppress them.
1196       SWIG_CXXFLAGS="$SWIG_CXXFLAGS -Wall -Wno-unused -Wno-uninitialized"
1197       AC_MSG_CHECKING([whether to use -fvisibility=hidden])
1198       dnl To be robust, we check both that -fvisibility=hidden is recognised
1199       dnl and that SWIG will have added the visibility attributes.
1200       dnl The GCC wiki says it's supported from GCC 4.0 onwards.  GCC 3.4
1201       dnl also supports -fvisibility, but doesn't allow visibility to be
1202       dnl specified for classes, which probably breaks throwing exception
1203       dnl classes from the library.  We want that to work, so only switch
1204       dnl this on for GCC 4.0 onwards.
1205       SAVE_CXXFLAGS=$CXXFLAGS
1206       CXXFLAGS="-fvisibility=hidden"
1207       AC_TRY_COMPILE([], [
1208 #if __GNUC__ >= 4
1209   /* GCC supports -fvisibility and allows specifying visibility for classes. */
1210 #else
1211   choke me
1212 #endif
1214                      AC_MSG_RESULT(yes)
1215                      SWIG_CXXFLAGS="$SWIG_CXXFLAGS -fvisibility=hidden"
1216                      ,
1217                      AC_MSG_RESULT(no))
1218       CXXFLAGS=$SAVE_CXXFLAGS
1219       dnl The Java JNI wrappers have a few unused variables.
1220       JAVA_CXXFLAGS="-Wall -W -Wno-unused"
1221     ])
1223 AC_SUBST(SWIG_CXXFLAGS)
1224 AC_SUBST(JAVA_CXXFLAGS)
1226 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1227 CXXFLAGS=$save_CXXFLAGS
1229 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1230 : ${AUTOM4TE=autom4te}
1231 AC_SUBST([AUTOM4TE])
1233 AC_CONFIG_FILES([Makefile
1234  xapian-version.h
1235  python/Makefile python/version.i
1236  php/Makefile
1237  java/Makefile java/native/Makefile java/org/xapian/Makefile
1238  java/org/xapian/errors/Makefile java/org/xapian/examples/Makefile
1239  java-swig/Makefile
1240  tcl8/Makefile tcl8/pkgIndex.tcl
1241  csharp/Makefile csharp/AssemblyInfo.cs
1242  ruby/Makefile
1243  perl/Makefile perl/util.i
1244  lua/Makefile
1245  xapian-bindings.spec
1246  ])
1247 AC_OUTPUT
1249 echo ""
1250 if test -z "$BINDINGS" ; then
1251   echo "*** Not found the required tools for building bindings for any"
1252   echo "*** supported language!"
1253   echo "***"
1254   echo "*** You may need to install -dev or -devel packages for the languages"
1255   echo "*** you want to build bindings for."
1256   echo "***"
1257   echo "*** For details of how to point configure at tools not on PATH, see:"
1258   echo "***     ./configure --help"
1259 else
1260   echo "*** Building bindings for languages:" $BINDINGS
1262 echo ""
1263 if test "$COMPAT_VERSION" != "$XAPIAN_VERSION" ; then
1264   release_series=[`echo "$COMPAT_VERSION"|sed 's/[0-9][0-9]*$//'`]
1265   case $XAPIAN_VERSION in
1266   $release_series*) ;;
1267   *)
1268     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.])
1269     ;;
1270   esac
1271   dnl 0.8.2 was the first version which set XAPIAN_VERSION
1272   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.])