1 dnl Process this file with autoconf to produce a configure script.
3 dnl NB When updating the version for a release, update LIBRARY_VERSION_INFO
5 AC_INIT([xapian-core], [1.5.0], [https://xapian.org/bugs])
6 dnl See HACKING document for details of the reasons for required versions.
8 dnl Extract from the libtool info manual:
10 dnl Here are a set of rules to help you update your library version information:
12 dnl 1. Start with version information of '0:0:0' for each libtool library.
14 dnl 2. Update the version information only immediately before a public
15 dnl release of your software. More frequent updates are unnecessary,
16 dnl and only guarantee that the current interface number gets larger
19 dnl 3. If the library source code has changed at all since the last
20 dnl update, then increment REVISION ('C:R:A' becomes 'C:r+1:A').
22 dnl 4. If any interfaces have been added, removed, or changed since the
23 dnl last update, increment CURRENT, and set REVISION to 0.
25 dnl 5. If any interfaces have been added since the last public release,
26 dnl then increment AGE.
28 dnl 6. If any interfaces have been removed since the last public release
29 dnl then set AGE to 0.
31 dnl LIBRARY_VERSION_INFO for libxapian1.5
32 dnl 0:0:0 1.5.0 Reset as library renamed
33 LIBRARY_VERSION_INFO=0:0:0
34 AC_SUBST([LIBRARY_VERSION_INFO])
36 LIBRARY_VERSION_SUFFIX=
37 dnl Where xapian.h, etc go.
39 case $PACKAGE_VERSION in
41 dnl Development release series:
42 [dev_series=`echo "$PACKAGE_VERSION"|sed 's/\.[^.]*$//'`]
44 dnl Append version installed programs by default. To specify no suffix,
45 dnl configure with: --program-suffix=
46 test x"$program_suffix" != xNONE || program_suffix=-$dev_series
48 incdir=$incdir/xapian-$dev_series
50 LIBRARY_VERSION_SUFFIX=-$dev_series
54 AC_SUBST([LIBRARY_VERSION_SUFFIX])
57 dnl Check the build directory doesn't contain a space, so we die early with
61 AC_MSG_ERROR([You can't build in a directory whose path contains a space])
65 dnl Check the source directory doesn't contain a space, so we die early with
66 dnl a helpful error. FIXME: Unfortunately, configure seems to choke before
67 dnl it gets to us so this code doesn't get a chance to fire.
70 dnl Note: for in-tree builds, the build directory test above will fire
72 AC_MSG_ERROR([You can't build with sources in a directory whose path contains a space])
76 dnl Check the prefix to install in doesn't contain a space, so we die early with
80 AC_MSG_ERROR([You can't install in a directory whose path contains a space])
84 dnl Note if the user specified a particular C++ compiler so we can give a more
85 dnl appropriate error message if we can't link a simple C++ program.
87 if test -n "$CXX" ; then
88 original_CXX="CXX=$CXX"
89 elif test -n "$CCC" ; then
90 original_CXX="CCC=$CCC"
93 dnl See HACKING document for details of the reasons for required versions.
94 AM_INIT_AUTOMAKE([1.13 -Wportability tar-ustar no-dist-gzip dist-xz std-options])
95 AC_CONFIG_SRCDIR([matcher/multiandpostlist.cc])
97 AC_CONFIG_HEADERS([config.h])
99 AC_CONFIG_MACRO_DIRS([m4])
103 dnl Use libtool to manage our libraries.
105 dnl Default to only building shared libraries.
107 dnl Building both shared and static means having to compile the files which
108 dnl make up the library twice on most platforms. Shared libraries are the
109 dnl better option for most users, and if anyone really wants static libraries,
110 dnl they can configure with --enable-static (or --enable-static=xapian-core if
111 dnl configuring a combined tree with the bindings).
113 dnl We don't export any data items from the library, so it should be safe to
114 dnl enable win32-dll without decorating any declarations specially.
115 LT_INIT([disable-static win32-dll])
117 dnl -no-undefined causes problems on Solaris with Sun CC in C++11 mode, so only
118 dnl pass -no-undefined on platforms where it is required in order to link a
119 dnl shared library at all (Windows is the main one).
121 if test unsupported = "$allow_undefined_flag" ; then
122 NO_UNDEFINED=-no-undefined
124 AC_SUBST(NO_UNDEFINED)
128 dnl A standard "gotcha" for mingw and cygwin users is to not set up their
129 dnl PATH correctly, so that MSDOS FIND.EXE is found before Unix find. Help
130 dnl them out by checking for this condition, rather than letting libtool
131 dnl fail in obscure ways. NB check the *BUILD* OS, not the host one!
133 *mingw* | *cygwin* | pw32*)
134 find /dirunlikelytoexist >/dev/null 2>&1
135 if test $? = 2 ; then
136 dnl Unix find will return 1 if the directory didn't exist, or 0 if
139 *** You appear to have an MSDOS-like FIND.EXE in your PATH ahead of any
140 *** UNIX-like find. This misconfiguration will confuse libtool - you'll need
141 *** to make sure you have a UNIX-like find installed and fix your PATH, then
142 *** rerun configure. For more information, see:
144 *** https://www.cygwin.com/faq/faq.html#faq.using.find
150 dnl Add parameters for aclocal
151 dnl (This must come after AM_INIT_AUTOMAKE, since it modifies ACLOCAL)
152 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
154 dnl disable "maintainer only" rules by default
157 dnl Checks for programs.
162 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
164 linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
165 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
166 link_all_deplibs_CXX=no
172 dnl Extract search path from ldconfig which is more reliable than the way
173 dnl vanilla libtool extracts them from ld.so.conf.
174 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
175 test -z "$d" || sys_lib_dlsearch_path_spec=$d
180 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
181 dnl On these platforms, libtool emits a warning if -no-install is passed,
182 dnl and uses -no-fast-install instead - the least ugly way to avoid that
183 dnl warnings seems to be to duplicate the above list of platforms from
184 dnl libtool and use -no-fast-install on them directly.
185 NO_INSTALL=-no-fast-install ;;
187 NO_INSTALL=-no-install ;;
189 AC_SUBST([NO_INSTALL])
191 dnl For reasons which are beyond me, if autoconf can't find a C++ compiler
192 dnl it will set CXX to g++ (which obviously won't work) rather than actually
193 dnl telling the user that it couldn't find a C++ compiler and telling them
194 dnl to either install one or set CXX if there's one configure failed to find.
195 dnl It's probably worthwhile checking that the C++ compiler actually works
197 if test -n "$CXX" ; then
199 AC_MSG_CHECKING([whether $CXX is a working C++ compiler])
200 AC_CACHE_VAL([xo_cv_cxx_works],
202 AC_TRY_RUN([int main() {}],
205 AC_TRY_LINK([], [], xo_cv_cxx_works=yes, xo_cv_cxx_works=no))
207 AC_MSG_RESULT([$xo_cv_cxx_works])
211 if test no = "$xo_cv_cxx_works" ; then
212 case $original_CXX in
214 dnl CCC is handled in a slightly odd way - if its value isn't an
215 dnl executable (taking PATH into account) then it is ignored!
216 test "$original_CXX" = "CCC=$CXX" || original_CXX=
219 if test -z "$original_CXX" ; then
221 *** You need a working C++ compiler to compile Xapian, but configure failed to
222 *** find one. If you have a working C++ compiler, you can tell configure where
223 *** to find it by invoking it like so:
225 *** ./configure CXX=/opt/bin/c++
229 *** You need a working C++ compiler to compile Xapian, but the compiler you
230 *** specified (with '$original_CXX') doesn't appear to be able to successfully
231 *** compile and link a simple program.
236 dnl Probe for any options needed to enable C++11 support.
237 AX_CXX_COMPILE_STDCXX_11
239 dnl We don't use a C compiler to compile Xapian's code, but on some platforms
240 dnl (e.g. mingw) libtool uses $LTCC which defaults to $CC, and it's also use to
241 dnl build auxiliary tools like snowball and lemon.
244 dnl Check endianness.
247 dnl We want a non-cross-compiling C compiler for building lemon with.
248 if test -z "$CC_FOR_BUILD" ; then
249 if test yes = "$cross_compiling"; then
255 AC_ARG_VAR([CC_FOR_BUILD], [C compiler command for native compilation (needed to compile build tools during cross-builds)])
257 dnl Run tests using the C++ compiler.
260 dnl Enable large file support if possible.
262 dnl With xlC on AIX, -D_LARGE_FILES changes the ABI of std::string, so it
263 dnl also needs to be used when compiling user code.
264 abi_affecting_cxxflags=
265 if $GREP '^#define _LARGE_FILES 1$' confdefs.h > /dev/null 2>&1 ; then
266 abi_affecting_cxxflags=-D_LARGE_FILES
268 AC_SUBST([abi_affecting_cxxflags])
270 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
271 #if defined __WIN32__ || defined _WIN32
274 ]])], [win32=no], [win32=yes])
276 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
280 ]])], [msvc=no], [msvc=yes])
284 AC_SUBST([XAPIAN_LDFLAGS])
285 AC_SUBST([XAPIAN_LIBS])
287 AC_DEFUN([XAPIAN_TEST_LINKER_FLAG],
289 AC_MSG_CHECKING([for $CXX -Wl,$1])
290 AC_CACHE_VAL([xo_cv_ldflag_$2],
292 save_LDFLAGS=$LDFLAGS
293 LDFLAGS="$LDFLAGS -Wl,$1"
295 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
300 LDFLAGS=$save_LDFLAGS
302 AC_MSG_RESULT([$xo_cv_ldflag_$2])
305 dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
306 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
307 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
309 XTC_save_CXXFLAGS=$CXXFLAGS
310 CXXFLAGS="$CXXFLAGS $1"
311 AC_TRY_COMPILE([], [],
312 [CXXFLAGS=$XTC_save_CXXFLAGS
315 [CXXFLAGS=$XTC_save_CXXFLAGS
320 if test yesyes = "$GXX$enable_shared" ; then
323 XAPIAN_TEST_LINKER_FLAG([--enable-runtime-pseudo-reloc], [enable_runtime_pseudo_reloc],
324 [ldflags="-Wl,$flag"],
326 dnl Can't use AC_DISABLE_SHARED after AC_PROG_LIBTOOL, but
327 dnl this test needs to be after AC_PROG_LIBTOOL, so we can't
328 dnl just disable the shared build automatically...
329 AC_MSG_ERROR([ld version too old to support a shared build - configure with --disable-shared, or install binutils 2.13.90-20030111-1 or later])
334 dnl Only works for ldflags which can be specified anywhere on the link line.
337 dnl Preserve the default CXXFLAGS.
338 save_CXXFLAGS=$CXXFLAGS
340 dnl x86 has excess precision issues with 387 FP instructions, which are
341 dnl avoided by using SSE instructions instead. This is also faster (~6% in
342 dnl a CPU bound testcase).
344 [AS_HELP_STRING([--disable-sse],
345 [disable use of SSE FP instructions on x86])]
346 [AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
347 [set which SSE FP instructions to use on x86 (default: sse2)])],
348 [case ${enableval} in
350 *) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
354 dnl Some versions of Sun's C++ compiler reportedly need an explicit -lm.
355 dnl The maths functions we use include: exp log ceil fabs sqrt
356 AC_MSG_CHECKING([if -lm is required for maths functions])
357 dnl Don't use constant arguments as the compiler might simply evaluate the
358 dnl whole expression at compile time, and it might inline certain functions
359 dnl so test several functions. Also write results using printf() so that
360 dnl the compiler can't optimise away the computations.
361 AC_TRY_LINK([#ifdef __SUNPRO_CC
362 #error Need -lm for Sun C++ 5.9 under libtool 2.2.10
367 using namespace std;], [
368 double a = log(ceil(time(NULL)/7.0));
369 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));
370 ], [AC_MSG_RESULT([no])], [
372 AC_TRY_LINK([#include <cmath>
375 using namespace std;], [
376 double a = log(ceil(time(NULL)/7.0));
377 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));],
378 [AC_MSG_RESULT([yes])],
379 [AC_MSG_ERROR([Failed to link a C++ program using <cmath>])
383 dnl C++11 should have log2(double), but keep this check for now to allow for
384 dnl compilers with incomplete library support for C++11.
385 AC_CHECK_DECLS([log2(double)], [], [],
387 using namespace std;])
389 dnl exp10() is a GNU libc extension.
390 AC_CHECK_DECLS([exp10(double)], [], [],
392 using namespace std;])
394 dnl Darwin provides __exp10().
395 AC_CHECK_DECLS([__exp10(double)], [], [],
397 using namespace std;])
399 dnl GCC provides __builtin_exp10() (but notably clang doesn't currently).
400 dnl On mingw, __builtin_exp10() causes GCC to generate a call to exp10() which
401 dnl then fails to link, so perform a link check here to catch that.
402 AC_CACHE_CHECK([for __builtin_exp10], ac_cv_link___builtin_exp10, [
403 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
406 using namespace std;]],
407 [[printf("%f", __builtin_exp10(double(time(NULL)*1e-8)));]])],
408 [ac_cv_link___builtin_exp10=yes],
409 [ac_cv_link___builtin_exp10=no])
411 if test $ac_cv_link___builtin_exp10 = yes ; then
412 AC_DEFINE([HAVE___BUILTIN_EXP10], [1], [Define to 1 if you have the `__builtin_exp10' function.])
415 dnl See if <typeinfo> can be used in the testsuite - at least for GCC and xlC,
416 dnl compilation of the test code below fails if RTTI isn't being generated
417 dnl (g++ -fno-rtti, or by default with xlC).
418 AC_MSG_CHECKING([if RTTI is supported])
419 save_CXXFLAGS=$CXXFLAGS
420 dnl xlC issues a warning for typeid() being used without RTTI being enabled,
421 dnl so for this test we pass the xlC option to make that warning into an error.
422 XAPIAN_TEST_CXXFLAGS([-qhaltonmsg=1540-2412], [CXXFLAGS])
425 #include <typeinfo>],
430 } catch (std::exception & e) {
431 return typeid(e).name()[0];
434 AC_DEFINE([USE_RTTI], [1], [Define if the testsuite can use RTTI]),
436 CXXFLAGS=$save_CXXFLAGS
438 AC_CHECK_DECLS([__builtin_bswap16, __builtin_bswap32], [], [], [ ])
439 AC_CHECK_DECLS([_byteswap_ushort, _byteswap_ulong], [], [],
440 [#include <stdlib.h>])
441 AC_CHECK_DECLS([__builtin_clz, __builtin_clzl, __builtin_clzll], [], [], [ ])
442 AC_CHECK_DECLS([__builtin_ctz, __builtin_ctzl, __builtin_ctzll], [], [], [ ])
443 AC_CHECK_DECLS([__builtin_expect], [], [], [ ])
444 AC_CHECK_DECLS([__builtin_popcount, __builtin_popcountl, __builtin_popcountll], [], [], [ ])
445 AC_CHECK_DECLS([__popcnt, __popcnt64], [], [], [#include <intrin.h>])
447 dnl Check for time functions.
448 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
452 dnl For _ftime64() on mingw we need to tell it we're happy to require
453 dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
454 AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
455 AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
459 dnl We use timer_create() if available to implement a search time limit.
461 AC_SEARCH_LIBS([timer_create], [rt],
463 AC_MSG_CHECKING([for timer_create() usability])
464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
465 [[#if defined _AIX || defined __GNU__
466 #error timer_create known not to work
468 [AC_MSG_RESULT([yes])
469 XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"
470 AC_DEFINE([HAVE_TIMER_CREATE], [1], [Define to 1 if you have the 'timer_create' function.])]
477 dnl Used by tests/soaktest/soaktest.cc
478 AC_CHECK_FUNCS([srandom random])
480 dnl Used by tests/harness/testsuite.cc
481 AC_CHECK_FUNCS([sigaction])
482 AC_MSG_CHECKING([for sigsetjmp and siglongjmp])
483 AC_TRY_COMPILE([#include <setjmp.h>],
484 [sigjmp_buf jb; if (sigsetjmp(jb, 1)) { siglongjmp(jb, 1); }],
485 AC_DEFINE([HAVE_SIGSETJMP], [1], [Define to 1 if you have the 'sigsetjmp' function])
486 AC_MSG_RESULT([yes]),
489 dnl Used by tests/harness/cputimer.cc:
490 AC_CHECK_FUNCS([getrusage times sysconf])
492 dnl Used by tests/harness/unixcmd.cc
493 AC_CHECK_FUNCS([nftw])
495 dnl Used by tests/api_replicate.cc.
497 dnl Solaris < 10 only has putenv().
499 dnl Microsoft have marked putenv() as deprecated, so we use _putenv_s() under
500 dnl MSVC to avoid deprecation warnings. We probe here since mingw doesn't
501 dnl currently (v3.20) provide _putenv_s(), so we can't just use it conditional
502 dnl on __WIN32__ being defined. We need to check for a declaration rather
503 dnl than just seeing if the symbol exists, as the symbol will exist in the C
504 dnl runtime DLL even if mingw doesn't declare it in its headers.
505 AC_CHECK_FUNCS([setenv])
506 AC_CHECK_DECLS([_putenv_s(const char *,const char *)], [], [],
507 [#include <stdlib.h>])
509 dnl See if we have closefrom(), or some functions that are useful to implement
510 dnl closefrom() on platforms which don't provide it.
511 AC_CHECK_FUNCS([closefrom getdirentries getrlimit])
513 dnl See if ftime returns void (as it does on mingw)
514 AC_MSG_CHECKING([return type of ftime])
515 if test $ac_cv_func_ftime = yes ; then
516 AC_TRY_COMPILE([#include <sys/timeb.h>],
517 [struct timeb tp; int i = ftime(&tp);],
518 AC_MSG_RESULT([int]),
519 AC_MSG_RESULT([void])
520 AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void]))
523 dnl Check how to find the hostname: uname() in sys/utsname.h, or gethostname()
524 dnl Don't use default includes as inttypes.h is found by Compaq C but not C++
525 dnl so it causes all header probes to fail.
526 AC_CHECK_HEADERS([sys/utsname.h], [], [], [ ])
527 AC_CHECK_FUNCS([gethostname])
529 dnl mingw (for instance) lacks ssize_t
536 AC_CHECK_SIZEOF([short])
537 AC_CHECK_SIZEOF([int])
538 AC_CHECK_SIZEOF([long])
539 AC_CHECK_SIZEOF([long long])
541 AC_CHECK_HEADERS([sys/types.h])
543 AC_MSG_CHECKING([for 32 bit integer type])
545 "$ac_cv_sizeof_int") INT32_T=int ;;
546 "$ac_cv_sizeof_long") INT32_T=long ;;
547 "$ac_cv_sizeof_short") INT32_T=short ;;
549 AC_MSG_RESULT([none found])
550 AC_MSG_ERROR([No 32 bit integer type found])
552 AC_MSG_RESULT([$INT32_T])
554 AC_MSG_CHECKING([for 64 bit integer type])
556 "$ac_cv_sizeof_int") INT64_T=int ;;
557 "$ac_cv_sizeof_long") INT64_T=long ;;
558 "$ac_cv_sizeof_long_long") INT64_T='long long' ;;
560 AC_MSG_RESULT([none found])
561 AC_MSG_ERROR([No 64 bit integer type found])
563 AC_MSG_RESULT([$INT64_T])
565 dnl Check for perl (needed to generate some sources and documentation).
566 AC_PATH_PROG([PERL], [perl], [])
567 if test x$USE_MAINTAINER_MODE = xyes; then
568 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
571 AC_ARG_ENABLE([64bit_docid],
572 [AS_HELP_STRING([--enable-64bit-docid], [enable 64bit docid [default=no]])],
573 [case ${enableval} in
575 *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-docid]) ;;
577 [enable_64bit_docid=no])
579 AC_ARG_ENABLE([64bit_termcount],
580 [AS_HELP_STRING([--enable-64bit-termcount], [enable 64bit termcount [default=no]])],
581 [case ${enableval} in
583 *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termcount]) ;;
585 [enable_64bit_termcount=no])
587 AC_ARG_ENABLE([documentation],
588 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
589 [case ${enableval} in
591 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
593 [enable_documentation=$USE_MAINTAINER_MODE])
594 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
595 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
597 if test x"$enable_documentation" = xyes ; then
598 dnl Checks for dot. (Diagrams in the documentation)
599 AC_PATH_PROG([DOT], [dot])
600 test -z "$DOT" && AC_MSG_ERROR([dot (part of the graphviz package) is required to build documentation])
601 DOXYGEN_DOT_PATH=`echo "$DOT" | sed 's!/dot$!!'`
602 AC_SUBST([DOXYGEN_DOT_PATH])
604 dnl Check for doxygen. (Needed to make some more of the documentation)
605 AC_PATH_PROG([DOXYGEN], [doxygen], [])
606 test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
608 dnl Check for help2man. (Needed to make man pages from "--help" output).
609 AC_PATH_PROG([HELP2MAN], [help2man], [])
610 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
612 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
613 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
614 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
615 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
617 dnl Check for pngcrush, which we optionally use to reduce the size of the
618 dnl PNG files which doxygen generates. We can get by without it, so don't
619 dnl fail here if it's not found.
620 AC_PATH_PROG([PNGCRUSH], [pngcrush], [])
623 dnl Checks for header files.
624 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h sys/uio.h], [], [], [ ])
625 AC_CHECK_HEADERS([sys/resource.h],
626 [], [], [#include <sys/types.h>])
628 dnl cxxabi.h was added in GCC 3.1, but clang lies and defines __GNUC__ yet
629 dnl doesn't seem to reliably provide this header, so probe for it.
630 AC_CHECK_HEADERS([cxxabi.h], [], [], [ ])
632 dnl If valgrind is installed and new enough, we use it for leak checking in the
633 dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
634 dnl don't use valgrind.
635 if test -n "${VALGRIND-unset}" ; then
636 AC_PATH_PROG([VALGRIND], [valgrind], [])
637 if test -n "$VALGRIND" ; then
638 dnl Check that the installed valgrind version works, and supports the
639 dnl options we use. This means we won't try to use valgrind < 3.3.0
640 dnl (released 7/12/2007) since before that --log-file didn't expand
641 dnl %p (and appended the process id).
643 dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
645 AC_MSG_CHECKING([if valgrind supports --log-file with %p and --child-silent-after-fork=yes])
646 vglog=config.vglog.%p.tmp
647 vglogwild="config.vglog.*.tmp*"
649 if $VALGRIND --log-file="$vglog" --child-silent-after-fork=yes -q true 2>&AS_MESSAGE_LOG_FD ; then
650 for f in $vglogwild ; do
652 $vglog*) VALGRIND= ;;
655 if test x"$VALGRIND" = x ; then
659 AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
662 dnl The valgrind detected doesn't seem to work! Perhaps this is an
663 dnl x86_64 box with a 32 bit valgrind.
664 AC_MSG_RESULT([$VALGRIND doesn't work])
671 if test -n "$VALGRIND" ; then
672 AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
675 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
676 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
678 if test -n "${EATMYDATA-unset}" ; then
679 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
682 dnl Checks for library functions.
686 AC_CACHE_CHECK([for sys_errlist and sys_nerr], ac_cv_sys_errlist_and_sys_nerr, [
687 AC_LINK_IFELSE([AC_LANG_PROGRAM(
688 dnl On Linux, sys_errlist and sys_nerr need <stdio.h>, though the man page
689 dnl says <errno.h>. The man page seems to match other platforms such as
690 dnl NetBSD, so include both headers to ensure we get them.
692 #include <stdio.h>]],
693 [[ printf("%s", sys_errlist[sys_nerr - 1]);]])],
694 [ ac_cv_sys_errlist_and_sys_nerr=yes ],
695 [ ac_cv_sys_errlist_and_sys_nerr=no ])
697 if test "x$ac_cv_sys_errlist_and_sys_nerr" = "xyes" ; then
698 AC_DEFINE([HAVE_SYS_ERRLIST_AND_SYS_NERR], [1],[Define if you have 'sys_errlist' and 'sys_nerr'])
701 AC_CACHE_CHECK([for _sys_errlist and _sys_nerr], ac_cv__sys_errlist_and__sys_nerr, [
702 AC_LINK_IFELSE([AC_LANG_PROGRAM(
704 #include <stdio.h>]],
705 [[ printf("%s", _sys_errlist[_sys_nerr - 1]);]])],
706 [ ac_cv__sys_errlist_and__sys_nerr=yes ],
707 [ ac_cv__sys_errlist_and__sys_nerr=no
710 if test "x$ac_cv__sys_errlist_and__sys_nerr" = "xyes" ; then
711 AC_DEFINE([HAVE__SYS_ERRLIST_AND__SYS_NERR], [1],[Define if you have '_sys_errlist' and '_sys_nerr'])
714 dnl Check that snprintf actually works as it's meant to.
716 dnl Linux 'man snprintf' warns:
717 dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
718 dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
719 dnl size argument. Thus, the use of snprintf with early libc4 leads to
720 dnl serious security problems.
722 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C99
723 dnl implementations) return -1 when truncating so check that we get the
724 dnl ISO C99 semantics for the returned length when truncating. If we
725 dnl have a working snprintf but with non-ISO return semantics, handle
726 dnl that case separately as it may still be useful in many cases.
728 dnl mingw has _snprintf so check for that too.
729 AC_MSG_CHECKING([for working ISO C99 conforming snprintf])
730 ac_cv_func_snprintf_noniso=no
731 for func in snprintf _snprintf ; do
739 dnl Return different exit status for each error so we can see which
740 dnl check failed by consulting config.log.
742 char buffer[4] = "abc";
743 int res1 = $func(buffer, 2, "%s", "XYZ");
744 if (memcmp(buffer, "X\0c", 4) != 0) return 2;
745 int res2 = $func(buffer, 2, "%x", 0x12);
746 if (memcmp(buffer, "1\0c", 4) != 0) return 3;
747 if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
748 if (res1 != 3) return 4;
749 if (res2 != 2) return 5;
752 [ac_cv_func_snprintf=$func;break],
754 if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
755 ac_cv_func_snprintf_noniso=$func
757 ac_cv_func_snprintf=no
759 [ac_cv_func_snprintf=unknown;break]
762 AC_MSG_RESULT([$ac_cv_func_snprintf])
763 case $ac_cv_func_snprintf in
765 AC_MSG_CHECKING([for working non-ISO C99 conforming snprintf])
766 AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
767 if test no != "$ac_cv_func_snprintf_noniso" ; then
768 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
769 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
773 dnl be conservative when crosscompiling
776 AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
777 [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
778 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
779 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
783 dnl ***************************
784 dnl * Select modules to build *
785 dnl ***************************
787 dnl Check if a non-GPL library build is specified.
789 AC_ARG_ENABLE([gpl-libxapian],
790 [AS_HELP_STRING([--disable-gpl-libxapian], [disable use of GPL code in libxapian])],
791 [case ${enableval} in
794 AC_DEFINE([DISABLE_GPL_LIBXAPIAN], 1, [Define to error out if we try to include GPL code in libxapian])
796 *) AC_MSG_ERROR([bad value ${enableval} for --disable-gpl-libxapian]) ;;
799 dnl Check which database backends should be built.
801 AC_DEFUN([_XAPIAN_BACKEND_ENABLE],
802 [AC_ARG_ENABLE([backend_$1],
803 [AS_HELP_STRING([--enable-backend-$1], [build the $1 database backend [default=$3]])],
806 *) AC_MSG_ERROR([Invalid option: '--enable-backend-$1=$enableval']) ;;
807 esac], [enable_backend_$1=$2])
810 AC_DEFUN([XAPIAN_BACKEND_ENABLE],
811 [_XAPIAN_BACKEND_ENABLE([$1],
812 m4_default([$2], [yes]),
813 m4_default([$3], [yes]))
816 dnl When adding a new backend, update INSTALL too.
817 XAPIAN_BACKEND_ENABLE([glass], [$enable_gpl_libxapian], [yes (unless --disable-gpl-libxapian)])
818 XAPIAN_BACKEND_ENABLE([honey])
819 XAPIAN_BACKEND_ENABLE([inmemory], [$enable_gpl_libxapian], [yes (unless --disable-gpl-libxapian)])
820 default_enable_backend_remote=$enable_gpl_libxapian
823 dnl We don't currently support the remote backend on this platform so
824 dnl disable it by default.
825 default_enable_backend_remote=no
828 XAPIAN_BACKEND_ENABLE([remote], [$default_enable_backend_remote], [yes (except for MSDOS; unless --disable-gpl-libxapian)])
833 case $enable_backend_glass$enable_backend_honey in
835 dnl We use zlib for compressing tags in glass and honey. We could
836 dnl automatically disable support if zlib isn't found, but overall that
837 dnl probably does more harm than good - it's most likely that someone just
838 dnl forgot to install the -dev package for zlib.
840 dnl Similarly for uuid support.
842 dnl Check for zlib.h.
843 AC_CHECK_HEADERS([zlib.h], [], [
844 AC_MSG_ERROR([zlib.h not found - required for glass (you may need to install the zlib1g-dev or zlib-devel package)])
847 dnl Check for zlibVersion in -lz.
849 dnl mingw build needs -lzlib or -lzdll.
850 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
851 AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll - required for glass (you may need to install the zlib1g-dev or zlib-devel package)])
853 if test x != x"$LIBS" ; then
854 XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
858 dnl Find the UUID library (from e2fsprogs/util-linux-ng, not the OSSP one).
860 case $host_os-$win32 in
861 *-yes | *cygwin*) dnl Use built-in win32 API.
863 AC_DEFINE([USE_WIN32_UUID_API], [1],
864 [Define to 1 to use UuidCreate(), etc])
865 if test $win32 = yes ; then
866 dnl We need -lws2_32 for htonl(), etc, but not for Cygwin which
867 dnl provides these functions in its libc.
870 XAPIAN_LIBS="$XAPIAN_LIBS -lrpcrt4"
873 dnl Check for uuid/uuid.h (e2fsprogs/util-linux-ng) or uuid.h
874 dnl (FreeBSD/NetBSD).
875 AC_CHECK_HEADERS([uuid/uuid.h], [
876 dnl util-linux-ng's uuid/uuid.h found - check for uuid_generate in
879 AC_SEARCH_LIBS([uuid_generate], [uuid], [], [
880 AC_MSG_ERROR([uuid_generate() not found in -luuid - required for glass and honey backends (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
882 if test x != x"$LIBS" ; then
883 XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
886 dnl Try uuid.h as found on FreeBSD/NetBSD, with associated code in libc.
887 AC_CHECK_HEADERS([uuid.h], [
888 dnl Check for uuid_create with no extra libraries required.
889 AC_CHECK_FUNC([uuid_create], [], [
890 AC_MSG_ERROR([uuid.h found, but uuid_create() not found. You probably wants to install libuuid from util-linux-ng or e2fsprogs (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
893 dnl Especially useful for Android.
894 AC_MSG_CHECKING([if host platform supports /proc/sys/kernel/random/uuid])
898 AC_DEFINE([USE_PROC_FOR_UUID], [1],
899 [Define to 1 to read UUID from '/proc/sys/kernel/random/uuid'])
904 AC_MSG_ERROR([Failed to find a way to generate UUIDs, required for glass and honey backends (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
912 dnl Older versions of libuuid (such as that on CentOS 4.7) don't have
913 dnl uuid_unparse_lower(), only uuid_unparse().
914 AC_LINK_IFELSE([AC_LANG_CALL([], [uuid_unparse_lower])],
916 AC_DEFINE([HAVE_UUID_UNPARSE_LOWER], [1],
917 [Define to 1 if you have the 'uuid_unparse_lower' function.])
923 dnl DJGPP has a dummy implementation of fork which always fails.
925 dnl For disk-based backends, use flock() for locking, which doesn't need
926 dnl fork() or socketpair().
927 AC_DEFINE([FLINTLOCK_USE_FLOCK], 1, [Define to use flock() for flint-compatible locking])
932 AM_CONDITIONAL([USE_PROC_FOR_UUID], [test "$use_proc_for_uuid" = 1])
933 AM_CONDITIONAL([USE_WIN32_UUID_API], [test "$use_win32_uuid_api" = 1])
935 if test "$enable_backend_remote" = yes ; then
936 case $host_os-$win32 in
938 dnl For mingw and msvc we have an alternative implementation which
939 dnl doesn't need fork() or socketpair().
941 dnl We need -lws2_32 for getaddrinfo(), etc.
943 dnl Vista is needed for the AI_ADDRCONFIG flag to getaddrinfo().
944 AC_DEFINE([WINVER], [0x600],
945 [Version of Windows to assume (0x600 => Vista).])
946 AC_DEFINE([_WIN32_WINNT], [WINVER],
947 [Version of Windows to assume.])
950 dnl DJGPP has a dummy implementation of fork which always fails. If
951 dnl someone actually wanted remote backend support, then DJGPP has a
952 dnl pthreads port, so using threads like we do on Windows would make more
954 AC_MSG_ERROR([The remote backend is not currently supported on this platform.])
957 dnl On Unix, we need fork and socketpair for the remotebackend.
959 AC_CHECK_FUNCS([fork], [], [
960 AC_MSG_ERROR([fork() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
962 dnl Check if -lsocket is required for socketpair (Solaris needs it).
963 dnl And on Haiku it's in -lnetwork.
964 AC_SEARCH_LIBS([socketpair], [socket network], [], [
965 AC_MSG_ERROR([socketpair() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
967 AC_DEFINE([HAVE_SOCKETPAIR], [1],
968 [Define to 1 if you have the 'socketpair' function.])
969 dnl Check if extra libraries are needed for getaddrinfo or inet_ntop()
970 dnl (e.g. on Solaris).
972 dnl We're currently assuming that any system that is worth trying to
973 dnl support has getaddrinfo() and inet_ntop(), since these are the
974 dnl standard route for supporting IPv6, and that's pretty much essential
975 dnl for platforms to support now.
976 AC_SEARCH_LIBS([getaddrinfo], [nsl socket], [], [
977 AC_MSG_ERROR([getaddrinfo() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
979 AC_SEARCH_LIBS([inet_ntop], [nsl socket], [], [
980 AC_MSG_ERROR([inet_ntop() required for the remote backend - if an extra library is needed, pass LIBS=-lfoo to configure. Or --disable-backend-remote to disable it.)])
982 XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
990 if test "$win32_need_lws2_32" = 1 ; then
991 XAPIAN_LIBS="$XAPIAN_LIBS -lws2_32"
994 AC_ARG_ENABLE([visibility],
995 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
996 [case ${enableval} in
998 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
1002 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
1005 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
1007 dnl Turn off compilation of anything that we don't have the requirements for
1009 dnl Set conditionals to specify what we compile
1011 AM_CONDITIONAL([BUILD_BACKEND_GLASS], [test yes = "$enable_backend_glass"])
1012 AM_CONDITIONAL([BUILD_BACKEND_HONEY], [test yes = "$enable_backend_honey"])
1013 AM_CONDITIONAL([BUILD_BACKEND_INMEMORY], [test yes = "$enable_backend_inmemory"])
1014 AM_CONDITIONAL([BUILD_BACKEND_REMOTE], [test yes = "$enable_backend_remote"])
1015 AM_CONDITIONAL([BUILD_BACKEND_TOOLS],
1016 [test nono != "$enable_backend_glass$enable_backend_honey"])
1018 dnl Decide if we should use the zlib-vg.so LD_PRELOAD hack.
1020 if test -n "$VALGRIND" ; then
1022 linux*) use_zlib_vg=yes ;;
1025 AM_CONDITIONAL([USE_ZLIB_VG], [test yes = "$use_zlib_vg"])
1027 dnl See if we have fdatasync, and what libraries are needed for it.
1028 dnl We need to actually check for a declaration as OS X has a dummy
1029 dnl implementation in the library which is not prototyped in any header.
1030 AC_CHECK_DECL([fdatasync(int)], [
1032 AC_SEARCH_LIBS([fdatasync], [rt], [XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"])
1034 AC_CHECK_FUNCS([fdatasync])
1036 [ac_cv_func_fdatasync=no],
1037 [#include <unistd.h>]
1040 AC_CHECK_FUNCS([fsync writev])
1041 AC_CHECK_FUNCS([posix_fadvise])
1042 if test "$win32" = no ; then
1043 dnl ftruncate() under Wine seems to be buggy and sometimes fails, though
1044 dnl a cut-down reproducer seems fine. For now just avoid ftruncate()
1045 dnl entirely on this platform - we'll fallback to lseek() + write() of a
1046 dnl single zero byte, which is pretty efficient.
1047 AC_CHECK_FUNCS([ftruncate])
1050 dnl HP-UX has pread and pwrite, but they don't work! Apparently this problem
1051 dnl manifests when largefile support is enabled, and we definitely want that
1052 dnl so don't use pread or pwrite on HP-UX.
1055 AC_MSG_CHECKING([for pread])
1056 AC_MSG_RESULT([present but broken on $host_os])
1057 AC_MSG_CHECKING([for pwrite])
1058 AC_MSG_RESULT([present but broken on $host_os])
1061 AC_CHECK_FUNC([pread],
1062 [AC_DEFINE([HAVE_PREAD], [1],
1063 [Define if pread is available on this system])
1064 AC_MSG_CHECKING([for any prototype needed for pread])
1065 AC_CACHE_VAL([xo_cv_pread_prototype],
1068 'extern "C" ssize_t pread(int, void *, size_t, off_t) throw ();' \
1069 'extern "C" ssize_t pread(int, void *, size_t, off_t);' ; do
1071 #include <sys/types.h>
1076 pread(1, b, 256, 20);
1078 xo_cv_pread_prototype="$p"
1082 if test -z "$xo_cv_pread_prototype"; then
1083 AC_MSG_RESULT([not found])
1084 AC_MSG_ERROR([Failed to find working prototype for pread])
1087 if test " " = "$xo_cv_pread_prototype" ; then
1088 AC_MSG_RESULT([none required])
1090 AC_MSG_RESULT([$xo_cv_pread_prototype])
1091 AC_DEFINE_UNQUOTED([PREAD_PROTOTYPE], [$xo_cv_pread_prototype],
1092 [explicit prototype needed for pread (if any)])
1095 AC_CHECK_FUNC([pwrite],
1096 [AC_DEFINE([HAVE_PWRITE], [1],
1097 [Define if pwrite is available on this system])
1098 AC_MSG_CHECKING([for any prototype needed for pwrite])
1099 AC_CACHE_VAL([xo_cv_pwrite_prototype],
1102 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t) throw ();' \
1103 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t);' ; do
1105 #include <sys/types.h>
1109 const char *p = "hello";
1110 pwrite(1, p, 5, 20);
1112 xo_cv_pwrite_prototype="$p"
1116 if test -z "$xo_cv_pwrite_prototype"; then
1117 AC_MSG_RESULT([not found])
1118 AC_MSG_ERROR([Failed to find working prototype for pwrite])
1121 if test " " = "$xo_cv_pwrite_prototype" ; then
1122 AC_MSG_RESULT([none required])
1124 AC_MSG_RESULT([$xo_cv_pwrite_prototype])
1125 AC_DEFINE_UNQUOTED([PWRITE_PROTOTYPE], [$xo_cv_pwrite_prototype],
1126 [explicit prototype needed for pwrite (if any)])
1132 AC_MSG_CHECKING([for directory separator(s)])
1133 case $host_os-$win32 in
1134 *-yes | cygwin* | os2* | *djgpp* | *msdos* )
1135 AC_MSG_RESULT([/ and \\])
1136 AC_DEFINE([DIR_SEPS], ["/\\"], [directory separator(s) as a character or string literal])
1137 AC_DEFINE([DIR_SEPS_LIST], [{ '/', '\\' }], [directory separator(s) as an initialiser list])
1141 AC_DEFINE([DIR_SEPS], ['/'], [directory separator(s) as a character or string literal])
1142 AC_DEFINE([DIR_SEPS_LIST], [{ '/' }], [directory separator(s) as an initialiser list])
1146 AC_CHECK_FUNCS([link])
1148 dnl *************************
1149 dnl * Set debugging options *
1150 dnl *************************
1152 dnl Which assertion types to enable in the code.
1154 AC_ARG_ENABLE([assertions],
1155 [AS_HELP_STRING([--enable-assertions], [enable debug assertions (no|partial|yes) [default=no]])],
1159 AC_MSG_ERROR([Invalid option: '--enable-assertions=$enableval']) ;;
1162 AC_ARG_ENABLE([log],
1163 [AS_HELP_STRING([--enable-log], [generate a log of methods called, etc (no|yes|profile) [default=no]])],
1167 AC_MSG_ERROR(['--enable-log=profile' is no longer supported - see https://trac.xapian.org/wiki/ProfilingXapian for alternatives.]) ;;
1169 AC_MSG_ERROR([Invalid option: '--enable-log=$enableval']) ;;
1172 dnl Set defines according to the --enable-assertions and --enable-log options
1175 if test yes = "$enable_assertions" || test partial = "$enable_assertions" ; then
1176 AC_DEFINE([XAPIAN_ASSERTIONS],,
1177 [Define if you want assertions (causes some slow-down)])
1180 if test yes = "$enable_assertions"; then
1181 AC_DEFINE([XAPIAN_ASSERTIONS_PARANOID],,
1182 [Define if you want paranoid assertions (causes significant slow-down)])
1185 if test yes = "$enable_log"; then
1186 AC_DEFINE([XAPIAN_DEBUG_LOG],,
1187 [Define if you want a log of methods called and other debug messages])
1190 dnl ******************************
1191 dnl * Set special compiler flags *
1192 dnl ******************************
1194 dnl Set flags to control warnings (enable more, or disable annoying ones).
1196 if test yes = "$GXX"; then
1197 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
1198 dnl we actually have, as neither is really 100% compatible.
1199 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
1200 *__INTEL_COMPILER*__clang__*)
1201 dnl GCC (since neither substituted):
1203 dnl The exact format of g++ --version seems to change with almost every
1204 dnl minor release so use the preprocessor macros which should be more
1206 AC_MSG_CHECKING([for version of $CXX])
1207 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
1208 AC_MSG_RESULT([GCC $gxx_version])
1210 case $gxx_version in
1211 [[0123]].*|4.[[0-7]].*)
1212 AC_MSG_ERROR([Xapian requires GCC 4.8 or later])
1216 dnl -Wundef was supported by g++ 3.0.
1218 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
1221 dnl -Wdouble-promotion was added in GCC 4.6.
1223 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
1224 dnl warns for this case with -Wuninitialized (implied by -W). We
1225 dnl don't intend to use this idiom, so any instances are bugs we'd
1226 dnl like to know about.
1228 dnl All the other options were supported by g++ 2.95.
1229 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual -Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -Wlogical-op -Wmissing-declarations -Wdouble-promotion -Winit-self"
1232 dnl -Wconversion in older GCC versions is intended to help migration
1233 dnl from K&R to ISO C, and isn't useful for us. In 4.3 it was renamed
1234 dnl to -Wtraditional-conversion and a new -Wconversion added which
1235 dnl sounds useful but is a bit buggy currently. So we should consider
1236 dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
1238 dnl -Wold-style-cast is interesting, but triggers for macros from
1239 dnl system headers (e.g. FD_SET). GCC 4.8 improved this by making
1240 dnl -ftrack-macro-expansion=2 the default, but we still see such
1241 dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
1242 dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
1243 dnl warnings from zlib.h).
1245 dnl Automatically add -Werror if maintainer mode is enabled.
1246 if test x$USE_MAINTAINER_MODE = xyes; then
1247 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1251 dnl Intel's compiler (since __clang__ not substituted):
1253 dnl -w1 stops the avalanche of uninteresting "remark" messages.
1254 dnl -wd... disables warnings which don't have good code workarounds.
1255 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
1257 dnl Automatically add -Werror if maintainer mode is enabled.
1258 if test x$USE_MAINTAINER_MODE = xyes; then
1259 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1263 dnl clang (since __INTEL_COMPILER not substituted):
1265 dnl These options all work at least as far back as clang++ 3.0:
1266 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual -Wshadow -Wstrict-overflow=1 -Wmissing-declarations -Winit-self"
1268 dnl Automatically add -Werror if maintainer mode is enabled.
1269 if test x$USE_MAINTAINER_MODE = xyes; then
1270 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1275 if test no != "$enable_visibility"; then
1276 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1277 dnl supported on mingw and visibility attributes result in warnings).
1278 AC_MSG_CHECKING([if $CXX -fvisibility=hidden -fvisibility-inlines-hidden works])
1279 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
1280 AC_MSG_RESULT([yes])
1281 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
1282 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
1288 dnl Not GCC, nor a compiler masquerading as GCC.
1291 dnl +w turns on more warnings.
1292 dnl +wlint turns on "lint-like" warnings.
1293 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
1294 dnl 2340 (remark) "value copied to temporary, reference to temporary
1295 dnl use", in: throw Xapian::UnimplementedError("...");
1296 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
1297 dnl virtual destructor for intrusive_base, since we never delete
1298 dnl its subclasses by a intrusive_base *).
1299 dnl 3348 "declaration hides constant ..." which seems to misfire!
1300 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
1301 dnl alignment boundary".
1302 dnl 4273 "floating-point equality and inequality comparisons may be
1303 dnl inappropriate due to roundoff common in floating-point computation"
1304 dnl No obvious workaround for when you really do want == or !=.
1305 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
1306 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,20201" ;;
1308 dnl Sun's C++ compiler warns about functions failing to return a value even
1309 dnl when the function ends with a "throw" statement. That's just unhelpful
1310 dnl noise, and adding a dummy "return" after "throw" seems a worse solution
1311 dnl than simply disabling this warning - any genuinely missing return
1312 dnl statements will get reported by compilers with superior warning
1314 XAPIAN_TEST_CXXFLAGS([-erroff=voidretw], [AM_CXXFLAGS])
1319 XAPIAN_TEST_LINKER_FLAG([-Bsymbolic-functions], [symbolic_functions],
1320 [XAPIAN_LDFLAGS="$XAPIAN_LDFLAGS $flag"])
1322 FP_EXCESS_PRECISION=no
1323 AC_MSG_CHECKING([whether to use SSE instructions on x86])
1326 if test "$enable_sse" = no ; then
1328 FP_EXCESS_PRECISION=yes
1330 dnl Default to sse2.
1331 test "$enable_sse" != yes || enable_sse=sse2
1332 if test yes = "$GXX"; then
1333 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1334 dnl We can unconditionally use -mtune=generic as it was added in GCC
1335 dnl 4.2, and supported at least as far back as clang 3.0.
1336 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic"
1338 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1339 [[#ifndef __SUNPRO_CC
1340 #error Not Sun compiler
1342 [AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1343 AM_CXXFLAGS="$AM_CXXFLAGS -xarch=$enable_sse"]
1345 [AC_MSG_RESULT([don't know how to for compiler $CXX])
1346 FP_EXCESS_PRECISION=yes]
1352 AC_MSG_RESULT([non-x86 arch ($host_cpu)]) ;;
1354 AC_SUBST([FP_EXCESS_PRECISION])
1357 [/* Disable stupid MSVC warnings. */
1359 /* Passing an empty parameter to a single parameter macro. */
1360 # pragma warning(disable:4003)
1361 /* A "performance" warning for converting int to bool. */
1362 # pragma warning(disable:4800)
1364 /* Tell MSVC we want M_PI, etc defined. */
1365 # define _USE_MATH_DEFINES
1367 /* Tell MSVC we don't want max() and min() macros defined. */
1371 /* Make the POSIX-like functions support large files. MSVC needs this;
1372 * current mingw32 does too; mingw64 supports _FILE_OFFSET_BITS, which
1373 * AC_SYS_LARGEFILE should discover and enable automatically.
1375 #if defined _MSC_VER || \
1376 (defined __MINGW32__ && !defined _FILE_OFFSET_BITS)
1378 # include <sys/stat.h>
1379 # include <sys/types.h>
1381 /* zlib.h uses off_t so we need to include it before we redefine off_t. */
1384 // MSVC needs to call _stat64() instead of stat() and the struct which holds
1385 // the information is "struct _stat64" instead of "struct stat" so we just
1386 // use #define to replace both in one go. We also want to use _fstat64()
1387 // instead of fstat() but in this case we can use a function-like macro.
1389 // Mingw has _stat64() but unhelpfully for our purposes, it has an extra
1390 // underscore prefix on the struct name ("struct __stat64") so there we
1391 // target _stati64 instead. This has 64-bit file size but the time_t size
1392 // is switchable. We don't really care about file timestamps in the
1393 // library, so this should be fine.
1395 // This hack is a problem is we ever want a method called "stat", or one called
1396 // fstat which takes 2 parameters, but we can probably live with these
1408 # define stat _stat64
1409 # define fstat(FD, BUF) _fstat64(FD, BUF)
1411 # define stat _stati64
1412 # define fstat(FD, BUF) _fstati64(FD, BUF)
1423 # define lseek(FD, OFF, WHENCE) _lseeki64(FD, OFF, WHENCE)
1424 /* Redefine via a typedef so C++ code off_t(-1) works - it wouldn't if we did:
1425 * #define off_t long long
1427 typedef long long off_t_redefinition_typedef;
1428 # define off_t off_t_redefinition_typedef
1432 /* MSVC defines _WIN32 but not __WIN32__. */
1433 #if !defined __WIN32__ && defined _WIN32
1437 /* MSVC defines _WIN64 but not __WIN64__. */
1438 #if !defined __WIN64__ && defined _WIN64
1442 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
1443 * shouldn't cause a problem to define it where it's not supported and some
1444 * distros may have backported support, so hardcoding version checks is
1445 * counter-productive.
1447 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
1448 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
1450 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
1451 # define _FORTIFY_SOURCE 2
1454 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
1455 * we can use __builtin_expect to give the compiler hints about branch
1456 * prediction. See HACKING for how to use these.
1458 #if HAVE_DECL___BUILTIN_EXPECT
1459 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
1460 * the first argument is always an integer expression, and always 0 or 1, but
1461 * still has the same truth value for the if or while it is used in.
1463 # define rare(COND) __builtin_expect(!!(COND), 0)
1464 # define usual(COND) __builtin_expect(!!(COND), 1)
1466 # define rare(COND) (COND)
1467 # define usual(COND) (COND)
1470 /* Signal we're building the library so it's OK to include headers such as
1471 * xapian/query.h directly.
1473 #define XAPIAN_LIB_BUILD 1
1475 /* With Sun CC 5.13 (Studio 12.4) on Solaris 11.2, <math.h> seems to get
1476 * implicitly included somehow before <cmath>, and compilation fails due
1477 * to 'std::exception' colliding with 'struct exception'. It's not clear
1478 * how to avoid this, so just define the same magic macro which <cmath> does
1479 * before it includes <math.h>.
1482 # define __MATHERR_RENAME_EXCEPTION
1486 AC_SUBST([AM_CXXFLAGS])
1488 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1489 CXXFLAGS=$save_CXXFLAGS
1491 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1492 : ${AUTOM4TE=autom4te}
1493 AC_SUBST([AUTOM4TE])
1495 dnl Libtool sets this (to yes|no|unknown) and we use it in xapian-config.
1496 AC_SUBST([link_all_deplibs_CXX])
1498 dnl Shared library extension.
1500 eval "SHLIBEXT=$shrext_cmds"
1501 AC_SUBST([SHLIBEXT])
1503 dnl We want to be able to use GNU make % pattern rules in maintainer targets
1504 dnl but automake warns these aren't portable, so we substitute the % to avoid
1509 dnl Split up the version number into "MAJOR.MINOR.REVISION".
1510 MAJOR_VERSION=`echo "$VERSION"|sed 's/\..*//'`
1511 [MINOR_VERSION=`echo "$VERSION"|sed 's/[^.]*\.//;s/\..*//'`]
1512 [REVISION=`echo "$VERSION"|sed 's/.*\.//;s/_.*$//'`]
1514 dnl **************************
1515 dnl * Build the output files *
1516 dnl **************************
1522 docs/doxygen_api.conf
1523 docs/doxygen_source.conf
1525 cmake/xapian-config.cmake
1526 cmake/xapian-config-version.cmake
1527 pkgconfig/xapian-core"$LIBRARY_VERSION_SUFFIX".pc:pkgconfig/xapian-core.pc.in
1529 AC_CONFIG_FILES([tests/runtest], [chmod +x tests/runtest])
1530 AC_CONFIG_FILES([tests/runsrv], [chmod +x tests/runsrv])
1531 AC_CONFIG_FILES([tests/submitperftest], [chmod +x tests/submitperftest])
1532 AC_CONFIG_FILES([tests/perftest/get_machine_info], [chmod +x tests/perftest/get_machine_info])
1533 AC_CONFIG_FILES([xapian-config], [chmod +x xapian-config])
1534 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
1537 dnl There are no files generated by AC_OUTPUT in the following directories
1538 dnl and we need to ensure they exist so that the rest of configure or make
1539 dnl won't fail because they don't exist when srcdir != builddir.
1540 if test yes = "$vpath_build" ; then
1541 for dir in include/xapian languages queryparser ; do
1542 AS_MKDIR_P(["$dir"])
1546 dnl Generate include/xapian/version.h:
1548 dnl MAIN_VERSION is VERSION without any _git123 suffix.
1549 MAIN_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$REVISION"
1551 for backend in GLASS HONEY INMEMORY REMOTE ; do
1552 val=`eval echo "\\\$BUILD_BACKEND_${backend}_TRUE"`
1553 if test -z "$val" ; then
1554 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_${backend}_BACKEND"
1558 if test yes = "$enable_64bit_docid" ; then
1559 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_DOCID_BASE_TYPE="`echo "$INT64_T"|sed 's/ /____/g'`
1561 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_DOCID_BASE_TYPE="`echo "$INT32_T"|sed 's/ /____/g'`
1564 if test yes = "$enable_64bit_termcount" ; then
1565 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMCOUNT_BASE_TYPE="`echo "$INT64_T"|sed 's/ /____/g'`
1567 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMCOUNT_BASE_TYPE="`echo "$INT32_T"|sed 's/ /____/g'`
1570 dnl Always ought to be 64 bit.
1571 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TOTALLENGTH_TYPE="`echo "unsigned $INT64_T"|sed 's/ /____/g'`
1573 dnl Make revision numbers in the API 64 bit for future-proofing.
1574 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_REVISION_TYPE="`echo "unsigned $INT64_T"|sed 's/ /____/g'`
1576 dnl For GCC (and compilers which pretend to be GCC) and MSVC, we create some
1577 dnl ABI checks in the generated version.h, and $CXXFLAGS may contain options
1578 dnl which affect the ABI (e.g. -fabi-version for GCC) so we want to use these
1579 dnl options when generating version.h. For these compilers, CXXCPP="$CXX -E"
1580 dnl so it should understand all compiler options.
1582 dnl For other compilers, we only pass $CPPFLAGS to $CXXCPP in case it's an
1583 dnl external cpp which doesn't understand flags which might be in $CXXFLAGS.
1584 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
1590 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS $CXXFLAGS"],
1591 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS"])
1592 rm -f include/xapian/version.h.tmp
1593 dnl "\r" in sed is a GNUism, but we only need to remove it on MS Windows
1594 dnl where we'll always have GNU sed, and other sed's will just interpret
1595 dnl it as "r" (Solaris sed) or maybe literal "\r" which won't match.
1597 dnl Use @@ around $MAIN_VERSION so we get " in the final output.
1598 $CXXCPP $cxxcpp_flags\
1599 -DSTRING_VERSION="\"@@$MAIN_VERSION@@\""\
1600 -DMAJOR_VERSION="\"$MAJOR_VERSION\""\
1601 -DMINOR_VERSION="\"$MINOR_VERSION\""\
1602 -DREVISION="\"$REVISION\""\
1604 $srcdir/include/xapian/version_h.cc|\
1605 ${SED-sed} '0,/const char \* dummy/d;/"/!d;s/^ *//;/^#/d;s/ *$//;s/" *,//;s/"//g;s/@@/"/g;s/ */ /g;s/ *,\r$//;s/ *,$//;s/____/ /g;s/\\\\$/\\/'\
1606 > include/xapian/version.h.tmp
1607 dnl Only update the file if it has changed, so we don't alter the timestamp
1608 dnl and cause lots of rebuilding needlessly. However, the build system
1609 dnl needs a timestamp to know when to regenerate version.h because version_h.cc
1610 dnl has changed so we use a separate timestamp file.
1611 touch include/xapian/version.h.timestamp
1612 if cmp include/xapian/version.h.tmp include/xapian/version.h >/dev/null 2>&1
1614 rm include/xapian/version.h.tmp
1616 mv include/xapian/version.h.tmp include/xapian/version.h