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.4.19], [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 libxapian:
32 dnl 29:1:7 1.2.23 No API changes (except new inline methods)
33 dnl 30:0:0 1.4.0 Extensive API changes
34 dnl 31:0:1 1.4.1 New Weight subclasses, etc
35 dnl 32:0:2 1.4.2 Database::get_document() with flags
36 dnl 33:0:3 1.4.3 Database::locked() method
37 dnl 33:1:3 1.4.4 No API changes
38 dnl 34:0:4 1.4.5 Database::get_total_length() method
39 dnl 35:0:5 1.4.6 C++11 move support added
40 dnl 35:1:5 1.4.7 No API changes
41 dnl 36:0:6 1.4.8 STEM_SOME_FULL_POS added
42 dnl 36:1:6 1.4.9 No API changes
43 dnl 37:0:7 1.4.10 Added DatabaseClosedError, etc
44 dnl 38:0:8 1.4.11 Added SNIPPET_CJK_NGRAM
45 dnl 39:0:9 1.4.12 Database::size() method
46 dnl 39:1:9 1.4.13 No API changes
47 dnl 40:0:10 1.4.14 Xapian::Stem changes
48 dnl 40:1:10 1.4.15 No API changes
49 dnl 40:2:10 1.4.16 No API changes
50 dnl 40:3:10 1.4.17 No API changes (except a new inlined method)
51 dnl 41:0:11 1.4.18 QueryParser::FLAG_ACCUMULATE
52 dnl 42:0:12 1.4.19 QueryParser::FLAG_NO_POSITIONS
53 LIBRARY_VERSION_INFO=42:0:12
54 AC_SUBST([LIBRARY_VERSION_INFO])
56 LIBRARY_VERSION_SUFFIX=
57 AC_SUBST([LIBRARY_VERSION_SUFFIX])
59 dnl Disabled for stable release series.
60 test x"$program_suffix" != xNONE || program_suffix=
62 dnl Where xapian.h, etc go. In development release append "/xapian-1.3".
66 dnl Check the build directory doesn't contain a space, so we die early with
70 AC_MSG_ERROR([You can't build in a directory whose path contains a space])
74 dnl Check the source directory doesn't contain a space, so we die early with
75 dnl a helpful error. FIXME: Unfortunately, configure seems to choke before
76 dnl it gets to us so this code doesn't get a chance to fire.
79 dnl Note: for in-tree builds, the build directory test above will fire
81 AC_MSG_ERROR([You can't build with sources in a directory whose path contains a space])
85 dnl Check the prefix to install in doesn't contain a space, so we die early with
89 AC_MSG_ERROR([You can't install in a directory whose path contains a space])
93 dnl Note if the user specified a particular C++ compiler so we can give a more
94 dnl appropriate error message if we can't link a simple C++ program.
96 if test -n "$CXX" ; then
97 original_CXX="CXX=$CXX"
98 elif test -n "$CCC" ; then
99 original_CXX="CCC=$CCC"
102 dnl See HACKING document for details of the reasons for required versions.
103 AM_INIT_AUTOMAKE([1.11 -Wportability tar-ustar no-dist-gzip dist-xz std-options])
104 AC_CONFIG_SRCDIR([matcher/multiandpostlist.cc])
106 AC_CONFIG_HEADERS([config.h])
108 AC_CONFIG_MACRO_DIR([m4])
112 dnl Use libtool to manage our libraries.
114 dnl Default to only building shared libraries.
116 dnl Building both shared and static means having to compile the files which
117 dnl make up the library twice on most platforms. Shared libraries are the
118 dnl better option for most users, and if anyone really wants static libraries,
119 dnl they can configure with --enable-static (or --enable-static=xapian-core if
120 dnl configuring a combined tree with the bindings).
122 dnl We don't export any data items from the library, so it should be safe to
123 dnl enable win32-dll without decorating any declarations specially.
124 LT_INIT([disable-static win32-dll])
126 dnl -no-undefined causes problems on Solaris with Sun CC in C++11 mode, so only
127 dnl pass -no-undefined on platforms where it is required in order to link a
128 dnl shared library at all (Windows is the main one).
130 if test unsupported = "$allow_undefined_flag" ; then
131 NO_UNDEFINED=-no-undefined
133 AC_SUBST(NO_UNDEFINED)
137 dnl A standard "gotcha" for mingw and cygwin users is to not set up their
138 dnl PATH correctly, so that MSDOS FIND.EXE is found before Unix find. Help
139 dnl them out by checking for this condition, rather than letting libtool
140 dnl fail in obscure ways. NB check the *BUILD* OS, not the host one!
142 *mingw* | *cygwin* | pw32*)
143 find /dirunlikelytoexist >/dev/null 2>&1
144 if test $? = 2 ; then
145 dnl Unix find will return 1 if the directory didn't exist, or 0 if
148 *** You appear to have an MSDOS-like FIND.EXE in your PATH ahead of any
149 *** UNIX-like find. This misconfiguration will confuse libtool - you'll need
150 *** to make sure you have a UNIX-like find installed and fix your PATH, then
151 *** rerun configure. For more information, see:
153 *** https://www.cygwin.com/faq/faq.html#faq.using.find
159 dnl Add parameters for aclocal
160 dnl (This must come after AM_INIT_AUTOMAKE, since it modifies ACLOCAL)
161 ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
163 dnl disable "maintainer only" rules by default
166 dnl Checks for programs.
171 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
173 linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
174 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
175 link_all_deplibs_CXX=no
181 dnl Extract search path from ldconfig which is more reliable than the way
182 dnl vanilla libtool extracts them from ld.so.conf.
183 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
184 test -z "$d" || sys_lib_dlsearch_path_spec=$d
189 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
190 dnl On these platforms, libtool emits a warning if -no-install is passed,
191 dnl and uses -no-fast-install instead - the least ugly way to avoid that
192 dnl warnings seems to be to duplicate the above list of platforms from
193 dnl libtool and use -no-fast-install on them directly.
194 NO_INSTALL=-no-fast-install ;;
196 NO_INSTALL=-no-install ;;
198 AC_SUBST([NO_INSTALL])
200 dnl For reasons which are beyond me, if autoconf can't find a C++ compiler
201 dnl it will set CXX to g++ (which obviously won't work) rather than actually
202 dnl telling the user that it couldn't find a C++ compiler and telling them
203 dnl to either install one or set CXX if there's one configure failed to find.
204 dnl It's probably worthwhile checking that the C++ compiler actually works
206 if test -n "$CXX" ; then
208 AC_MSG_CHECKING([whether $CXX is a working C++ compiler])
209 AC_CACHE_VAL([xo_cv_cxx_works],
211 AC_RUN_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
212 [xo_cv_cxx_works=yes],
213 [xo_cv_cxx_works=no],
214 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
215 [xo_cv_cxx_works=yes],
216 [xo_cv_cxx_works=no])])
218 AC_MSG_RESULT([$xo_cv_cxx_works])
222 if test no = "$xo_cv_cxx_works" ; then
223 case $original_CXX in
225 dnl CCC is handled in a slightly odd way - if its value isn't an
226 dnl executable (taking PATH into account) then it is ignored!
227 test "$original_CXX" = "CCC=$CXX" || original_CXX=
230 if test -z "$original_CXX" ; then
232 *** You need a working C++ compiler to compile Xapian, but configure failed to
233 *** find one. If you have a working C++ compiler, you can tell configure where
234 *** to find it by invoking it like so:
236 *** ./configure CXX=/opt/bin/c++
240 *** You need a working C++ compiler to compile Xapian, but the compiler you
241 *** specified (with '$original_CXX') doesn't appear to be able to successfully
242 *** compile and link a simple program.
247 dnl Probe for any options needed to enable C++11 support.
248 AX_CXX_COMPILE_STDCXX_11
250 dnl We don't use a C compiler to compile Xapian's code, but on some platforms
251 dnl (e.g. mingw) libtool uses $LTCC which defaults to $CC, and it's also use to
252 dnl build auxiliary tools like snowball and lemon.
255 dnl Check endianness.
258 dnl We want a non-cross-compiling C compiler for building lemon with.
259 if test -z "$CC_FOR_BUILD" ; then
260 if test yes = "$cross_compiling"; then
266 AC_ARG_VAR([CC_FOR_BUILD], [C compiler command for native compilation (needed to compile build tools during cross-builds)])
268 dnl Run tests using the C++ compiler.
271 dnl Enable large file support if possible.
273 dnl With xlC on AIX, -D_LARGE_FILES changes the ABI of std::string, so it
274 dnl also needs to be used when compiling user code.
275 abi_affecting_cxxflags=
276 if $GREP '^#define _LARGE_FILES 1$' confdefs.h > /dev/null 2>&1 ; then
277 abi_affecting_cxxflags=-D_LARGE_FILES
279 AC_SUBST([abi_affecting_cxxflags])
281 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
282 #if defined __WIN32__ || defined _WIN32
285 ]])], [win32=no], [win32=yes])
287 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
291 ]])], [msvc=no], [msvc=yes])
295 AC_SUBST([XAPIAN_LDFLAGS])
296 AC_SUBST([XAPIAN_LIBS])
298 AC_DEFUN([XAPIAN_TEST_FLAGS_],
300 m4_define([cachevar],
301 [xo_cv_]m4_tolower(m4_bpatsubst([$1][_$3], [[^A-Za-z0-9]], [_])))
302 AC_CACHE_CHECK([for $CXX with $3 in $1], cachevar,
306 $2([AC_LANG_PROGRAM([], [])],
317 dnl Test if compiling works with $1 added to CXXFLAGS; if it does, add $1 to
318 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
319 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
320 [XAPIAN_TEST_FLAGS_([CXXFLAGS], [AC_COMPILE_IFELSE], [$1], [$2], [$3], [$4])])
322 dnl Test if linking works with $1 added to LDFLAGS; if it does, add $1 to
323 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
324 AC_DEFUN([XAPIAN_TEST_LDFLAGS],
325 [XAPIAN_TEST_FLAGS_([LDFLAGS], [AC_LINK_IFELSE], [$1], [$2], [$3], [$4])])
328 if test yesyes = "$GXX$enable_shared" ; then
332 [-Wl,--enable-runtime-pseudo-reloc],
336 dnl Can't use AC_DISABLE_SHARED after AC_PROG_LIBTOOL, but
337 dnl this test needs to be after AC_PROG_LIBTOOL, so we can't
338 dnl just disable the shared build automatically...
339 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])
344 dnl Only works for ldflags which can be specified anywhere on the link line.
347 dnl Preserve the default CXXFLAGS.
348 save_CXXFLAGS=$CXXFLAGS
350 dnl x86 has excess precision issues with 387 FP instructions, which are
351 dnl avoided by using SSE instructions instead. This is also faster (~6% in
352 dnl a CPU bound testcase).
354 [AS_HELP_STRING([--disable-sse],
355 [disable use of SSE FP instructions on x86])]
356 [AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
357 [set which SSE FP instructions to use on x86 (default: sse2)])],
358 [case ${enableval} in
360 *) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
364 dnl The maths functions we use include: exp log ceil fabs sqrt
365 AC_MSG_CHECKING([if -lm is required for maths functions])
366 dnl Don't use constant arguments as the compiler might simply evaluate the
367 dnl whole expression at compile time, and it might inline certain functions
368 dnl so test several functions. Also write results using printf() so that
369 dnl the compiler can't optimise away the computations.
370 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cmath>
373 using namespace std;]], [[
374 double a = log(ceil(time(NULL)/7.0));
375 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));
376 ]])], [AC_MSG_RESULT([no])], [
378 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <cmath>
381 using namespace std;]], [[
382 double a = log(ceil(time(NULL)/7.0));
383 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));]])],
384 [AC_MSG_RESULT([yes])],
385 [AC_MSG_ERROR([Failed to link a C++ program using <cmath>])
389 dnl C++11 should have log2(double), but keep this check for now to allow for
390 dnl compilers with incomplete library support for C++11.
391 AC_CHECK_DECLS([log2(double)], [], [],
393 using namespace std;])
395 dnl exp10() is a GNU libc extension.
396 AC_CHECK_DECLS([exp10(double)], [], [],
398 using namespace std;])
400 dnl Darwin provides __exp10().
401 AC_CHECK_DECLS([__exp10(double)], [], [],
403 using namespace std;])
405 dnl GCC provides __builtin_exp10() (but notably clang doesn't currently).
406 dnl On mingw, __builtin_exp10() causes GCC to generate a call to exp10() which
407 dnl then fails to link, so perform a link check here to catch that.
408 AC_CACHE_CHECK([for __builtin_exp10], xo_cv_link___builtin_exp10, [
409 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
412 using namespace std;]],
413 [[printf("%f", __builtin_exp10(double(time(NULL)*1e-8)));]])],
414 [xo_cv_link___builtin_exp10=yes],
415 [xo_cv_link___builtin_exp10=no])
417 if test $xo_cv_link___builtin_exp10 = yes ; then
418 AC_DEFINE([HAVE___BUILTIN_EXP10], [1], [Define to 1 if you have the '__builtin_exp10' function.])
421 dnl See if <typeinfo> can be used in the testsuite - at least for GCC and xlC,
422 dnl compilation of the test code below fails if RTTI isn't being generated
423 dnl (g++ -fno-rtti, or by default with xlC).
424 AC_MSG_CHECKING([if RTTI is supported])
425 save_CXXFLAGS=$CXXFLAGS
426 dnl xlC issues a warning for typeid() being used without RTTI being enabled,
427 dnl so for this test we pass the xlC option to make that warning into an error.
428 CXXFLAGS="$CXXFLAGS -qhaltonmsg=1540-2412"
429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
431 [CXXFLAGS=$save_CXXFLAGS])
432 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
434 #include <typeinfo>]],
439 } catch (std::exception & e) {
440 return typeid(e).name()[0];
442 [AC_MSG_RESULT([yes])
443 AC_DEFINE([USE_RTTI], [1], [Define if the testsuite can use RTTI])],
444 [AC_MSG_RESULT([no])])
445 CXXFLAGS=$save_CXXFLAGS
447 dnl We need to specify the argument types for builtin functions, or else
448 dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
449 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
450 __builtin_sub_overflow(int, int, int*),
451 __builtin_mul_overflow(int, int, int*)], [], [], [ ])
452 AC_CHECK_DECLS([__builtin_bswap16(uint16_t),
453 __builtin_bswap32(uint32_t),
454 __builtin_bswap64(uint64_t)], [], [],
455 [#include <stdint.h>])
456 AC_CHECK_DECLS([_byteswap_ushort, _byteswap_ulong, _byteswap_uint64], [], [],
457 [#include <stdlib.h>])
458 AC_CHECK_DECLS([__builtin_clz(unsigned),
459 __builtin_clzl(unsigned long),
460 __builtin_clzll(unsigned long long)], [], [], [ ])
461 AC_CHECK_DECLS([__builtin_ctz(unsigned),
462 __builtin_ctzl(unsigned long),
463 __builtin_ctzll(unsigned long long)], [], [], [ ])
464 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
465 AC_CHECK_DECLS([__builtin_popcount(unsigned),
466 __builtin_popcountl(unsigned long),
467 __builtin_popcountll(unsigned long long)], [], [], [ ])
468 AC_CHECK_DECLS([__popcnt, __popcnt64], [], [], [#include <intrin.h>])
469 AC_CHECK_DECLS([_addcarry_u32(unsigned char, unsigned, unsigned, unsigned*),
470 _addcarry_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*),
471 _subborrow_u32(unsigned char, unsigned, unsigned, unsigned*),
472 _subborrow_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*)],
473 [], [], [#include <intrin.h>])
475 dnl Check for poll().
476 AC_CHECK_FUNCS([poll])
478 dnl Check for time functions.
479 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
483 dnl For _ftime64() on mingw we need to tell it we're happy to require
484 dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
485 AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
486 AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
490 dnl Used by tests/soaktest/soaktest.cc
491 AC_CHECK_FUNCS([srandom random])
493 dnl Used by tests/harness/testsuite.cc
494 AC_CHECK_FUNCS([sigaction])
495 dnl These can be macros (and sigsetjmp is with glibc at least).
496 AC_CHECK_DECLS([sigsetjmp, siglongjmp], [], [], [#include <setjmp.h>])
498 dnl Used by tests/harness/cputimer.cc:
499 AC_CHECK_FUNCS([getrusage times sysconf])
501 dnl Used by tests/harness/unixcmd.cc
502 AC_CHECK_FUNCS([nftw])
504 dnl POSIX requires setenv(). The final Unix-like platform without it seems
505 dnl to have been Solaris 9, which is now out of support.
507 dnl Microsoft don't provide setenv() and have marked putenv() as deprecated, so
508 dnl we use _putenv_s() to avoid deprecation warnings with MSVC. It's also a
509 dnl more similar interface to setenv() so easier to implement a setenv() wrapper
510 dnl around. We probe for both the function and a declaration since mingw
511 dnl doesn't currently (v3.20) declare it but it is present in the C runtime DLL
512 dnl so we can provide our own declaration to access it.
513 AC_CHECK_FUNCS([setenv _putenv_s])
514 AC_CHECK_DECLS([_putenv_s(const char*, const char*)], [], [],
515 [#include <stdlib.h>])
517 dnl See if we have closefrom(), or some functions that are useful to implement
518 dnl closefrom() on platforms which don't provide it.
519 AC_CHECK_FUNCS([closefrom getdirentries getrlimit])
521 if test $ac_cv_func_ftime = yes ; then
522 dnl See if ftime returns void (as it does on mingw)
523 AC_MSG_CHECKING([return type of ftime])
525 [AC_LANG_PROGRAM([[#include <sys/timeb.h>]],
526 [[struct timeb tp; int i = ftime(&tp);]])],
527 [AC_MSG_RESULT([int])],
528 [AC_MSG_RESULT([void])
529 AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void])])
532 dnl Check how to find the hostname: uname() in sys/utsname.h, or gethostname()
533 AC_CHECK_HEADERS([sys/utsname.h], [], [], [ ])
534 AC_CHECK_FUNCS([gethostname])
536 dnl mingw (for instance) lacks ssize_t
543 AC_CHECK_SIZEOF([short])
544 AC_CHECK_SIZEOF([int])
545 AC_CHECK_SIZEOF([long])
546 AC_CHECK_SIZEOF([long long])
548 AC_CHECK_HEADERS([sys/types.h])
550 AC_MSG_CHECKING([for 32 bit integer type])
552 "$ac_cv_sizeof_int") INT32_T=int ;;
553 "$ac_cv_sizeof_long") INT32_T=long ;;
554 "$ac_cv_sizeof_short") INT32_T=short ;;
556 AC_MSG_RESULT([none found])
557 AC_MSG_ERROR([No 32 bit integer type found])
559 AC_MSG_RESULT([$INT32_T])
561 AC_MSG_CHECKING([for 64 bit integer type])
563 "$ac_cv_sizeof_int") INT64_T=int ;;
564 "$ac_cv_sizeof_long") INT64_T=long ;;
565 "$ac_cv_sizeof_long_long") INT64_T='long long' ;;
567 AC_MSG_RESULT([none found])
568 AC_MSG_ERROR([No 64 bit integer type found])
570 AC_MSG_RESULT([$INT64_T])
572 dnl Check for perl (needed to generate some sources and documentation).
573 AC_PATH_PROG([PERL], [perl], [])
574 AC_ARG_VAR([PERL], [Perl interpreter])
575 if test x$USE_MAINTAINER_MODE = xyes; then
576 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
579 AC_ARG_ENABLE([64bit_docid],
580 [AS_HELP_STRING([--enable-64bit-docid], [enable 64bit docid])],
581 [case ${enableval} in
583 *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-docid]) ;;
585 [enable_64bit_docid=no])
587 AC_ARG_ENABLE([64bit_termcount],
588 [AS_HELP_STRING([--enable-64bit-termcount], [enable 64bit termcount])],
589 [case ${enableval} in
591 *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termcount]) ;;
593 [enable_64bit_termcount=no])
595 AC_ARG_ENABLE([64bit_termpos],
596 [AS_HELP_STRING([--enable-64bit-termpos], [enable 64bit termpos])],
597 [case ${enableval} in
599 *) AC_MSG_ERROR([bad value ${enableval} for --enable-64bit-termpos]) ;;
601 [enable_64bit_termpos=no])
603 AC_ARG_ENABLE([documentation],
604 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
605 [case ${enableval} in
607 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
609 [enable_documentation=$USE_MAINTAINER_MODE])
610 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
611 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
613 if test x"$enable_documentation" = xyes ; then
614 dnl Checks for dot. (Diagrams in the documentation)
615 AC_PATH_PROG([DOT], [dot])
616 AC_ARG_VAR([DOT], [dot from graphviz])
617 test -z "$DOT" && AC_MSG_ERROR([dot (part of the graphviz package) is required to build documentation])
618 DOXYGEN_DOT_PATH=`echo "$DOT" | sed 's!/dot$!!'`
619 AC_SUBST([DOXYGEN_DOT_PATH])
621 dnl Check for doxygen. (Needed to make some more of the documentation)
622 AC_PATH_PROG([DOXYGEN], [doxygen], [])
623 AC_ARG_VAR([DOXYGEN], [Doxygen documentation system])
624 test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
626 dnl Check for help2man. (Needed to make man pages from "--help" output).
627 AC_PATH_PROG([HELP2MAN], [help2man], [])
628 AC_ARG_VAR([HELP2MAN], [help2man man page generator])
629 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
631 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
632 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
633 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
634 AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
635 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
637 dnl Check for pngcrush, which we optionally use to reduce the size of the
638 dnl PNG files which doxygen generates. We can get by without it, so don't
639 dnl fail here if it's not found.
640 AC_PATH_PROG([PNGCRUSH], [pngcrush], [])
641 AC_ARG_VAR([PNGCRUSH], [PNG optimiser])
644 dnl Checks for header files.
645 AC_CHECK_HEADERS([fcntl.h limits.h poll.h sys/select.h],
647 AC_CHECK_HEADERS([sys/resource.h],
648 [], [], [#include <sys/types.h>])
650 dnl cxxabi.h was added in GCC 3.1, but clang lies and defines __GNUC__ yet
651 dnl doesn't seem to reliably provide this header, so probe for it.
652 AC_CHECK_HEADERS([cxxabi.h], [], [], [ ])
654 dnl If valgrind is installed and new enough, we use it for leak checking in the
655 dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
656 dnl don't use valgrind. On macOS only use valgrind if VALGRIND is set to a
657 dnl no empty value, as valgrind on macOS gives a lot of false positives.
658 use_valgrind_if_non_empty=
661 use_valgrind_if_non_empty=$VALGRIND ;;
663 use_valgrind_if_non_empty=${VALGRIND-unset} ;;
666 if test -n "$use_valgrind_if_non_empty" ; then
667 AC_PATH_PROG([VALGRIND], [valgrind], [])
668 AC_ARG_VAR([VALGRIND], [debugging tool (optionally used by test harness)])
669 if test -n "$VALGRIND" ; then
670 dnl Check that the installed valgrind version works, and supports the
671 dnl options we use. This means we won't try to use valgrind < 3.3.0
672 dnl (released 7/12/2007) since before that --log-file didn't expand
673 dnl %p (and appended the process id).
675 dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
677 AC_MSG_CHECKING([if valgrind supports --log-file with %p and --child-silent-after-fork=yes])
678 vglog=config.vglog.%p.tmp
679 vglogwild="config.vglog.*.tmp*"
681 if $VALGRIND --log-file="$vglog" --child-silent-after-fork=yes -q true 2>&AS_MESSAGE_LOG_FD ; then
682 for f in $vglogwild ; do
684 $vglog*) VALGRIND= ;;
687 if test x"$VALGRIND" = x ; then
691 AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
694 dnl The valgrind detected doesn't seem to work! Perhaps this is an
695 dnl x86_64 box with a 32 bit valgrind.
696 AC_MSG_RESULT([$VALGRIND doesn't work])
703 if test -n "$VALGRIND" ; then
704 AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
707 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
708 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
710 if test -n "${EATMYDATA-unset}" ; then
711 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
712 AC_ARG_VAR([EATMYDATA], [wrapper to disable fsync (optionally used by test harness)])
715 dnl Checks for library functions.
718 AC_CACHE_CHECK([for sys_errlist and sys_nerr], xo_cv_sys_errlist_and_sys_nerr, [
719 AC_LINK_IFELSE([AC_LANG_PROGRAM(
720 dnl On Linux, sys_errlist and sys_nerr need <stdio.h>, though the man page
721 dnl says <errno.h>. The man page seems to match other platforms such as
722 dnl NetBSD, so include both headers to ensure we get them.
724 #include <stdio.h>]],
725 [[ printf("%s", sys_errlist[sys_nerr - 1]);]])],
726 [ xo_cv_sys_errlist_and_sys_nerr=yes ],
727 [ xo_cv_sys_errlist_and_sys_nerr=no ])
729 if test "x$xo_cv_sys_errlist_and_sys_nerr" = "xyes" ; then
730 AC_DEFINE([HAVE_SYS_ERRLIST_AND_SYS_NERR], [1],[Define if you have 'sys_errlist' and 'sys_nerr'])
733 AC_CACHE_CHECK([for _sys_errlist and _sys_nerr], xo_cv__sys_errlist_and__sys_nerr, [
734 AC_LINK_IFELSE([AC_LANG_PROGRAM(
736 #include <stdio.h>]],
737 [[ printf("%s", _sys_errlist[_sys_nerr - 1]);]])],
738 [ xo_cv__sys_errlist_and__sys_nerr=yes ],
739 [ xo_cv__sys_errlist_and__sys_nerr=no
742 if test "x$xo_cv__sys_errlist_and__sys_nerr" = "xyes" ; then
743 AC_DEFINE([HAVE__SYS_ERRLIST_AND__SYS_NERR], [1],[Define if you have '_sys_errlist' and '_sys_nerr'])
746 dnl GNU-specific replacement for sys_errlist and sys_nerr.
747 AC_CHECK_FUNCS([strerrordesc_np])
749 dnl mingw has _snprintf so check for that too.
750 AC_MSG_CHECKING([for snprintf])
751 AC_CACHE_VAL([xo_cv_func_snprintf],
753 xo_cv_func_snprintf=no
754 for func in snprintf _snprintf ; do
762 char buffer[4] = "abc";
763 int res = $func(buffer, 4, "%s", "XYZ");
767 [xo_cv_func_snprintf=$func;break],
772 AC_MSG_RESULT([$xo_cv_func_snprintf])
773 if test "$xo_cv_func_snprintf" != no ; then
774 AC_DEFINE_UNQUOTED([SNPRINTF], [$xo_cv_func_snprintf],
775 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
778 dnl ***************************
779 dnl * Select modules to build *
780 dnl ***************************
782 dnl Check which database backends should be built.
784 AC_DEFUN([_XAPIAN_BACKEND_ENABLE],
785 [AC_ARG_ENABLE([backend_$1],
786 [AS_HELP_STRING([--enable-backend-$1], [build the $1 database backend [default=$3]])],
789 *) AC_MSG_ERROR([Invalid option: '--enable-backend-$1=$enableval']) ;;
790 esac], [enable_backend_$1=$2])
793 AC_DEFUN([XAPIAN_BACKEND_ENABLE],
794 [_XAPIAN_BACKEND_ENABLE([$1],
795 m4_default([$2], [yes]),
796 m4_default([$3], [yes]))
799 dnl When adding a new backend, update INSTALL too.
800 XAPIAN_BACKEND_ENABLE([chert])
801 XAPIAN_BACKEND_ENABLE([glass])
802 XAPIAN_BACKEND_ENABLE([inmemory])
803 default_enable_backend_remote=yes
806 dnl We don't currently support the remote backend on this platform so
807 dnl disable it by default.
808 default_enable_backend_remote=no
811 XAPIAN_BACKEND_ENABLE([remote], [$default_enable_backend_remote], [yes (except for MSDOS)])
813 dnl Save and empty LIBS while we probe for libraries to link libxapian against
814 dnl so we can just use AC_SEARCH_LIBS then copy LIBS to XAPIAN_LIBS and restore
815 dnl the value saved here.
819 dnl See if we have fdatasync, and what libraries are needed for it.
820 dnl We need to actually check for a declaration as OS X has a dummy
821 dnl implementation in the library which is not prototyped in any header.
822 AC_CHECK_DECL([fdatasync(int)], [
823 AC_SEARCH_LIBS([fdatasync], [rt], [])
824 AC_CHECK_FUNCS([fdatasync])
826 [ac_cv_func_fdatasync=no],
827 [#include <unistd.h>]
830 dnl We use timer_create() if available to implement a search time limit.
831 AC_SEARCH_LIBS([timer_create], [rt],
833 AC_MSG_CHECKING([for timer_create() usability])
834 dnl Several platforms have timer_create() but it's non-functional.
836 dnl Some of these (at least those with a stub implementation which always
837 dnl fails with ENOSYS) could be probed for, but we'd have to run code
838 dnl which isn't possible when cross-compiling, so just maintain a list
839 dnl of such platforms for now.
840 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
842 #error timer_create always fails with EAGAIN on AIX 7.1
843 #elif defined __GNU__
844 #error timer_create always fails with ENOSYS on GNU Hurd
845 #elif defined __NetBSD__
846 #error timer_create timers never fire on NetBSD 7.1
847 #elif defined __OpenBSD__
848 #error timer_create always fails with ENOSYS on OpenBSD 6.2 (and no prototype)
850 [AC_MSG_RESULT([yes])
851 AC_DEFINE([HAVE_TIMER_CREATE], [1], [Define to 1 if you have the 'timer_create' function.])]
858 case $enable_backend_chert$enable_backend_glass in
860 dnl We use zlib for compressing tags in chert/glass. We could
861 dnl automatically disable support if zlib isn't found, but overall that
862 dnl probably does more harm than good - it's most likely that someone just
863 dnl forgot to install the -dev package for zlib.
865 dnl Similarly for uuid support.
867 dnl Check for zlib.h.
868 AC_CHECK_HEADERS([zlib.h], [], [
869 AC_MSG_ERROR([zlib.h not found - required for chert and glass (you may need to install the zlib1g-dev or zlib-devel package)])
872 dnl Check for zlibVersion - normally it's in -lz but the mingw build needs -lzlib or -lzdll.
873 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
874 AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll - required for chert and glass (you may need to install the zlib1g-dev or zlib-devel package)])
877 dnl Find the UUID library (from e2fsprogs/util-linux-ng, not the OSSP one).
879 case $host_os-$win32 in
880 *-yes | *cygwin*) dnl Use built-in win32 API.
881 AC_DEFINE([USE_WIN32_UUID_API], [1],
882 [Define to 1 to use UuidCreate(), etc])
883 if test $win32 = yes ; then
884 dnl We need -lws2_32 for htonl(), etc, but not for Cygwin which
885 dnl provides these functions in its libc.
888 LIBS="$LIBS -lrpcrt4"
891 dnl Check for uuid/uuid.h (e2fsprogs/util-linux-ng) or uuid.h
892 dnl (FreeBSD/NetBSD/OpenBSD/AIX).
893 AC_CHECK_HEADERS([uuid/uuid.h], [
894 dnl util-linux-ng's uuid/uuid.h found - check for uuid_generate in
896 AC_SEARCH_LIBS([uuid_generate], [uuid], [], [
897 AC_MSG_ERROR([uuid_generate() not found in -luuid - required for chert and glass (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
900 dnl Try uuid.h as found on FreeBSD/NetBSD/OpenBSD/AIX, with associated
902 AC_CHECK_HEADERS([uuid.h], [
903 dnl Check for uuid_create with no extra libraries required.
904 AC_CHECK_FUNC([uuid_create], [], [
905 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)])
908 dnl Especially useful for Android.
909 AC_MSG_CHECKING([if host platform supports /proc/sys/kernel/random/uuid])
912 AC_DEFINE([USE_PROC_FOR_UUID], [1],
913 [Define to 1 to read UUID from '/proc/sys/kernel/random/uuid'])
918 AC_MSG_ERROR([Failed to find a way to generate UUIDs, required for chert and glass backends (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
928 dnl DJGPP has a dummy implementation of fork which always fails.
930 dnl For disk-based backends, use flock() for locking, which doesn't need
931 dnl fork() or socketpair().
932 AC_DEFINE([FLINTLOCK_USE_FLOCK], 1, [Define to use flock() for flint-compatible locking])
938 if test "$enable_backend_remote" = yes ; then
939 case $host_os-$win32 in
941 dnl For mingw and msvc we have an alternative implementation which
942 dnl doesn't need fork() or socketpair().
944 dnl We need -lws2_32 for getaddrinfo(), etc.
946 dnl Vista is needed for the AI_ADDRCONFIG flag to getaddrinfo().
947 AC_DEFINE([WINVER], [0x600],
948 [Version of Windows to assume (0x600 => Vista).])
949 AC_DEFINE([_WIN32_WINNT], [WINVER],
950 [Version of Windows to assume.])
953 dnl DJGPP has a dummy implementation of fork which always fails. If
954 dnl someone actually wanted remote backend support, then DJGPP has a
955 dnl pthreads port, so using threads like we do on Windows would make more
957 AC_MSG_ERROR([The remote backend is not currently supported on this platform.])
960 dnl On Unix, we need fork and socketpair for the remotebackend.
961 AC_CHECK_FUNCS([fork], [], [
962 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.])
964 dnl Check if -lsocket is required for socketpair (Solaris needs it).
965 dnl And on Haiku it's in -lnetwork.
966 AC_SEARCH_LIBS([socketpair], [socket network], [], [
967 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.])
969 AC_DEFINE([HAVE_SOCKETPAIR], [1],
970 [Define to 1 if you have the 'socketpair' function.])
971 dnl Check if extra libraries are needed for getaddrinfo or inet_ntop()
972 dnl (e.g. on Solaris).
974 dnl We're currently assuming that any system that is worth trying to
975 dnl support has getaddrinfo() and inet_ntop(), since these are the
976 dnl standard route for supporting IPv6, and that's pretty much essential
977 dnl for platforms to support now.
978 AC_SEARCH_LIBS([getaddrinfo], [nsl socket], [], [
979 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.])
981 AC_SEARCH_LIBS([inet_ntop], [nsl socket], [], [
982 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.])
987 XAPIAN_TYPE_SOCKLEN_T
990 if test "$win32_need_lws2_32" = 1 ; then
991 LIBS="$LIBS -lws2_32"
996 AC_ARG_ENABLE([visibility],
997 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
998 [case ${enableval} in
1000 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
1004 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
1007 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
1009 dnl Turn off compilation of anything that we don't have the requirements for
1011 dnl Set conditionals to specify what we compile
1013 AM_CONDITIONAL([BUILD_BACKEND_CHERT], [test yes = "$enable_backend_chert"])
1014 AM_CONDITIONAL([BUILD_BACKEND_GLASS], [test yes = "$enable_backend_glass"])
1015 AM_CONDITIONAL([BUILD_BACKEND_INMEMORY], [test yes = "$enable_backend_inmemory"])
1016 AM_CONDITIONAL([BUILD_BACKEND_REMOTE], [test yes = "$enable_backend_remote"])
1017 AM_CONDITIONAL([BUILD_BACKEND_CHERT_OR_GLASS],
1018 [test nono != "$enable_backend_chert$enable_backend_glass"])
1020 dnl Decide if we should use the zlib-vg.so LD_PRELOAD hack.
1022 if test -n "$VALGRIND" ; then
1024 linux*) use_zlib_vg=yes ;;
1027 AM_CONDITIONAL([USE_ZLIB_VG], [test yes = "$use_zlib_vg"])
1029 AC_CHECK_FUNCS([fsync])
1030 AC_CHECK_FUNCS([posix_fadvise])
1031 if test "$win32" = no ; then
1032 dnl ftruncate() under Wine seems to be buggy and sometimes fails, though
1033 dnl a cut-down reproducer seems fine. For now just avoid ftruncate()
1034 dnl entirely on this platform - we'll fallback to lseek() + write() of a
1035 dnl single zero byte, which is pretty efficient.
1036 AC_CHECK_FUNCS([ftruncate])
1039 dnl HP-UX has pread and pwrite, but they don't work! Apparently this problem
1040 dnl manifests when largefile support is enabled, and we definitely want that
1041 dnl so don't use pread or pwrite on HP-UX.
1044 AC_MSG_CHECKING([for pread])
1045 AC_MSG_RESULT([present but broken on $host_os])
1046 AC_MSG_CHECKING([for pwrite])
1047 AC_MSG_RESULT([present but broken on $host_os])
1050 AC_CHECK_FUNC([pread],
1051 [AC_DEFINE([HAVE_PREAD], [1],
1052 [Define if pread is available on this system])
1053 AC_MSG_CHECKING([for any prototype needed for pread])
1054 AC_CACHE_VAL([xo_cv_pread_prototype],
1057 'extern "C" ssize_t pread(int, void *, size_t, off_t) throw ();' \
1058 'extern "C" ssize_t pread(int, void *, size_t, off_t);' ; do
1059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1060 #include <sys/types.h>
1065 pread(1, b, 256, 20);
1067 xo_cv_pread_prototype="$p"
1071 if test -z "$xo_cv_pread_prototype"; then
1072 AC_MSG_RESULT([not found])
1073 AC_MSG_ERROR([Failed to find working prototype for pread])
1076 if test " " = "$xo_cv_pread_prototype" ; then
1077 AC_MSG_RESULT([none required])
1079 AC_MSG_RESULT([$xo_cv_pread_prototype])
1080 AC_DEFINE_UNQUOTED([PREAD_PROTOTYPE], [$xo_cv_pread_prototype],
1081 [explicit prototype needed for pread (if any)])
1084 AC_CHECK_FUNC([pwrite],
1085 [AC_DEFINE([HAVE_PWRITE], [1],
1086 [Define if pwrite is available on this system])
1087 AC_MSG_CHECKING([for any prototype needed for pwrite])
1088 AC_CACHE_VAL([xo_cv_pwrite_prototype],
1091 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t) throw ();' \
1092 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t);' ; do
1093 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1094 #include <sys/types.h>
1098 const char *p = "hello";
1099 pwrite(1, p, 5, 20);
1101 xo_cv_pwrite_prototype="$p"
1105 if test -z "$xo_cv_pwrite_prototype"; then
1106 AC_MSG_RESULT([not found])
1107 AC_MSG_ERROR([Failed to find working prototype for pwrite])
1110 if test " " = "$xo_cv_pwrite_prototype" ; then
1111 AC_MSG_RESULT([none required])
1113 AC_MSG_RESULT([$xo_cv_pwrite_prototype])
1114 AC_DEFINE_UNQUOTED([PWRITE_PROTOTYPE], [$xo_cv_pwrite_prototype],
1115 [explicit prototype needed for pwrite (if any)])
1121 AC_MSG_CHECKING([for directory separator(s)])
1122 case $host_os-$win32 in
1123 *-yes | cygwin* | os2* | *djgpp* | *msdos* )
1124 AC_MSG_RESULT([/ and \\])
1125 AC_DEFINE([DIR_SEPS], ["/\\"], [directory separator(s) as a character or string literal])
1126 AC_DEFINE([DIR_SEPS_LIST], [{ '/', '\\' }], [directory separator(s) as an initialiser list])
1130 AC_DEFINE([DIR_SEPS], ['/'], [directory separator(s) as a character or string literal])
1131 AC_DEFINE([DIR_SEPS_LIST], [{ '/' }], [directory separator(s) as an initialiser list])
1135 AC_CHECK_FUNCS([link])
1137 dnl *************************
1138 dnl * Set debugging options *
1139 dnl *************************
1141 dnl Which assertion types to enable in the code.
1143 AC_ARG_ENABLE([assertions],
1144 [AS_HELP_STRING([--enable-assertions], [enable debug assertions (no|partial|yes) [default=no]])],
1148 AC_MSG_ERROR([Invalid option: '--enable-assertions=$enableval']) ;;
1151 AC_ARG_ENABLE([log],
1152 [AS_HELP_STRING([--enable-log], [generate a log of methods called, etc (no|yes|profile) [default=no]])],
1156 AC_MSG_ERROR(['--enable-log=profile' is no longer supported - see https://trac.xapian.org/wiki/ProfilingXapian for alternatives.]) ;;
1158 AC_MSG_ERROR([Invalid option: '--enable-log=$enableval']) ;;
1161 dnl Set defines according to the --enable-assertions and --enable-log options
1164 if test yes = "$enable_assertions" || test partial = "$enable_assertions" ; then
1165 AC_DEFINE([XAPIAN_ASSERTIONS],,
1166 [Define if you want assertions (causes some slow-down)])
1169 if test yes = "$enable_assertions"; then
1170 AC_DEFINE([XAPIAN_ASSERTIONS_PARANOID],,
1171 [Define if you want paranoid assertions (causes significant slow-down)])
1174 if test yes = "$enable_log"; then
1175 AC_DEFINE([XAPIAN_DEBUG_LOG],,
1176 [Define if you want a log of methods called and other debug messages])
1179 dnl ******************************
1180 dnl * Set special compiler flags *
1181 dnl ******************************
1183 dnl Set flags to control warnings (enable more, or disable annoying ones).
1185 if test yes = "$GXX"; then
1186 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
1187 dnl we actually have, as neither is really 100% compatible.
1188 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
1189 *__INTEL_COMPILER*__clang__*)
1190 dnl GCC (since neither substituted):
1192 dnl The exact format of g++ --version seems to change with almost every
1193 dnl minor release so use the preprocessor macros which should be more
1195 AC_MSG_CHECKING([for version of $CXX])
1196 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
1197 AC_MSG_RESULT([GCC $gxx_version])
1199 dnl -Wundef was supported by g++ 3.0.
1201 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
1204 dnl -Wdouble-promotion was added in GCC 4.6.
1206 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
1207 dnl warns for this case with -Wuninitialized (implied by -W). We
1208 dnl don't intend to use this idiom, so any instances are bugs we'd
1209 dnl like to know about.
1211 dnl All the other options were supported by g++ 2.95.
1212 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"
1214 case $gxx_version in
1215 [[0123]].*|4.[[0-6]].*)
1216 AC_MSG_ERROR([Xapian requires GCC 4.7 or later])
1221 AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond"
1224 AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond -Wduplicated-branches"
1229 dnl -Wold-style-cast is interesting, but triggers for macros from
1230 dnl system headers (e.g. FD_SET). GCC 4.8 improved this by making
1231 dnl -ftrack-macro-expansion=2 the default, but we still see such
1232 dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
1233 dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
1234 dnl warnings from zlib.h).
1236 dnl Automatically add -Werror if maintainer mode is enabled.
1237 if test x$USE_MAINTAINER_MODE = xyes; then
1238 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1242 dnl Intel's compiler (since __clang__ not substituted):
1244 dnl -w1 stops the avalanche of uninteresting "remark" messages.
1245 dnl -wd... disables warnings which don't have good code workarounds.
1246 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
1248 dnl Automatically add -Werror if maintainer mode is enabled.
1249 if test x$USE_MAINTAINER_MODE = xyes; then
1250 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1254 dnl clang (since __INTEL_COMPILER not substituted):
1256 dnl These options all work at least as far back as clang++ 3.0:
1257 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"
1259 dnl Automatically add -Werror if maintainer mode is enabled.
1260 if test x$USE_MAINTAINER_MODE = xyes; then
1261 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1266 if test no != "$enable_visibility"; then
1267 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1268 dnl supported on mingw and visibility attributes result in warnings).
1269 AC_MSG_CHECKING([if $CXX -fvisibility=hidden -fvisibility-inlines-hidden works])
1270 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
1271 AC_MSG_RESULT([yes])
1272 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
1273 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
1279 dnl Not GCC, nor a compiler masquerading as GCC.
1282 dnl +w turns on more warnings.
1283 dnl +wlint turns on "lint-like" warnings.
1284 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
1285 dnl 2340 (remark) "value copied to temporary, reference to temporary
1286 dnl use", in: throw Xapian::UnimplementedError("...");
1287 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
1288 dnl virtual destructor for intrusive_base, since we never delete
1289 dnl its subclasses by a intrusive_base *).
1290 dnl 3348 "declaration hides constant ..." which seems to misfire!
1291 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
1292 dnl alignment boundary".
1293 dnl 4273 "floating-point equality and inequality comparisons may be
1294 dnl inappropriate due to roundoff common in floating-point computation"
1295 dnl No obvious workaround for when you really do want == or !=.
1296 dnl 4285 "operator= does not have a check for the source and destination
1297 dnl addresses being non-identical" - fires for AutoPtr which
1298 dnl includes such a check indirectly (internaltest's autoptr1 check this).
1299 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
1300 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
1302 dnl Sun's C++ compiler.
1304 dnl We use -errtags to report the tag for each warning emitted.
1306 dnl We use -erroff to suppress some unhelpful warnings:
1308 dnl oklambdaretmulti warns about a lambda with more than one return
1309 dnl statement even if they all return the same type.
1311 dnl voidretw warns about functions failing to return a value even when the
1312 dnl function ends with a "throw" statement. That's just unhelpful noise,
1313 dnl and adding a dummy "return" after "throw" seems a worse solution than
1314 dnl simply disabling this warning - any genuinely missing return statements
1315 dnl will get reported by compilers with superior warning machinery.
1316 XAPIAN_TEST_CXXFLAGS([-errtags -erroff=oklambdaretmulti,voidretw], [AM_CXXFLAGS])
1321 XAPIAN_TEST_LDFLAGS([-Wl,-Bsymbolic-functions], [XAPIAN_LDFLAGS])
1322 dnl Roughly equivalent Sun C++ option.
1323 XAPIAN_TEST_LDFLAGS([-xldscope=symbolic], [XAPIAN_LDFLAGS])
1325 dnl New in GCC 5. Sort of like -Bsymbolic-functions, but for the compiler
1326 dnl rather than the linker.
1327 XAPIAN_TEST_LDFLAGS([-fno-semantic-interposition], [XAPIAN_LDFLAGS])
1329 AC_MSG_CHECKING([whether to use SSE instructions on x86])
1332 if test "$enable_sse" = no ; then
1334 if test yes = "$msvc"; then
1335 dnl MSVC defaults to SSE2.
1336 AM_CXXFLAGS="$AM_CXXFLAGS -arch:IA32"
1339 dnl Default to sse2.
1340 test "$enable_sse" != yes || enable_sse=sse2
1341 if test yes = "$GXX"; then
1342 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1343 dnl We can unconditionally use -mtune=generic as it was added in GCC
1344 dnl 4.2, and supported at least as far back as clang 3.0.
1345 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic"
1346 elif test yes = "$msvc"; then
1347 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1348 if test sse = "$enable_sse"; then
1349 dnl MSVC defaults to SSE2.
1350 AM_CXXFLAGS="$AM_CXXFLAGS -arch:SSE"
1353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1354 [[#ifndef __SUNPRO_CC
1355 #error Not Sun compiler
1357 [AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1358 AM_CXXFLAGS="$AM_CXXFLAGS -xarch=$enable_sse"]
1360 [AC_MSG_RESULT([don't know how to for compiler $CXX])]
1366 AC_MSG_RESULT([non-x86 arch ($host_cpu)]) ;;
1370 [/* Disable stupid MSVC warnings. */
1372 /* Passing an empty parameter to a single parameter macro. */
1373 # pragma warning(disable:4003)
1374 /* A "performance" warning for converting int to bool. */
1375 # pragma warning(disable:4800)
1377 /* Tell MSVC we want M_PI, etc defined. */
1378 # define _USE_MATH_DEFINES
1380 /* Tell MSVC we don't want max() and min() macros defined. */
1384 /* Make the POSIX-like functions support large files. MSVC needs this;
1385 * current mingw32 does too; mingw64 supports _FILE_OFFSET_BITS, which
1386 * AC_SYS_LARGEFILE should discover and enable automatically.
1388 #if defined _MSC_VER || \
1389 (defined __MINGW32__ && !defined _FILE_OFFSET_BITS)
1391 # include <sys/stat.h>
1392 # include <sys/types.h>
1394 /* zlib.h uses off_t so we need to include it before we redefine off_t. */
1397 // The default stat() and fstat() use 32-bit filesizes and time_t, so we need
1398 // to arrange to use 64-bit variants instead.
1401 // Break #undef lines to stop config.status from commenting them out.
1406 // This hack is a problem is we ever want a method called "stat".
1408 // MSVC needs to call _stat64() instead of stat() and the struct which holds
1409 // the information is `struct _stat64` instead of `struct stat` so we just
1410 // use #define to replace both in one go.
1411 # define stat _stat64
1413 // Mingw32 has _stat64() but unhelpfully for our purposes, the struct is
1414 // called __stat64 (with an extra underscore). We hack around this by
1415 // defining stat to __stat64 which sorts out the struct, and then using
1416 // a second macro to forward function-like uses of __stat64() to
1418 # define stat __stat64
1419 # define __stat64(PATH, STATBUF) _stat64((PATH), (STATBUF))
1422 // We also want to use _fstat64() instead of fstat() but in this case we can
1423 // use a function-like macro, so we could have a method called fstat so long
1424 // as it didn't take two parameters.
1427 // Break #undef lines to stop config.status from commenting them out.
1432 # define fstat(FD, BUF) _fstat64(FD, BUF)
1435 // Break #undef lines to stop config.status from commenting them out.
1441 // Break #undef lines to stop config.status from commenting them out.
1446 # define lseek(FD, OFF, WHENCE) _lseeki64(FD, OFF, WHENCE)
1447 /* Redefine via a typedef so C++ code off_t(-1) works - it wouldn't if we did:
1448 * #define off_t long long
1450 typedef long long off_t_redefinition_typedef;
1451 # define off_t off_t_redefinition_typedef
1455 /* MSVC defines _WIN32 but not __WIN32__. */
1456 #if !defined __WIN32__ && defined _WIN32
1460 /* MSVC defines _WIN64 but not __WIN64__. */
1461 #if !defined __WIN64__ && defined _WIN64
1465 /* Default to enabling _FORTIFY_SOURCE at level 2. It shouldn't cause a
1466 * problem to define it where it's not supported.
1468 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
1469 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
1471 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
1472 # define _FORTIFY_SOURCE 2
1474 /* Both mingw32 and mingw-w64 define __MINGW32__. */
1475 # include <stddef.h>
1476 # ifdef __MINGW64_VERSION_MAJOR
1477 /* Enabling _FORTIFY_SOURCE on newer mingw-w64 requires linking with -lssp so
1478 * we simply don't automatically enable it there.
1480 # undef _FORTIFY_SOURCE
1485 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
1486 * we can use __builtin_expect to give the compiler hints about branch
1487 * prediction. See HACKING for how to use these.
1489 #if HAVE_DECL___BUILTIN_EXPECT
1490 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
1491 * the first argument is always an integer expression, and always 0 or 1, but
1492 * still has the same truth value for the if or while it is used in.
1494 # define rare(COND) __builtin_expect(!!(COND), 0)
1495 # define usual(COND) __builtin_expect(!!(COND), 1)
1497 # define rare(COND) (COND)
1498 # define usual(COND) (COND)
1501 /* Signal we're building the library so it's OK to include headers such as
1502 * xapian/query.h directly.
1504 #define XAPIAN_LIB_BUILD 1
1506 /* With Sun CC 5.13 (Studio 12.4) on Solaris 11.2, <math.h> seems to get
1507 * implicitly included somehow before <cmath>, and compilation fails due
1508 * to 'std::exception' colliding with 'struct exception'. It's not clear
1509 * how to avoid this, so just define the same magic macro which <cmath> does
1510 * before it includes <math.h>.
1512 #if defined __SUNPRO_CC && !defined __MATHERR_RENAME_EXCEPTION
1513 # define __MATHERR_RENAME_EXCEPTION
1517 AC_SUBST([AM_CXXFLAGS])
1519 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1520 CXXFLAGS=$save_CXXFLAGS
1522 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1523 : ${AUTOM4TE=autom4te}
1524 AC_SUBST([AUTOM4TE])
1526 dnl Libtool sets this (to yes|no|unknown) and we use it in xapian-config.
1527 AC_SUBST([link_all_deplibs_CXX])
1529 dnl Shared library extension.
1531 eval "SHLIBEXT=$shrext_cmds"
1532 AC_SUBST([SHLIBEXT])
1534 dnl We want to be able to use GNU make % pattern rules in maintainer targets
1535 dnl but automake warns these aren't portable, so we substitute the % to avoid
1540 dnl Split up the version number into "MAJOR.MINOR.REVISION".
1541 MAJOR_VERSION=`echo "$VERSION"|sed 's/\..*//'`
1542 [MINOR_VERSION=`echo "$VERSION"|sed 's/[^.]*\.//;s/\..*//'`]
1543 [REVISION=`echo "$VERSION"|sed 's/.*\.//;s/_.*$//'`]
1545 dnl Convert the libs in $XAPIAN_LIBS to a CMake list.
1546 XAPIAN_CMAKE_LIBS=`echo " $XAPIAN_LIBS" | sed 's/ -l/;/g;s/ //g'`
1547 AC_SUBST([XAPIAN_CMAKE_LIBS])
1549 XAPIAN_CMAKE_SHARED=
1550 if test "$enable_shared" = yes; then
1551 XAPIAN_CMAKE_SHARED=ON
1553 XAPIAN_CMAKE_SHARED=OFF
1555 AC_SUBST([XAPIAN_CMAKE_SHARED])
1557 LIBRARY_STATIC_EXT=.$libext
1558 AC_SUBST([LIBRARY_STATIC_EXT])
1560 if test "$win32" = yes; then
1561 LIBRARY_SHARED_IMP_EXT=$LIBRARY_STATIC_EXT
1563 LIBRARY_SHARED_IMP_EXT=
1565 AC_SUBST([LIBRARY_SHARED_IMP_EXT])
1567 dnl **************************
1568 dnl * Build the output files *
1569 dnl **************************
1575 docs/doxygen_api.conf
1576 docs/doxygen_source.conf
1578 cmake/xapian-config.cmake
1579 cmake/xapian-config-version.cmake
1580 pkgconfig/xapian-core"$LIBRARY_VERSION_SUFFIX".pc:pkgconfig/xapian-core.pc.in
1582 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
1583 AC_CONFIG_FILES([tests/runtest], [chmod +x tests/runtest])
1584 AC_CONFIG_FILES([tests/runsrv], [chmod +x tests/runsrv])
1585 AC_CONFIG_FILES([tests/submitperftest], [chmod +x tests/submitperftest])
1586 AC_CONFIG_FILES([tests/perftest/get_machine_info], [chmod +x tests/perftest/get_machine_info])
1587 AC_CONFIG_FILES([xapian-config], [chmod +x xapian-config])
1590 dnl There are no files generated by AC_OUTPUT in the following directories
1591 dnl and we need to ensure they exist so that the rest of configure or make
1592 dnl won't fail because they don't exist when srcdir != builddir.
1593 if test yes = "$vpath_build" ; then
1594 for dir in include/xapian languages queryparser ; do
1595 AS_MKDIR_P(["$dir"])
1599 dnl Generate include/xapian/version.h:
1601 dnl MAIN_VERSION is VERSION without any _git123 suffix.
1602 MAIN_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$REVISION"
1604 for backend in CHERT GLASS INMEMORY REMOTE ; do
1605 val=`eval echo "\\\$BUILD_BACKEND_${backend}_TRUE"`
1606 if test -z "$val" ; then
1607 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_${backend}_BACKEND"
1611 if test yes = "$enable_64bit_docid" ; then
1612 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_DOCID_BASE_TYPE="`echo "$INT64_T"|sed 's/ /____/g'`
1614 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_DOCID_BASE_TYPE="`echo "$INT32_T"|sed 's/ /____/g'`
1617 if test yes = "$enable_64bit_termcount" ; then
1618 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMCOUNT_BASE_TYPE="`echo "$INT64_T"|sed 's/ /____/g'`
1620 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMCOUNT_BASE_TYPE="`echo "$INT32_T"|sed 's/ /____/g'`
1623 if test yes = "$enable_64bit_termpos" ; then
1624 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMPOS_BASE_TYPE="`echo "$INT64_T"|sed 's/ /____/g'`
1626 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TERMPOS_BASE_TYPE="`echo "$INT32_T"|sed 's/ /____/g'`
1629 dnl Always ought to be 64 bit.
1630 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_TOTALLENGTH_TYPE="`echo "unsigned $INT64_T"|sed 's/ /____/g'`
1632 dnl Make revision numbers in the API 64 bit for future-proofing.
1633 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_REVISION_TYPE="`echo "unsigned $INT64_T"|sed 's/ /____/g'`
1635 dnl For GCC (and compilers which pretend to be GCC) and MSVC, we create some
1636 dnl ABI checks in the generated version.h, and $CXXFLAGS may contain options
1637 dnl which affect the ABI (e.g. -fabi-version for GCC) so we want to use these
1638 dnl options when generating version.h. For these compilers, CXXCPP="$CXX -E"
1639 dnl so it should understand all compiler options.
1641 dnl For other compilers, we only pass $CPPFLAGS to $CXXCPP in case it's an
1642 dnl external cpp which doesn't understand flags which might be in $CXXFLAGS.
1643 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
1649 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS $CXXFLAGS"],
1650 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS"])
1651 rm -f include/xapian/version.h.tmp
1652 dnl "\r" in sed is a GNUism, but we only need to remove it on MS Windows
1653 dnl where we'll always have GNU sed, and other sed's will just interpret
1654 dnl it as "r" (Solaris sed) or maybe literal "\r" which won't match.
1656 dnl Use @@ around $MAIN_VERSION so we get " in the final output.
1657 $CXXCPP $cxxcpp_flags\
1658 -DSTRING_VERSION="\"@@$MAIN_VERSION@@\""\
1659 -DMAJOR_VERSION="\"$MAJOR_VERSION\""\
1660 -DMINOR_VERSION="\"$MINOR_VERSION\""\
1661 -DREVISION="\"$REVISION\""\
1663 $srcdir/include/xapian/version_h.cc|\
1664 ${SED-sed} '0,/const char \* dummy/d;/"/!d;s/^ *//;/^#/d;s/ *$//;s/" *,//;s/"//g;s/@@/"/g;s/ */ /g;s/ *,\r$//;s/ *,$//;s/____/ /g;s/\\\\$/\\/'\
1665 > include/xapian/version.h.tmp
1666 dnl Only update the file if it has changed, so we don't alter the timestamp
1667 dnl and cause lots of rebuilding needlessly. However, the build system
1668 dnl needs a timestamp to know when to regenerate version.h because version_h.cc
1669 dnl has changed so we use a separate timestamp file.
1670 touch include/xapian/version.h.timestamp
1671 if cmp include/xapian/version.h.tmp include/xapian/version.h >/dev/null 2>&1
1673 rm include/xapian/version.h.tmp
1675 mv include/xapian/version.h.tmp include/xapian/version.h