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.2.23], [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:
32 dnl 21:11:6 1.0.20 No API changes
33 dnl 22:0:0 1.2.0 Many API changes!
34 dnl 23:0:1 1.2.1 QueryParser::add_boolean_prefix()'s exclusive parameter.
35 dnl 23:1:1 1.2.2 No API changes
36 dnl 23:2:1 1.2.3 No API changes
37 dnl 24:0:2 1.2.4 Compactor
38 dnl 25:0:3 1.2.5 New min_wt overload for Enquire::get_eset()
39 dnl 26:0:4 1.2.6 QueryParser::set_max_wildcard_expansion() added
40 dnl 26:1:4 1.2.7 No API changes
41 dnl 26:2:4 1.2.8 No API changes
42 dnl 26:3:4 1.2.9 No API changes
43 dnl 26:4:4 1.2.10 No API changes
44 dnl 26:0:5 1.2.11 TermGenerator::set_stemming_strategy() added
45 dnl 27:0:5 1.2.12 Corrects error in 1.2.11's LIBRARY_VERSION_INFO
46 dnl 28:0:6 1.2.13 TermGenerator::set_max_word_length() added
47 dnl 28:1:6 1.2.14 No API changes
48 dnl 28:2:6 1.2.15 No API changes
49 dnl 28:3:6 1.2.16 No API changes
50 dnl 28:4:6 1.2.17 No API changes
51 dnl 28:5:6 1.2.18 No API changes
52 dnl 28:6:6 1.2.19 No API changes
53 dnl 28:7:6 1.2.20 No API changes
54 dnl 28:8:6 1.2.21 No API changes
55 dnl 29:0:7 1.2.22 FLAG_CJK_NGRAM added
56 dnl 29:1:7 1.2.23 No API changes (except new inline methods)
57 LIBRARY_VERSION_INFO=29:1:7
58 AC_SUBST([LIBRARY_VERSION_INFO])
60 LIBRARY_VERSION_SUFFIX=
61 AC_SUBST([LIBRARY_VERSION_SUFFIX])
63 dnl Disabled for stable release series.
64 dnl Default to "-1.1"; for no suffix, specify: --program-suffix=
65 dnl test x"$program_suffix" != xNONE || program_suffix=-1.1
67 dnl Where xapian.h, etc go. In development release append "/xapian-1.1".
71 dnl Check the build directory doesn't contain a space, so we die early with
75 AC_MSG_ERROR([You can't build in a directory whose path contains a space])
80 dnl Check the source directory doesn't contain a space, so we die early with
81 dnl a helpful error. FIXME: Unfortunately, configure seems to choke before
82 dnl it gets to us so this code doesn't get a chance to fire.
85 dnl Note: for in-tree builds, the build directory test above will fire
87 AC_MSG_ERROR([You can't build with sources in a directory whose path contains a space])
92 dnl Check the prefix to install in doesn't contain a space, so we die early with
96 AC_MSG_ERROR([You can't install in a directory whose path contains a space])
101 dnl Note if the user specified a particular C++ compiler so we can give a more
102 dnl appropriate error message if we can't link a simple C++ program.
104 if test -n "$CXX" ; then
105 original_CXX="CXX=$CXX"
106 elif test -n "$CCC" ; then
107 original_CXX="CCC=$CCC"
110 dnl See HACKING document for details of the reasons for required versions.
111 AM_INIT_AUTOMAKE([1.11 -Wportability tar-ustar no-dist-gzip dist-xz std-options])
112 AC_CONFIG_SRCDIR([matcher/multiandpostlist.cc])
114 AC_CONFIG_HEADERS([config.h])
116 AC_CONFIG_MACRO_DIR([m4])
118 dnl Use libtool to manage our libraries.
120 dnl Libtool doesn't know about -library=stdcxx4 yet, and also it checks for
121 dnl -library=stlport4 before we enable it, so trick it into not wanting to add
123 solaris_use_stlport4=yes
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_TRY_RUN([int main() {}],
214 AC_TRY_LINK([], [], xo_cv_cxx_works=yes, xo_cv_cxx_works=no))
216 AC_MSG_RESULT([$xo_cv_cxx_works])
220 if test no = "$xo_cv_cxx_works" ; then
221 case $original_CXX in
223 dnl CCC is handled in a slightly odd way - if its value isn't an
224 dnl executable (taking PATH into account) then it is ignored!
225 test "$original_CXX" = "CCC=$CXX" || original_CXX=
228 if test -z "$original_CXX" ; then
230 *** You need a working C++ compiler to compile Xapian, but configure failed to
231 *** find one. If you have a working C++ compiler, you can tell configure where
232 *** to find it by invoking it like so:
234 *** ./configure CXX=/opt/bin/c++
238 *** You need a working C++ compiler to compile Xapian, but the compiler you
239 *** specified (with '$original_CXX') doesn't appear to be able to successfully
240 *** compile and link a simple program.
245 dnl We don't use a C compiler to compile Xapian's code, but on some platforms
246 dnl (e.g. mingw) libtool uses $LTCC which defaults to $CC, and it's also use to
247 dnl build auxiliary tools like snowball and lemon.
250 dnl We want a non-cross-compiling C compiler for building lemon with.
251 if test -z "$CC_FOR_BUILD" ; then
252 if test yes = "$cross_compiling"; then
258 AC_ARG_VAR([CC_FOR_BUILD], [C compiler command for native compilation (needed to compile build tools during cross-builds)])
260 dnl Run tests using the C++ compiler.
263 dnl Enable large file support if possible.
265 dnl With xlC on AIX, -D_LARGE_FILES changes the ABI of std::string, so it
266 dnl also needs to be used when compiling user code.
267 abi_affecting_cxxflags=
268 if $GREP '^#define _LARGE_FILES 1$' confdefs.h > /dev/null 2>&1 ; then
269 abi_affecting_cxxflags=-D_LARGE_FILES
271 AC_SUBST([abi_affecting_cxxflags])
275 AC_SUBST([XAPIAN_LDFLAGS])
276 AC_SUBST([XAPIAN_LIBS])
278 AC_DEFUN([XAPIAN_TEST_LINKER_FLAG],
280 AC_MSG_CHECKING([for $CXX -Wl,$1])
281 AC_CACHE_VAL([xo_cv_$2],
284 dnl The option in $1 will start with a dash so needs protecting. We can't
285 dnl use -e as Solaris /usr/bin/grep doesn't support that, so prepend an
286 dnl empty group instead.
287 if $CXX -Wl,$1 >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD|grep '\(\)'$1 >/dev/null 2>&1; then
288 dnl The error message contains the flag name - it must be a
289 dnl complaint that the option is unrecognized (doing it this
290 dnl way allows it to work regardless of the i18n in use):
291 dnl ld: unrecognized option '--enable-runtime-pseudo-reloc'
299 AC_MSG_RESULT([$xo_cv_$2])
302 dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
303 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
304 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
306 XTC_save_CXXFLAGS=$CXXFLAGS
307 CXXFLAGS="$CXXFLAGS $1"
308 AC_TRY_COMPILE([], [],
310 CXXFLAGS=$XTC_save_CXXFLAGS
312 [CXXFLAGS=$XTC_save_CXXFLAGS
317 if test yesyes = "$GXX$enable_shared" ; then
320 XAPIAN_TEST_LINKER_FLAG([--enable-runtime-pseudo-reloc], [enable_runtime_pseudo_reloc],
321 [ldflags="-Wl,$flag"],
323 dnl Can't use AC_DISABLE_SHARED after AC_PROG_LIBTOOL, but
324 dnl this test needs to be after AC_PROG_LIBTOOL, so we can't
325 dnl just disable the shared build automatically...
326 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])
331 dnl Only works for ldflags which can be specified anywhere on the link line.
336 AC_MSG_CHECKING([for $CXX options to enable ISO C++ mode])
337 if test yes = "$GXX"; then
339 AC_MSG_RESULT([none required])
342 dnl Some C++ compilers need a special switch to select ISO C++ mode. Do
343 dnl this early in configure so such settings are used for other tests.
346 dnl Select ANSI mode for HP's aCC, which gives us the std:: namespace,
347 dnl Koenig lookup, and ANSI scoping for the variable i in:
348 dnl for (int i = 1; i < n; ++i) { ... }
349 dnl (don't confuse -AA with -Aa which is similar but without the std::
352 dnl Note that using -AA means that user code must be built with -AA
353 dnl (which is the default on Itanium, but not on PARISC:
354 dnl http://h21007.www2.hp.com/dspp/tech/tech_TechDocumentDetailPage_IDX/1,1701,5520,00.html
356 dnl Also -ext (which can also be spelled +e):
357 dnl "Allow various C++ extensions. Currently -ext enables the 64 bit
358 dnl integer (long long) data type." This seems to be implied by -AA
359 dnl but otherwise is needed to allow "cout << (long long)42;".
361 dnl +w turns on more warnings.
362 dnl +wlint turns on "lint-like" warnings.
363 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
364 dnl 2340 (remark) "value copied to temporary, reference to temporary
365 dnl use", in: throw Xapian::UnimplementedError("...");
366 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
367 dnl virtual destructor for RefCntBase, since we never delete its
368 dnl subclasses by a RefCntBase *).
369 dnl 3348 "declaration hides constant ..." which seems to misfire!
370 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
371 dnl alignment boundary".
372 dnl 4273 "floating-point equality and inequality comparisons may be
373 dnl inappropriate due to roundoff common in floating-point computation"
374 dnl No obvious workaround for when you really do want == or !=.
375 dnl 4285 "operator= does not have a check for the source and destination
376 dnl addresses being non-identical" - fires for AutoPtr which
377 dnl includes such a check indirectly (internaltest's autoptr1 check this).
378 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
379 WARNING_CXXFLAGS="+w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
381 dnl Select ANSI mode ('-std strict_ansi' is needed for ANSI iostream
382 dnl as '-std ansi' gives a pre-standard AT&T-compatible version).
383 dnl If this proves to be a problem, we could instead try
384 dnl '-std ansi -D__USE_STD_IOSTREAM'.
386 dnl Check that the compiler recognises these flags to avoid problems
387 dnl with other compilers named cxx.
388 XAPIAN_TEST_CXXFLAGS([-std strict_ansi], [ISO_CXXFLAGS]) ;;
390 dnl Could be Sun's, SGI's, or something else entirely.
391 case `$CXX -V 2>&1` in
394 dnl Select ANSI conforming STL - for more information see:
395 dnl http://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/cplusplus-faq-355066.html#LibComp5
396 dnl -library=stdcxx4 is better, but needs "Solaris 10 update 10 or
399 dnl If the compiler supports -library=stdcxx4 but the user has
400 dnl specified CXXFLAGS=-library=stlport4, then this should put
401 dnl -library=stlport4 in ISO_CXXFLAGS, since the compiler will give
402 dnl an error when passed -library=stlport4 -library=stdcxx4.
403 for l in stdcxx4 stlport4 Cstd ; do
404 dnl We avoid -library-$l,Crun as libtool looks for
405 dnl " -library=stlport4 " (with the spaces either side).
406 f="-library=$l -library=Crun"
407 XAPIAN_TEST_CXXFLAGS([$f], [ISO_CXXFLAGS], [break])
409 dnl Older versions of this compiler defaulted to a non-standard
410 dnl lifetime for temporary objects, and -features=tmplife is required
411 dnl for standard conforming behaviour (which Xapian code expects).
412 XAPIAN_TEST_CXXFLAGS([-features=tmplife], [ISO_CXXFLAGS])
413 dnl Sun's C++ compiler warns about functions failing to return a value even
414 dnl when the function ends with a "throw" statement. That's just unhelpful
415 dnl noise, and adding a dummy "return" after "throw" seems a worse solution
416 dnl than simply disabling this warning - any genuinely missing return
417 dnl statements will get reported by compilers with superior warning
419 XAPIAN_TEST_CXXFLAGS([-erroff=voidretw], [WARNING_CXXFLAGS])
422 case `$CXX -v 2>&1` in
424 dnl On stderr: MIPSpro Compilers: Version 7.4.2m
425 dnl Select ANSI mode for SGI's CC with "-LANG:std". Also, we have to
426 dnl specify "-ptused" or we get strange template linking errors.
427 ISO_CXXFLAGS="-LANG:std -ptused" ;;
434 if test -n "$ISO_CXXFLAGS" ; then
435 AC_MSG_RESULT([$ISO_CXXFLAGS])
437 dnl Perhaps we should try to compile some code which uses iostream, for
438 dnl scoping, etc, but maintaining such a snippet to cover everything we
439 dnl require which any C++ compiler may not support is tricky.
440 AC_MSG_RESULT([none known for $CXX])
444 dnl Preserve the default CXXFLAGS.
445 save_CXXFLAGS=$CXXFLAGS
447 dnl Put any flags for ANSI mode in CXXFLAGS for the duration of configure
448 dnl since we want to make feature tests using those flags.
449 if test -n "$ISO_CXXFLAGS" ; then
450 CXXFLAGS="$ISO_CXXFLAGS $CXXFLAGS"
451 AM_CXXFLAGS="$ISO_CXXFLAGS $AM_CXXFLAGS"
454 dnl Make 'xapian-config --cxxflags' turn on any such flags for code linking
456 AC_SUBST([ISO_CXXFLAGS])
458 dnl x86 has excess precision issues with 387 FP instructions, which are
459 dnl avoided by using SSE instructions instead. This is also faster (~6% in
460 dnl a CPU bound testcase).
462 [AS_HELP_STRING([--disable-sse],
463 [disable use of SSE FP instructions on x86])]
464 [AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
465 [set which SSE FP instructions to use on x86 (default: sse2)])],
466 [case ${enableval} in
468 *) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
472 dnl Some versions of Sun's C++ compiler reportedly need an explicit -lm.
473 dnl The maths functions we use include: exp log ceil fabs sqrt
474 AC_MSG_CHECKING([if -lm is required for maths functions])
475 dnl Don't use constant arguments as the compiler might simply evaluate the
476 dnl whole expression at compile time, and it might inline certain functions
477 dnl so test several functions. Also write results using printf() so that
478 dnl the compiler can't optimise away the computations.
479 AC_TRY_LINK([#ifdef __SUNPRO_CC
480 #error Need -lm for Sun C++ 5.9 under libtool 2.2.10
485 using namespace std;], [
486 double a = log(ceil(time(NULL)/7.0));
487 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));
488 ], [AC_MSG_RESULT([no])], [
490 AC_TRY_LINK([#include <cmath>
493 using namespace std;], [
494 double a = log(ceil(time(NULL)/7.0));
495 printf("%f %f %f\n", a, sqrt(a), exp(fabs(a - 12345.6)));],
496 [AC_MSG_RESULT([yes])],
497 [AC_MSG_ERROR([Failed to link a C++ program using <cmath>])
501 dnl See if <typeinfo> can be used in the testsuite - at least for GCC and xlC,
502 dnl compilation of the test code below fails if RTTI isn't being generated
503 dnl (g++ -fno-rtti, or by default with xlC).
504 AC_MSG_CHECKING([if RTTI is supported])
505 save_CXXFLAGS=$CXXFLAGS
506 dnl xlC issues a warning for typeid() being used without RTTI being enabled,
507 dnl so for this test we pass the xlC option to make that warning into an error.
508 XAPIAN_TEST_CXXFLAGS([-qhaltonmsg=1540-2412], [CXXFLAGS])
511 #include <typeinfo>],
516 } catch (std::exception & e) {
517 return typeid(e).name()[0];
520 AC_DEFINE([USE_RTTI], [1], [Define if the testsuite can use RTTI]),
522 CXXFLAGS=$save_CXXFLAGS
524 dnl Check for time functions.
525 AC_CHECK_FUNCS([sleep gettimeofday ftime])
529 dnl For _ftime64() on mingw we need to tell it we're happy to require
530 dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
531 AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
532 AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
536 dnl Used by tests/soaktest/soaktest.cc
537 AC_CHECK_FUNCS([srandom random])
539 dnl Used by tests/harness/testsuite.cc
540 AC_CHECK_FUNCS([sigaction])
541 AC_MSG_CHECKING([for sigsetjmp and siglongjmp])
542 AC_TRY_COMPILE([#include <setjmp.h>],
543 [sigjmp_buf jb; if (sigsetjmp(jb, 1)) { siglongjmp(jb, 1); }],
544 AC_DEFINE([HAVE_SIGSETJMP], [1], [Define to 1 if you have the `sigsetjmp' function])
545 AC_MSG_RESULT([yes]),
548 dnl Used by tests/harness/cputimer.cc:
549 AC_CHECK_FUNCS([getrusage times sysconf])
551 dnl Used by tests/api_replicate.cc, tests/queryparsertest.cc and
552 dnl tests/termgentest.cc.
554 dnl Solaris < 10 only has putenv().
556 dnl Microsoft have marked putenv() as deprecated, so we use _putenv_s() under
557 dnl MSVC to avoid deprecation warnings. We probe here since mingw doesn't
558 dnl currently (v3.20) provide _putenv_s(), so we can't just use it conditional
559 dnl on __WIN32__ being defined.
560 AC_CHECK_FUNCS([setenv _putenv_s])
562 dnl Check for a more efficient way of closing fds during daemonisation.
563 dnl Apparently closefrom() is available on at least "Solaris 9 or later, NetBSD
564 dnl 3.0 or later, OpenBSD 3.5 or later". If we don't have closefrom(), then
565 dnl dirfd() and getrlimit are useful for an efficient implementation on some
567 AC_CHECK_FUNCS([closefrom dirfd getrlimit])
569 dnl See if ftime returns void (as it does on mingw)
570 AC_MSG_CHECKING([return type of ftime])
571 if test $ac_cv_func_ftime = yes ; then
572 AC_TRY_COMPILE([#include <sys/timeb.h>],
573 [struct timeb tp; int i = ftime(&tp);],
574 AC_MSG_RESULT([int]),
575 AC_MSG_RESULT([void])
576 AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void]))
579 dnl Check how to find the hostname: uname() in sys/utsname.h, or gethostname()
580 dnl Don't use default includes as inttypes.h is found by Compaq C but not C++
581 dnl so it causes all header probes to fail.
582 AC_CHECK_HEADERS([sys/utsname.h], [], [], [ ])
583 AC_CHECK_FUNCS([gethostname])
585 dnl mingw (for instance) lacks ssize_t
592 AC_CHECK_SIZEOF([int])
593 AC_CHECK_SIZEOF([long])
594 AC_CHECK_SIZEOF([long long])
596 AC_CHECK_HEADERS([sys/types.h])
597 AC_CHECK_SIZEOF([off_t])
599 AC_MSG_CHECKING([for 32 bit integer type])
601 "$ac_cv_sizeof_int") INT32_T=int ;;
602 "$ac_cv_sizeof_long") INT32_T=long ;;
603 "$ac_cv_sizeof_short") INT32_T=short ;;
605 AC_MSG_RESULT([none found])
606 AC_MSG_ERROR([No 32 bit integer type found])
608 AC_MSG_RESULT([$INT32_T])
610 AC_MSG_CHECKING([for 64 bit integer type])
612 "$ac_cv_sizeof_int") INT64_T=int ;;
613 "$ac_cv_sizeof_long") INT64_T=long ;;
614 "$ac_cv_sizeof_long_long") INT64_T='long long' ;;
616 AC_MSG_RESULT([none found])
617 AC_MSG_ERROR([No 64 bit integer type found])
619 AC_MSG_RESULT([$INT64_T])
621 dnl Used to avoid undefined behaviour left shifting file sizes.
622 AC_MSG_CHECKING([for unsigned equivalent of off_t])
623 case $ac_cv_sizeof_off_t in
624 "$ac_cv_sizeof_int") UNSIGNED_OFF_T=unsigned ;;
625 "$ac_cv_sizeof_long") UNSIGNED_OFF_T='unsigned long' ;;
626 "$ac_cv_sizeof_long_long") UNSIGNED_OFF_T='unsigned long long' ;;
628 AC_MSG_RESULT([none found])
629 AC_MSG_ERROR([No unsigned type equivalent to off_t found])
631 AC_DEFINE_UNQUOTED([UNSIGNED_OFF_T], [$UNSIGNED_OFF_T], [Define to an unsigned type equivalent to off_t])
632 AC_MSG_RESULT([$UNSIGNED_OFF_T])
634 dnl Check for perl (needed to generate some sources and documentation).
635 AC_PATH_PROG([PERL], [perl], [])
636 if test x$USE_MAINTAINER_MODE = xyes; then
637 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
640 AC_ARG_ENABLE([documentation],
641 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
642 [case ${enableval} in
644 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
646 [enable_documentation=$USE_MAINTAINER_MODE])
647 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
648 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
650 if test x"$enable_documentation" = xyes ; then
651 dnl Checks for dot. (Diagrams in the documentation)
652 AC_PATH_PROG([DOT], [dot])
653 test -z "$DOT" && AC_MSG_ERROR([dot (part of the graphviz package) is required to build documentation])
654 DOXYGEN_DOT_PATH=`echo "$DOT" | sed 's!/dot$!!'`
655 AC_SUBST([DOXYGEN_DOT_PATH])
657 dnl FIXME: pdflatex is needed to make some more of the documentation but
658 dnl doxygen expects it to be on PATH.
660 dnl Check for makeindex. (Needed to make some more of the documentation)
661 AC_PATH_PROG([MAKEINDEX], [makeindex], [])
662 test -z "$MAKEINDEX" && AC_MSG_ERROR([makeindex is required to build documentation])
664 dnl Check for doxygen. (Needed to make some more of the documentation)
665 AC_PATH_PROG([DOXYGEN], [doxygen], [])
666 test -z "$DOXYGEN" && AC_MSG_ERROR([doxygen is required to build documentation])
668 dnl Check for help2man. (Needed to make man pages from "--help" output).
669 AC_PATH_PROG([HELP2MAN], [help2man], [])
670 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
672 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
673 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
674 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
675 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation])
677 dnl Check for pngcrush, which we optionally use to reduce the size of the
678 dnl PNG files which doxygen generates. We can get by without it, so don't
679 dnl fail here if it's not found.
680 AC_PATH_PROGS([PNGCRUSH], [pngcrush], [])
683 dnl Check whether we need -ldl for dlsym() etc.
684 dnl No longer used...
685 dnl AC_TRY_LINK_FUNC([dlsym], ,
686 dnl [AC_CHECK_LIB([dl], [dlsym], [DL_LIBS="-ldl"])])
687 dnl AC_SUBST([DL_LIBS])
689 dnl Checks for header files.
690 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
691 AC_CHECK_HEADERS([sys/resource.h],
692 [], [], [#include <sys/types.h>])
694 dnl If valgrind is installed and new enough, we use it for leak checking in the
695 dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
696 dnl don't use valgrind.
697 if test -n "${VALGRIND-unset}" ; then
698 AC_PATH_PROG([VALGRIND], [valgrind], [])
699 if test -n "$VALGRIND" ; then
700 dnl Check that the installed valgrind version works, and supports the
701 dnl options we use. This means we won't try to use valgrind < 3.3.0
702 dnl (released 7/12/2007) since before that --log-file didn't expand
703 dnl %p (and appended the process id).
705 dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
707 AC_MSG_CHECKING([if valgrind supports --log-file with %p])
708 vglog=config.vglog.%p.tmp
709 vglogwild="config.vglog.*.tmp*"
711 if $VALGRIND --log-file="$vglog" -q true 2>&AS_MESSAGE_LOG_FD ; then
712 for f in $vglogwild ; do
714 $vglog*) VALGRIND= ;;
717 if test x"$VALGRIND" = x ; then
721 AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
724 dnl The valgrind detected doesn't seem to work! Perhaps this is an
725 dnl x86_64 box with a 32 bit valgrind.
726 AC_MSG_RESULT([$VALGRIND doesn't work])
733 if test -n "$VALGRIND" ; then
734 AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
737 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
738 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
740 if test -n "${EATMYDATA-unset}" ; then
741 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
744 dnl Checks for library functions.
746 AC_CHECK_FUNCS([hstrerror])
749 AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
750 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
751 [[ printf("%s", sys_errlist[0]);]])],
752 [ ac_cv_libc_defines_sys_errlist="yes" ],
753 [ ac_cv_libc_defines_sys_errlist="no"
756 if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
757 AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [1],[Define if your system defines sys_errlist[]])
759 AC_DEFINE([HAVE_DECL_SYS_ERRLIST], [0],[Define if your system defines sys_errlist[]])
762 AC_CACHE_CHECK([if libc defines _sys_errlist], ac_cv_libc_defines__sys_errlist, [
763 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
764 [[ printf("%s", _sys_errlist[0]);]])],
765 [ ac_cv_libc_defines__sys_errlist="yes" ],
766 [ ac_cv_libc_defines__sys_errlist="no"
769 if test "x$ac_cv_libc_defines__sys_errlist" = "xyes" ; then
770 AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [1], [Define if your system defines _sys_errlist[]])
772 AC_DEFINE([HAVE_DECL__SYS_ERRLIST], [0], [Define if your system defines _sys_errlist[]])
775 AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
776 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
777 [[ printf("%i", sys_nerr);]])],
778 [ ac_cv_libc_defines_sys_nerr="yes" ],
779 [ ac_cv_libc_defines_sys_nerr="no"
782 if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
783 AC_DEFINE([HAVE_DECL_SYS_NERR], [1], [Define if your system defines sys_nerr])
785 AC_DEFINE([HAVE_DECL_SYS_NERR], [0], [Define if your system defines sys_nerr])
788 AC_CACHE_CHECK([if libc defines _sys_nerr], ac_cv_libc_defines__sys_nerr, [
789 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
790 [[ printf("%i", _sys_nerr);]])],
791 [ ac_cv_libc_defines__sys_nerr="yes" ],
792 [ ac_cv_libc_defines__sys_nerr="no"
795 if test "x$ac_cv_libc_defines__sys_nerr" = "xyes" ; then
796 AC_DEFINE([HAVE_DECL__SYS_NERR], [1], [Define if your system defines _sys_nerr])
798 AC_DEFINE([HAVE_DECL__SYS_NERR], [0], [Define if your system defines _sys_nerr])
801 dnl Check that snprintf actually works as it's meant to.
803 dnl Linux 'man snprintf' warns:
804 dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
805 dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
806 dnl size argument. Thus, the use of snprintf with early libc4 leads to
807 dnl serious security problems.
809 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C90
810 dnl implementations) return -1 when truncating so check that we get the
811 dnl ISO C90 semantics for the returned length when truncating. If we
812 dnl have a working snprintf but with non-ISO return semantics, handle
813 dnl that case separately as it may still be useful in many cases.
815 dnl mingw has _snprintf so check for that too.
816 AC_MSG_CHECKING([for working ISO C90 conforming snprintf])
817 ac_cv_func_snprintf_noniso=no
818 for func in snprintf _snprintf ; do
826 dnl Return different exit status for each error so we can see which
827 dnl check failed by consulting config.log.
829 char buffer[4] = "abc";
830 int res1 = $func(buffer, 2, "%s", "XYZ");
831 if (memcmp(buffer, "X\0c", 4) != 0) return 2;
832 int res2 = $func(buffer, 2, "%x", 0x12);
833 if (memcmp(buffer, "1\0c", 4) != 0) return 3;
834 if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
835 if (res1 != 3) return 4;
836 if (res2 != 2) return 5;
839 [ac_cv_func_snprintf=$func;break],
841 if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
842 ac_cv_func_snprintf_noniso=$func
844 ac_cv_func_snprintf=no
846 [ac_cv_func_snprintf=unknown;break]
849 AC_MSG_RESULT([$ac_cv_func_snprintf])
850 case $ac_cv_func_snprintf in
852 AC_MSG_CHECKING([for working non-ISO C90 conforming snprintf])
853 AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
854 if test no != "$ac_cv_func_snprintf_noniso" ; then
855 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
856 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
860 dnl be conservative when crosscompiling
863 AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
864 [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
865 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
866 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
870 dnl ***************************
871 dnl * Select modules to build *
872 dnl ***************************
874 dnl Check which database backends should be built.
876 AC_DEFUN([XAPIAN_BACKEND_ENABLE],
877 [AC_ARG_ENABLE([backend_$1],
878 [AS_HELP_STRING([--enable-backend-$1], [build the $1 database backend [default=yes]])],
881 *) AC_MSG_ERROR([Invalid option: '--enable-backend-$1=$enableval']) ;;
882 esac], [enable_backend_$1=yes])
885 dnl When adding a new backend, update INSTALL too.
886 XAPIAN_BACKEND_ENABLE([brass])
887 XAPIAN_BACKEND_ENABLE([chert])
888 XAPIAN_BACKEND_ENABLE([flint])
889 XAPIAN_BACKEND_ENABLE([inmemory])
890 XAPIAN_BACKEND_ENABLE([remote])
892 if test yes = "$enable_backend_brass" ; then
893 dnl We would need to implement a locking strategy for MSDOS before we
894 dnl could build brass there.
896 *djgpp* | *msdos* ) enable_backend_brass=no ;;
900 if test yes = "$enable_backend_chert" ; then
901 dnl We would need to implement a locking strategy for MSDOS before we
902 dnl could build chert there.
904 *djgpp* | *msdos* ) enable_backend_chert=no ;;
908 if test yes = "$enable_backend_flint" ; then
909 dnl We would need to implement a locking strategy for MSDOS before we
910 dnl could build flint there.
912 *djgpp* | *msdos* ) enable_backend_flint=no ;;
917 case $enable_backend_flint$enable_backend_chert$enable_backend_brass in
919 dnl We use zlib for compressing tags in brass/chert/flint. We could
920 dnl automatically disable support if zlib isn't found, but overall that
921 dnl probably does more harm than good - it's most likely that someone just
922 dnl forgot to install the -dev package for zlib.
924 dnl Similarly for uuid support.
926 dnl Check for zlib.h.
927 AC_CHECK_HEADERS([zlib.h], [], [
928 AC_MSG_ERROR([zlib.h not found - required for brass, chert and flint (you may need to install the zlib1g-dev or zlib-devel package)])
931 dnl Check for zlibVersion in -lz.
933 dnl mingw build needs -lzlib or -lzdll.
934 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
935 AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll - required for brass, chert and flint (you may need to install the zlib1g-dev or zlib-devel package)])
937 if test x != x"$LIBS" ; then
938 XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
942 dnl Find the UUID library (from e2fsprogs/util-linux-ng, not the OSSP one).
945 *mingw* | *cygwin*) dnl Use built-in API.
949 dnl Check for uuid/uuid.h (e2fsprogs/util-linux-ng) or uuid.h
950 dnl (FreeBSD/NetBSD).
951 AC_CHECK_HEADERS([uuid/uuid.h], [
952 dnl util-linux-ng's uuid/uuid.h found - check for uuid_generate in
955 AC_SEARCH_LIBS([uuid_generate], [uuid], [], [
956 AC_MSG_ERROR([uuid_generate() not found in -luuid - required for brass, chert and flint (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
958 if test x != x"$LIBS" ; then
959 XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
962 dnl Try uuid.h as found on FreeBSD/NetBSD, with associated code in libc.
963 AC_CHECK_HEADERS([uuid.h], [
964 dnl Check for uuid_create with no extra libraries required.
965 AC_CHECK_FUNC([uuid_create], [], [
966 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)])
969 AC_MSG_ERROR([Neither uuid/uuid.h nor uuid.h found - required for brass, chert and flint (you may need to install the uuid-dev, libuuid-devel or e2fsprogs-devel package)])
975 dnl Older versions of libuuid (such as that on CentOS 4.7) don't have
976 dnl uuid_unparse_lower(), only uuid_unparse().
977 AC_LINK_IFELSE([AC_LANG_CALL([], [uuid_unparse_lower])],
979 AC_DEFINE([HAVE_UUID_UNPARSE_LOWER], [1],
980 [Define to 1 if you have the 'uuid_unparse_lower' function.])
985 AM_CONDITIONAL([USE_WIN32_UUID_API], [test "$use_win32_uuid_api" = 1])
988 if test "$enable_backend_remote" = yes ; then
989 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
993 ]])], [win32=no], [win32=yes])
995 case $host_os-$win32 in
997 dnl For mingw and msvc we have an alternative implementation which
998 dnl doesn't need fork() or socketpair().
1000 dnl We need -lws2_32 for gethostbyname(), etc. Hardcode that knowledge
1001 dnl here because AC_SEARCH_LIBS fails to link the test program (I think
1002 dnl because its prototype has the wrong calling convention).
1003 REMOTE_LIBS=-lws2_32
1006 dnl DJGPP has a dummy implementation of fork which always fails. If
1007 dnl someone actually wanted support, then DJGPP has a pthreads port,
1008 dnl so using threads like we do on Windows would make more sense.
1009 enable_backend_remote=no ;;
1011 dnl On Unix, we need fork and socketpair for the remotebackend.
1012 AC_CHECK_FUNCS([fork])
1014 if test "$ac_cv_func_fork" = no ; then
1015 enable_backend_remote=no
1017 dnl Check if -lsocket is required for socketpair (Solaris needs it).
1018 dnl And on Haiku it's in -lnetwork.
1019 AC_SEARCH_LIBS([socketpair], [socket network], [], [enable_backend_remote=no])
1020 if test "$enable_backend_remote" = yes ; then
1021 AC_DEFINE([HAVE_SOCKETPAIR], [1],
1022 [Define to 1 if you have the 'socketpair' function.])
1023 dnl Check if -lnsl is required for gethostbyname (Solaris needs it).
1024 AC_SEARCH_LIBS([gethostbyname], [nsl], [], [enable_backend_remote=no])
1025 if test "$enable_backend_remote" = yes ; then
1034 if test "$enable_backend_remote" = yes ; then
1036 XAPIAN_LIBS="$XAPIAN_LIBS $REMOTE_LIBS"
1040 AC_ARG_ENABLE([quiet],
1041 [AS_HELP_STRING([--enable-quiet], [enable quiet building [default=no]])],
1042 [case ${enableval} in
1044 *) AC_MSG_ERROR([bad value ${enableval} for --enable-quiet]) ;;
1047 AC_ARG_ENABLE([visibility],
1048 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
1049 [case ${enableval} in
1051 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
1054 dnl Pass `--quiet' to libtool if quiet building is requested. Using an
1055 dnl AC_SUBST-ed value like this allows the choice to be easily overridden
1056 dnl if you want to see exactly what make and libtool are up to - just run
1057 dnl make like this: `make QUIET='
1059 if test yes = "$enable_quiet"; then
1065 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
1068 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
1070 dnl Turn off compilation of anything that we don't have the requirements for
1072 dnl Set conditionals to specify what we compile
1074 AM_CONDITIONAL([BUILD_BACKEND_BRASS], [test yes = "$enable_backend_brass"])
1075 AM_CONDITIONAL([BUILD_BACKEND_CHERT], [test yes = "$enable_backend_chert"])
1076 AM_CONDITIONAL([BUILD_BACKEND_FLINT], [test yes = "$enable_backend_flint"])
1077 AM_CONDITIONAL([BUILD_BACKEND_INMEMORY], [test yes = "$enable_backend_inmemory"])
1078 AM_CONDITIONAL([BUILD_BACKEND_REMOTE], [test yes = "$enable_backend_remote"])
1079 AM_CONDITIONAL([BUILD_BACKEND_BRASS_OR_CHERT_OR_FLINT],
1080 [test nonono != "$enable_backend_brass$enable_backend_chert$enable_backend_flint"])
1082 dnl Used to decide if we should use the zlib-vg.so LD_PRELOAD hack.
1084 if test -n "$VALGRIND" ; then
1086 linux*) use_zlib_vg=yes ;;
1089 AM_CONDITIONAL([USE_ZLIB_VG], [test yes = "$use_zlib_vg"])
1091 dnl See if we have fdatasync, and what libraries are needed for it.
1092 dnl We need to actually check for a declaration as OS X has a dummy
1093 dnl implementation in the library which is not prototyped in any header.
1094 AC_CHECK_DECL([fdatasync(int)], [
1096 AC_SEARCH_LIBS([fdatasync], [rt], [XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"])
1098 AC_CHECK_FUNCS([fdatasync])
1100 [ac_cv_func_fdatasync=no],
1101 [#include <unistd.h>]
1104 AC_CHECK_FUNCS([fsync])
1106 dnl HP-UX has pread and pwrite, but they don't work! Apparently this problem
1107 dnl manifests when largefile support is enabled, and we definitely want that
1108 dnl so don't use pread or pwrite on HP-UX.
1111 AC_MSG_CHECKING([for pread])
1112 AC_MSG_RESULT([present but broken on $host_os])
1113 AC_MSG_CHECKING([for pwrite])
1114 AC_MSG_RESULT([present but broken on $host_os])
1117 AC_CHECK_FUNC([pread],
1118 [AC_DEFINE([HAVE_PREAD], [1],
1119 [Define if pread is available on this system])
1120 AC_MSG_CHECKING([for any prototype needed for pread])
1121 AC_CACHE_VAL([xo_cv_pread_prototype],
1124 'extern "C" ssize_t pread(int, void *, size_t, off_t) throw ();' \
1125 'extern "C" ssize_t pread(int, void *, size_t, off_t);' ; do
1127 #include <sys/types.h>
1132 pread(1, b, 256, 20);
1134 xo_cv_pread_prototype="$p"
1138 if test -z "$xo_cv_pread_prototype"; then
1139 AC_MSG_RESULT([not found])
1140 AC_MSG_ERROR([Failed to find working prototype for pread])
1143 if test " " = "$xo_cv_pread_prototype" ; then
1144 AC_MSG_RESULT([none required])
1146 AC_MSG_RESULT([$xo_cv_pread_prototype])
1147 AC_DEFINE_UNQUOTED([PREAD_PROTOTYPE], [$xo_cv_pread_prototype],
1148 [explicit prototype needed for pread (if any)])
1151 AC_CHECK_FUNC([pwrite],
1152 [AC_DEFINE([HAVE_PWRITE], [1],
1153 [Define if pwrite is available on this system])
1154 AC_MSG_CHECKING([for any prototype needed for pwrite])
1155 AC_CACHE_VAL([xo_cv_pwrite_prototype],
1158 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t) throw ();' \
1159 'extern "C" ssize_t pwrite(int, const void *, size_t, off_t);' ; do
1161 #include <sys/types.h>
1165 const char *p = "hello";
1166 pwrite(1, p, 5, 20);
1168 xo_cv_pwrite_prototype="$p"
1172 if test -z "$xo_cv_pwrite_prototype"; then
1173 AC_MSG_RESULT([not found])
1174 AC_MSG_ERROR([Failed to find working prototype for pwrite])
1177 if test " " = "$xo_cv_pwrite_prototype" ; then
1178 AC_MSG_RESULT([none required])
1180 AC_MSG_RESULT([$xo_cv_pwrite_prototype])
1181 AC_DEFINE_UNQUOTED([PWRITE_PROTOTYPE], [$xo_cv_pwrite_prototype],
1182 [explicit prototype needed for pwrite (if any)])
1188 AC_CHECK_FUNCS([link])
1190 dnl *************************
1191 dnl * Set debugging options *
1192 dnl *************************
1194 dnl Which assertion types to enable in the code.
1196 AC_ARG_ENABLE([assertions],
1197 [AS_HELP_STRING([--enable-assertions], [enable debug assertions (no|partial|yes) [default=no]])],
1201 AC_MSG_ERROR([Invalid option: '--enable-assertions=$enableval']) ;;
1204 AC_ARG_ENABLE([log],
1205 [AS_HELP_STRING([--enable-log], [generate a log of methods called, etc (no|yes|profile) [default=no]])],
1209 AC_MSG_ERROR(['--enable-log=profile' is no longer supported - see https://trac.xapian.org/wiki/ProfilingXapian for alternatives.]) ;;
1211 AC_MSG_ERROR([Invalid option: '--enable-log=$enableval']) ;;
1214 dnl Set defines according to the --enable-assertions and --enable-log options
1217 if test yes = "$enable_assertions" || test partial = "$enable_assertions" ; then
1218 AC_DEFINE([XAPIAN_ASSERTIONS],,
1219 [Define if you want assertions (causes some slow-down)])
1222 if test yes = "$enable_assertions"; then
1223 AC_DEFINE([XAPIAN_ASSERTIONS_PARANOID],,
1224 [Define if you want paranoid assertions (causes significant slow-down)])
1227 if test yes = "$enable_log"; then
1228 AC_DEFINE([XAPIAN_DEBUG_LOG],,
1229 [Define if you want a log of methods called and other debug messages])
1232 dnl ******************************
1233 dnl * Set special compiler flags *
1234 dnl ******************************
1236 dnl Set flags to control warnings (enable more, or disable annoying ones).
1238 if test yes = "$GXX"; then
1239 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
1240 dnl we actually have, as neither is really 100% compatible.
1241 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
1242 *__INTEL_COMPILER*__clang__*)
1243 dnl GCC (since neither substituted):
1245 dnl -Wundef was supported by g++ 3.0 and since we now require GCC >= 3.1,
1246 dnl we can rely on it. -fshow-column was present in GCC 3.1 too.
1248 dnl All the other options were supported by g++ 2.95.
1249 AM_CXXFLAGS="$AM_CXXFLAGS -fshow-column -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual"
1251 dnl The exact format of g++ --version seems to change with almost every
1252 dnl minor release so use the preprocessor macros which should be more
1254 AC_MSG_CHECKING([for version of $CXX])
1255 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
1256 AC_MSG_RESULT([GCC $gxx_version])
1258 case $gxx_version in
1260 AC_MSG_ERROR([Xapian requires GCC 3.1 or later])
1264 case $gxx_version in
1266 dnl -Wstrict-null-sentinel was new in 4.0.1, but for simplicity we
1267 dnl only enable it for GCC >= 4.1.
1269 dnl -Wshadow was supported by g++ 3.0 (though buggy then). But it's
1270 dnl also buggy in 4.0 (at least on Mac OS X) and warns if a parameter
1271 dnl in a static method is the same as a member variable, so only
1272 dnl enable it for GCC >= 4.1.
1273 AM_CXXFLAGS="$AM_CXXFLAGS -Wstrict-null-sentinel -Wshadow" ;;
1275 dnl -Wstrict-overflow was new in GCC 4.2. Higher settings than 1
1276 dnl have proved too noisy.
1278 dnl Also, xapian-core seems to hit an aliasing bug in GCC 4.2:
1279 dnl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35643
1280 dnl GCC 4.1 and 4.3 produce working code. This bug can be avoided
1281 dnl by disabling aliasing with -fno-strict-aliasing, so we do that.
1282 dnl See https://trac.xapian.org/ticket/449 for more details.
1283 AM_CXXFLAGS="$AM_CXXFLAGS -Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -fno-strict-aliasing" ;;
1285 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
1287 AM_CXXFLAGS="$AM_CXXFLAGS -Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -Wlogical-op -Wmissing-declarations" ;;
1289 dnl -Wdouble-promotion was added in GCC 4.6.
1291 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
1292 dnl warns for this case with -Wuninitialized (implied by -W). We
1293 dnl don't intend to use this idiom, so any instances are bugs we'd
1294 dnl like to know about.
1295 AM_CXXFLAGS="$AM_CXXFLAGS -Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -Wlogical-op -Wmissing-declarations"
1296 AM_CXXFLAGS="$AM_CXXFLAGS -Wdouble-promotion -Winit-self" ;;
1300 dnl -Wconversion in older GCC versions is intended to help migration
1301 dnl from K&R to ISO C, and isn't useful for us. In 4.3 it was renamed
1302 dnl to -Wtraditional-conversion and a new -Wconversion added which
1303 dnl sounds useful but is a bit buggy currently. So we should consider
1304 dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
1306 dnl -Wold-style-cast is interesting, but triggers for macros from
1307 dnl system headers (e.g. FD_SET) (tested with GCC 4.4).
1309 dnl Automatically add -Werror if maintainer mode is enabled and we're
1310 dnl using GCC 4.1 or newer. We don't do this for older GCCs as GCC 2.95,
1311 dnl some GCC 3.x compilers, and Apple's GCC 4.0 issue spurious warnings.
1312 if test x$USE_MAINTAINER_MODE = xyes; then
1313 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1319 dnl Intel's compiler (since __clang__ not substituted):
1322 dnl -w1 stops the avalanche of uninteresting "remark" messages.
1323 dnl -wd... disables warnings which don't have good code workarounds.
1324 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
1326 dnl Automatically add -Werror if maintainer mode is enabled.
1327 if test x$USE_MAINTAINER_MODE = xyes; then
1328 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1332 dnl clang (since __INTEL_COMPILER not substituted):
1335 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual"
1336 AM_CXXFLAGS="$AM_CXXFLAGS -Wshadow -Wstrict-overflow=1 -Winit-self -Wmissing-declarations"
1338 dnl Automatically add -Werror if maintainer mode is enabled.
1339 if test x$USE_MAINTAINER_MODE = xyes; then
1340 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
1345 if test no != "$enable_visibility"; then
1346 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
1348 AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
1349 if echo 'int bar() __attribute__((visibility("default"))); int foo() {return 42;}'|$CXX -Werror -fvisibility=hidden -c -oconftest.o -xc++ - >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
1350 AC_MSG_RESULT([yes])
1351 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
1352 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
1358 dnl WARNING_CXXFLAGS is set above.
1359 AM_CXXFLAGS="$AM_CXXFLAGS $WARNING_CXXFLAGS"
1362 XAPIAN_TEST_LINKER_FLAG([-Bsymbolic-functions], [symbolic_functions],
1363 [XAPIAN_LDFLAGS="$XAPIAN_LDFLAGS $flag"])
1365 FP_EXCESS_PRECISION=no
1366 AC_MSG_CHECKING([whether to use SSE instructions on x86])
1369 if test "$enable_sse" = no ; then
1371 FP_EXCESS_PRECISION=yes
1373 dnl Default to sse2.
1374 test "$enable_sse" != yes || enable_sse=sse2
1377 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1378 dnl These options are supported at least as far back as clang 3.0.
1379 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic"
1382 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1383 case $gxx_version in
1384 3.*|4.[[01]].*) dnl -mtune=generic added in GCC 4.2.
1385 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse" ;;
1387 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic" ;;
1391 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
1392 AM_CXXFLAGS="$AM_CXXFLAGS -xarch=$enable_sse"
1395 AC_MSG_RESULT([don't know how to for compiler $CXX])
1401 AC_MSG_RESULT([non-x86 arch ($host_cpu)]) ;;
1403 AC_SUBST([FP_EXCESS_PRECISION])
1406 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
1408 # pragma warning(disable:4800)
1411 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
1412 * shouldn't cause a problem to define it where it's not supported and some
1413 * distros may have backported support, so hardcoding version checks is
1414 * counter-productive.
1416 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
1417 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
1419 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
1420 # define _FORTIFY_SOURCE 2
1423 /* For GCC >= 3.0 (and Intel's C++ compiler, which also defines __GNUC__),
1424 * we can use __builtin_expect to give the compiler hints about branch
1425 * prediction. See HACKING for how to use these.
1427 #if defined __GNUC__
1428 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
1429 * the first argument is always an integer expression, and always 0 or 1, but
1430 * still has the same truth value for the if or while it is used in.
1432 # define rare(COND) __builtin_expect(!!(COND), 0)
1433 # define usual(COND) __builtin_expect(!!(COND), 1)
1435 # define rare(COND) (COND)
1436 # define usual(COND) (COND)
1439 /* With Sun CC 5.13 (Studio 12.4) on Solaris 11.2, <math.h> seems to get
1440 * implicitly included somehow before <cmath>, and compilation fails due
1441 * to 'std::exception' colliding with 'struct exception'. It's not clear
1442 * how to avoid this, so just define the making macro which <cmath> does
1443 * before it includes <math.h>.
1446 # define __MATHERR_RENAME_EXCEPTION
1450 AC_SUBST([AM_CXXFLAGS])
1452 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
1453 CXXFLAGS=$save_CXXFLAGS
1455 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
1456 : ${AUTOM4TE=autom4te}
1457 AC_SUBST([AUTOM4TE])
1459 dnl Libtool sets this (to yes|no|unknown) and we use it in xapian-config.
1460 AC_SUBST([link_all_deplibs_CXX])
1462 dnl Shared library extension.
1464 eval "SHLIBEXT=$shrext_cmds"
1465 AC_SUBST([SHLIBEXT])
1467 dnl Split up the version number into "MAJOR.MINOR.REVISION".
1468 MAJOR_VERSION=`echo "$VERSION"|sed 's/\..*//'`
1469 [MINOR_VERSION=`echo "$VERSION"|sed 's/[^.]*\.//;s/\..*//'`]
1470 [REVISION=`echo "$VERSION"|sed 's/.*\.//;s/_.*$//'`]
1472 dnl **************************
1473 dnl * Build the output files *
1474 dnl **************************
1480 docs/doxygen_api.conf
1481 docs/doxygen_source.conf
1483 cmake/xapian-config.cmake
1484 cmake/xapian-config-version.cmake
1485 pkgconfig/xapian-core"$LIBRARY_VERSION_SUFFIX".pc:pkgconfig/xapian-core.pc.in
1487 AC_CONFIG_FILES([tests/runtest], [chmod +x tests/runtest])
1488 AC_CONFIG_FILES([tests/runsrv], [chmod +x tests/runsrv])
1489 AC_CONFIG_FILES([tests/submitperftest], [chmod +x tests/submitperftest])
1490 AC_CONFIG_FILES([tests/perftest/get_machine_info], [chmod +x tests/perftest/get_machine_info])
1491 AC_CONFIG_FILES([xapian-config], [chmod +x xapian-config])
1492 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
1493 AC_CONFIG_FILES([docs/gen_codestructure_doc], [chmod +x docs/gen_codestructure_doc])
1494 AC_CONFIG_FILES([languages/generate-allsnowballheaders], [chmod +x languages/generate-allsnowballheaders])
1497 dnl There are no files generated by AC_OUTPUT in the following directories
1498 dnl and we need to ensure they exist so that the rest of configure or make
1499 dnl won't fail because they don't exist when srcdir != builddir.
1500 if test yes = "$vpath_build" ; then
1501 for dir in include include/xapian languages queryparser ; do
1502 test -d "$dir" || mkdir "$dir"
1506 dnl Generate include/xapian/version.h:
1508 dnl MAIN_VERSION is VERSION without any _git123 suffix.
1509 MAIN_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$REVISION"
1511 for backend in BRASS CHERT FLINT INMEMORY REMOTE ; do
1512 val=`eval echo "\\\$BUILD_BACKEND_${backend}_TRUE"`
1513 if test -z "$val" ; then
1514 cxxcpp_flags="$cxxcpp_flags -DXAPIAN_HAS_${backend}_BACKEND"
1517 dnl For GCC (and compilers which pretend to be GCC) and MSVC, we create some
1518 dnl ABI checks in the generated version.h, and $CXXFLAGS may contain options
1519 dnl which affect the ABI (e.g. -fabi-version for GCC) so we want to use these
1520 dnl options when generating version.h. For these compilers, CXXCPP="$CXX -E"
1521 dnl so it should understand all compiler options.
1523 dnl For other compilers, we only pass $CPPFLAGS to $CXXCPP in case it's an
1524 dnl external cpp which doesn't understand flags which might be in $CXXFLAGS.
1525 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __GNUC__
1531 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS $CXXFLAGS"],
1532 [cxxcpp_flags="$cxxcpp_flags $CPPFLAGS"])
1533 rm -f include/xapian/version.h.tmp
1534 dnl "\r" in sed is a GNUism, but we only need to remove it on MS Windows
1535 dnl where we'll always have GNU sed, and other sed's will just interpret
1536 dnl it as "r" (Solaris sed) or maybe literal "\r" which won't match.
1538 dnl Use @@ around $MAIN_VERSION so we get " in the final output.
1539 $CXXCPP $cxxcpp_flags\
1540 -DSTRING_VERSION="\"@@$MAIN_VERSION@@\""\
1541 -DMAJOR_VERSION="\"$MAJOR_VERSION\""\
1542 -DMINOR_VERSION="\"$MINOR_VERSION\""\
1543 -DREVISION="\"$REVISION\""\
1545 $srcdir/include/xapian/version_h.cc|\
1546 ${SED-sed} '/"/!d;s/^ *//;/^#/d;s/ *$//;s/" *,//;s/"//g;s/@@/"/g;s/ */ /g;s/ *,\r$//;s/ *,$//'\
1547 > include/xapian/version.h.tmp
1548 dnl Only update the file if it has changed, so we don't alter the timestamp
1549 dnl and cause lots of rebuilding needlessly. However, the build system
1550 dnl needs a timestamp to know when to regenerate version.h because version_h.cc
1551 dnl has changed so we use a separate timestamp file.
1552 touch include/xapian/version.h.timestamp
1553 if cmp include/xapian/version.h.tmp include/xapian/version.h >/dev/null 2>&1
1555 rm include/xapian/version.h.tmp
1557 mv include/xapian/version.h.tmp include/xapian/version.h