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 m4_define([project_version], [1.5.0])
6 AC_INIT([xapian-letor], project_version, [https://xapian.org/bugs])
9 dnl Extract from the libtool info manual:
11 dnl Here are a set of rules to help you update your library version information:
13 dnl 1. Start with version information of '0:0:0' for each libtool library.
15 dnl 2. Update the version information only immediately before a public
16 dnl release of your software. More frequent updates are unnecessary,
17 dnl and only guarantee that the current interface number gets larger
20 dnl 3. If the library source code has changed at all since the last
21 dnl update, then increment REVISION ('C:R:A' becomes 'C:r+1:A').
23 dnl 4. If any interfaces have been added, removed, or changed since the
24 dnl last update, increment CURRENT, and set REVISION to 0.
26 dnl 5. If any interfaces have been added since the last public release,
27 dnl then increment AGE.
29 dnl 6. If any interfaces have been removed since the last public release
30 dnl then set AGE to 0.
32 dnl LIBRARY_VERSION_INFO for libxapianletor:
33 dnl 0:0:0 1.3.1 First release with xapian-letor split out from xapian-core
34 LIBRARY_VERSION_INFO=0:0:0
35 AC_SUBST(LIBRARY_VERSION_INFO)
37 dnl Where xapian-letor.h, etc go. In development release append "/xapian-1.3".
41 dnl Libtool sets this (to yes|no|unknown) and we use it in xapianletor-config.
42 AC_SUBST([link_all_deplibs_CXX])
44 AM_INIT_AUTOMAKE([1.13 -Wportability tar-ustar no-dist-gzip dist-xz std-options])
46 AC_CONFIG_SRCDIR([ranker/ranker.cc])
48 AC_CONFIG_HEADERS([config.h])
50 AC_CONFIG_MACRO_DIRS([m4])
54 dnl Use libtool to manage our libraries.
56 dnl Default to only building shared libraries.
58 dnl Building both shared and static means having to compile the files which
59 dnl make up the library twice on most platforms. Shared libraries are the
60 dnl better option for most users, and if anyone really wants static libraries,
61 dnl they can configure with --enable-static (or --enable-static=xapian-core if
62 dnl configuring a combined tree with the bindings).
64 dnl We don't export any data items from the library, so it should be safe to
65 dnl enable win32-dll without decorating any declarations specially.
66 LT_INIT([disable-static win32-dll])
68 dnl Only pass -no-undefined on platforms where it is required in order to link
69 dnl a shared library at all (Microsoft Windows is the main one) as it can cause
70 dnl problems on other platforms (e.g. Solaris with Sun CC in C++11 mode, though
71 dnl we don't support that compiler now as it lacks C++17 support).
73 if test unsupported = "$allow_undefined_flag" ; then
74 NO_UNDEFINED=-no-undefined
76 AC_SUBST(NO_UNDEFINED)
78 dnl disable "maintainer only" rules by default
81 dnl Checks for programs.
86 # Checked: dragonfly6.4 freebsd8.0 netbsd9.3 openbsd4.6 solaris2.9 solaris2.10
88 linux* | k*bsd*-gnu | dragonfly* | freebsd* | netbsd* | openbsd* | solaris*)
89 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
90 link_all_deplibs_CXX=no
96 dnl Extract search path from ldconfig which is more reliable than the way
97 dnl vanilla libtool extracts them from ld.so.conf.
98 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
99 test -z "$d" || sys_lib_dlsearch_path_spec=$d
104 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
105 dnl On these platforms, libtool emits a warning if -no-install is passed,
106 dnl and uses -no-fast-install instead - the least ugly way to avoid that
107 dnl warnings seems to be to duplicate the above list of platforms from
108 dnl libtool and use -no-fast-install on them directly.
109 NO_INSTALL=-no-fast-install ;;
111 NO_INSTALL=-no-install ;;
113 AC_SUBST([NO_INSTALL])
115 dnl Probe for any options needed to enable C++17 support.
116 AX_CXX_COMPILE_STDCXX([17])
118 dnl We don't use a C compiler to compile Xapian's code, but on some platforms
119 dnl (e.g. mingw) libtool uses $LTCC which defaults to $CC, and it's also use to
120 dnl build auxiliary tools like snowball and lemon.
123 dnl Check endianness.
126 dnl Run tests using the C++ compiler.
129 dnl Check for xapian-core.
130 XO_LIB_XAPIAN([], [],
131 [xapian-config]regexp(project_version,
132 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
135 dnl Enable large file support if possible.
137 dnl With xlC on AIX, -D_LARGE_FILES changes the ABI of std::string, so it
138 dnl also needs to be used when compiling user code.
139 abi_affecting_cxxflags=
140 if $GREP '^#define _LARGE_FILES 1$' confdefs.h > /dev/null 2>&1 ; then
141 abi_affecting_cxxflags=-D_LARGE_FILES
143 AC_SUBST([abi_affecting_cxxflags])
146 AC_SUBST([XAPIANLETOR_LDFLAGS])
148 AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
149 #if defined __WIN32__ || defined _WIN32
152 ]])], [win32=no], [win32=yes])
154 xo_fn_unknown_option_check() {
155 dnl Some compilers don't error out on unknown options which unhelpfully
156 dnl means we would think the option is supported, use it, and end up
157 dnl with a warning or note diagnostic every time we use the option.
159 dnl Check compiler stderr for known strings:
160 dnl * MSVC: Command line warning D9002 : ignoring unknown option '...'
161 dnl * MSVC: LINK : warning LNK4044: unrecognized option '...'; ignored
162 dnl * icc strings cribbed from automake's depend.m4
163 $GREP 'ignoring unknown option' conftest.err >/dev/null 2>&1 ||
164 $GREP 'unrecognized option' conftest.err >/dev/null 2>&1 ||
165 $GREP 'ignoring option' conftest.err >/dev/null 2>&1 ||
166 $GREP 'not supported' conftest.err >/dev/null 2>&1 ||
171 AC_DEFUN([XAPIAN_TEST_FLAGS_],
173 m4_define([cachevar],
174 [xo_cv_]m4_tolower(m4_bpatsubst([$1][_$3], [[^A-Za-z0-9]], [_])))
175 AC_CACHE_CHECK([for $CXX with $3 in $1], cachevar,
179 $2([AC_LANG_PROGRAM([], [])],
180 [if xo_fn_unknown_option_check ; then
187 if test "$cachevar" = yes ; then
196 dnl Test if compiling works with $1 added to CXXFLAGS; if it does, add $1 to
197 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
198 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
199 [XAPIAN_TEST_FLAGS_([CXXFLAGS], [AC_COMPILE_IFELSE], [$1], [$2], [$3], [$4])])
201 dnl Test if linking works with $1 added to LDFLAGS; if it does, add $1 to
202 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
203 AC_DEFUN([XAPIAN_TEST_LDFLAGS],
204 [XAPIAN_TEST_FLAGS_([LDFLAGS], [AC_LINK_IFELSE], [$1], [$2], [$3], [$4])])
206 dnl Preserve the default CXXFLAGS.
207 save_CXXFLAGS=$CXXFLAGS
209 dnl x86 has excess precision issues with 387 FP instructions, which are
210 dnl avoided by using SSE instructions instead. This is also faster (~6% in
211 dnl a CPU bound testcase).
213 [AS_HELP_STRING([--disable-sse],
214 [disable use of SSE FP instructions on x86])]
215 [AS_HELP_STRING([[--enable-sse[=sse|sse2]]],
216 [set which SSE FP instructions to use on x86 (default: sse2)])],
217 [case ${enableval} in
219 *) AC_MSG_ERROR([bad value ${enableval} for --enable-sse or --disable-sse]) ;;
223 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
224 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
226 dnl We need to specify the argument types for builtin functions, or else
227 dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
228 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
229 __builtin_sub_overflow(int, int, int*),
230 __builtin_mul_overflow(int, int, int*)], [], [], [ ])
231 AC_CHECK_DECLS([__builtin_bswap16(uint16_t),
232 __builtin_bswap32(uint32_t),
233 __builtin_bswap64(uint64_t)], [], [],
234 [#include <stdint.h>])
235 AC_CHECK_DECLS([_byteswap_ushort, _byteswap_ulong, _byteswap_uint64], [], [],
236 [#include <stdlib.h>])
237 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
238 AC_CHECK_DECLS([_addcarry_u32(unsigned char, unsigned, unsigned, unsigned*),
239 _addcarry_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*),
240 _subborrow_u32(unsigned char, unsigned, unsigned, unsigned*),
241 _subborrow_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*)],
242 [], [], [#include <intrin.h>])
244 dnl Check for time functions.
245 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
247 dnl Used by tests/harness/testsuite.cc
248 AC_CHECK_FUNCS([sigaction])
249 dnl These can be macros (and sigsetjmp is with glibc at least).
250 AC_CHECK_DECLS([sigsetjmp, siglongjmp], [], [], [#include <setjmp.h>])
252 dnl Used by tests/harness/cputimer.cc:
253 AC_CHECK_FUNCS([getrusage times sysconf])
255 dnl Used by tests/harness/unixcmd.cc
256 AC_CHECK_FUNCS([nftw])
258 dnl mingw (for instance) lacks ssize_t
265 dnl Check for perl (needed to generate some sources and documentation).
266 AC_PATH_PROG([PERL], [perl], [])
267 AC_ARG_VAR([PERL], [Perl interpreter])
268 if test x$USE_MAINTAINER_MODE = xyes; then
269 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
272 AC_ARG_ENABLE([documentation],
273 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
274 [case ${enableval} in
276 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
278 [enable_documentation=$USE_MAINTAINER_MODE])
279 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
280 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
282 if test x"$enable_documentation" = xyes ; then
283 dnl Check for help2man. (Needed to make man pages from "--help" output).
284 AC_PATH_PROG([HELP2MAN], [help2man], [])
285 AC_ARG_VAR([HELP2MAN], [help2man man page generator])
286 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
288 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
289 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
290 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
291 AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
292 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
295 dnl Checks for header files.
296 AC_CHECK_HEADERS([fcntl.h limits.h sys/select.h sysexits.h],
299 dnl cxxabi.h was added in GCC 3.1, but clang lies and defines __GNUC__ yet
300 dnl doesn't seem to reliably provide this header, so probe for it.
301 AC_CHECK_HEADERS([cxxabi.h], [], [], [ ])
303 dnl If valgrind is installed and new enough, we use it for leak checking in the
304 dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
305 dnl don't use valgrind. On macOS only use valgrind if VALGRIND is set to a
306 dnl no empty value, as valgrind on macOS gives a lot of false positives.
307 use_valgrind_if_non_empty=
310 use_valgrind_if_non_empty=$VALGRIND ;;
312 use_valgrind_if_non_empty=${VALGRIND-unset} ;;
315 if test -n "$use_valgrind_if_non_empty" ; then
316 AC_PATH_PROG([VALGRIND], [valgrind], [])
317 AC_ARG_VAR([VALGRIND], [debugging tool (optionally used by test harness)])
318 if test -n "$VALGRIND" ; then
319 dnl Check that the installed valgrind version works, and supports the
320 dnl options we use. This means we won't try to use valgrind < 3.3.0
321 dnl (released 7/12/2007) since before that --log-file didn't expand
322 dnl %p (and appended the process id).
324 dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
326 AC_MSG_CHECKING([if valgrind supports --log-file with %p and --child-silent-after-fork=yes])
327 vglog=config.vglog.%p.tmp
328 vglogwild="config.vglog.*.tmp*"
330 if $VALGRIND --log-file="$vglog" --child-silent-after-fork=yes -q true 2>&AS_MESSAGE_LOG_FD ; then
331 for f in $vglogwild ; do
333 $vglog*) VALGRIND= ;;
336 if test x"$VALGRIND" = x ; then
340 AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
343 dnl The valgrind detected doesn't seem to work! Perhaps this is an
344 dnl x86_64 box with a 32 bit valgrind.
345 AC_MSG_RESULT([$VALGRIND doesn't work])
352 if test -n "$VALGRIND" ; then
353 AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
356 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
357 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
359 if test -n "${EATMYDATA-unset}" ; then
360 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
361 AC_ARG_VAR([EATMYDATA], [wrapper to disable fsync (optionally used by test harness)])
364 dnl Checks for library functions.
367 AC_CACHE_CHECK([for sys_errlist and sys_nerr], xo_cv_sys_errlist_and_sys_nerr, [
368 AC_LINK_IFELSE([AC_LANG_PROGRAM(
369 dnl On Linux, sys_errlist and sys_nerr need <stdio.h>, though the man page
370 dnl says <errno.h>. The man page seems to match other platforms such as
371 dnl NetBSD, so include both headers to ensure we get them. With mingw and MSVC
372 dnl they're provided by <stdlib.h>.
375 #include <stdlib.h>]],
376 [[ printf("%s", sys_errlist[sys_nerr - 1]);]])],
377 [ xo_cv_sys_errlist_and_sys_nerr=yes ],
378 [ xo_cv_sys_errlist_and_sys_nerr=no ])
380 if test "x$xo_cv_sys_errlist_and_sys_nerr" = "xyes" ; then
381 AC_DEFINE([HAVE_SYS_ERRLIST_AND_SYS_NERR], [1],[Define if you have 'sys_errlist' and 'sys_nerr'])
384 AC_CACHE_CHECK([for _sys_errlist and _sys_nerr], xo_cv__sys_errlist_and__sys_nerr, [
385 AC_LINK_IFELSE([AC_LANG_PROGRAM(
388 #include <stdlib.h>]],
389 [[ printf("%s", _sys_errlist[_sys_nerr - 1]);]])],
390 [ xo_cv__sys_errlist_and__sys_nerr=yes ],
391 [ xo_cv__sys_errlist_and__sys_nerr=no
394 if test "x$xo_cv__sys_errlist_and__sys_nerr" = "xyes" ; then
395 AC_DEFINE([HAVE__SYS_ERRLIST_AND__SYS_NERR], [1],[Define if you have '_sys_errlist' and '_sys_nerr'])
398 dnl GNU-specific replacement for sys_errlist and sys_nerr.
399 AC_CHECK_FUNCS([strerrordesc_np])
403 case $host_os-$win32 in
405 dnl For mingw and msvc we have an alternative implementation which
406 dnl doesn't need fork() or socketpair().
409 dnl DJGPP has a dummy implementation of fork which always fails. If
410 dnl someone actually wanted remote backend support, then DJGPP has a
411 dnl pthreads port, so using threads like we do on Windows would make more
415 dnl On Unix, we need fork and socketpair for the remotebackend.
417 AC_CHECK_FUNCS([fork], [], [
418 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.])
420 dnl Check if -lsocket is required for socketpair (Solaris needs it).
421 dnl And on Haiku it's in -lnetwork.
422 AC_SEARCH_LIBS([socketpair], [socket network], [], [
423 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.])
425 AC_DEFINE([HAVE_SOCKETPAIR], [1],
426 [Define to 1 if you have the 'socketpair' function.])
433 AC_ARG_ENABLE([visibility],
434 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
435 [case ${enableval} in
437 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
441 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
444 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
446 dnl Decide if we should use the zlib-vg.so LD_PRELOAD hack.
448 if test -n "$VALGRIND" ; then
450 linux*) use_zlib_vg=yes ;;
453 AM_CONDITIONAL([USE_ZLIB_VG], [test yes = "$use_zlib_vg"])
455 AC_MSG_CHECKING([for directory separator(s)])
456 case $host_os-$win32 in
457 *-yes | cygwin* | msys* | os2* | *djgpp* | *msdos* )
458 AC_MSG_RESULT([/ and \\])
459 AC_DEFINE([DIR_SEPS], ["/\\"], [directory separator(s) as a character or string literal])
460 AC_DEFINE([DIR_SEPS_LIST], [{ '/', '\\' }], [directory separator(s) as an initialiser list])
464 AC_DEFINE([DIR_SEPS], ['/'], [directory separator(s) as a character or string literal])
465 AC_DEFINE([DIR_SEPS_LIST], [{ '/' }], [directory separator(s) as an initialiser list])
469 dnl ******************************
470 dnl * Set special compiler flags *
471 dnl ******************************
473 AC_ARG_ENABLE([werror],
474 [AS_HELP_STRING([--enable-werror], [enable treating compiler warnings as errors [default=maintainer-mode]])],
475 [case ${enableval} in
477 *) AC_MSG_ERROR([bad value ${enableval} for --enable-werror]) ;;
479 [enable_werror=$USE_MAINTAINER_MODE])
481 dnl Put -Werror or equivalent in its own make variable so that it can easily
482 dnl be overridden by `make WERROR=` if needed during development (e.g. if
483 dnl you want to get a full list of compile warnings to fix rather than
484 dnl stopping at the first file with warnings).
488 dnl Set flags to control warnings (enable more, or disable annoying ones).
490 if test yes = "$GXX"; then
491 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
492 dnl we actually have, as neither is really 100% compatible.
493 echo __INTEL_COMPILER __clang__ > conftest.cc
494 case `$CXX -E conftest.cc 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
495 *__INTEL_COMPILER*__clang__*)
496 dnl GCC (since neither substituted):
498 dnl The exact format of g++ --version seems to change with almost every
499 dnl minor release so use the preprocessor macros which should be more
500 dnl robust. Pass -xc++ to avoid warnings about any command-line options
501 dnl included in $CXX which aren't valid for C (such as -std=c++17).
502 AC_MSG_CHECKING([for version of $CXX])
503 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -xc++ -E -|sed '/^#/d;s/ //g'`
504 AC_MSG_RESULT([GCC $gxx_version])
506 dnl -Wundef was supported by g++ 3.0.
508 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
511 dnl -Wdouble-promotion was added in GCC 4.6.
513 dnl -Wduplicated-cond was added in GCC 6.
515 dnl -Wduplicated-branches was added in GCC 7.
517 dnl All the other options were supported by g++ 2.95.
518 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 -Wduplicated-cond -Wduplicated-branches"
522 AC_MSG_ERROR([Xapian requires GCC 7.0 or later])
527 dnl -Wold-style-cast is interesting, but triggers for macros from
528 dnl system headers (e.g. FD_SET). GCC 4.8 improved this by making
529 dnl -ftrack-macro-expansion=2 the default, but we still see such
530 dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
531 dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
532 dnl warnings from zlib.h).
537 dnl Intel's compiler (since __clang__ not substituted):
539 dnl -w1 stops the avalanche of uninteresting "remark" messages.
540 dnl -wd... disables warnings which don't have good code workarounds.
541 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
546 dnl clang (since __INTEL_COMPILER not substituted):
548 dnl These options all work at least as far back as clang++ 3.0:
549 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"
556 if test no != "$enable_visibility"; then
557 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
558 dnl supported on mingw and visibility attributes result in warnings).
559 AC_MSG_CHECKING([if $CXX -fvisibility=hidden -fvisibility-inlines-hidden works])
560 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
562 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden -fvisibility-inlines-hidden"
563 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
568 elif test yes = "$msvc"; then
569 dnl -W1 is command-line default, -W3 IDE default, -W4 highest numbered level.
570 dnl AM_CXXFLAGS="$AM_CXXFLAGS -W4"
575 AC_MSG_CHECKING([for option to turn warnings into errors])
576 if test x$enable_werror != xyes; then
578 AC_MSG_RESULT([not requested])
579 elif test -z "$WERROR" ; then
580 AC_MSG_RESULT([unknown for $CXX])
582 AC_MSG_RESULT([$WERROR])
585 XAPIAN_TEST_LDFLAGS([-Wl,-Bsymbolic-functions], [XAPIANLETOR_LDFLAGS])
587 AC_MSG_CHECKING([whether to use SSE instructions on x86])
590 if test "$enable_sse" = no ; then
592 if test yes = "$msvc"; then
593 dnl MSVC defaults to SSE2.
594 AM_CXXFLAGS="$AM_CXXFLAGS -arch:IA32"
598 test "$enable_sse" != yes || enable_sse=sse2
599 if test yes = "$GXX"; then
600 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
601 dnl We can unconditionally use -mtune=generic as it was added in GCC
602 dnl 4.2, and supported at least as far back as clang 3.0.
603 AM_CXXFLAGS="$AM_CXXFLAGS -mfpmath=sse -m$enable_sse -mtune=generic"
604 elif test yes = "$msvc"; then
605 AC_MSG_RESULT([yes (configure with --disable-sse to disable)])
606 if test sse = "$enable_sse"; then
607 dnl MSVC defaults to SSE2.
608 AM_CXXFLAGS="$AM_CXXFLAGS -arch:SSE"
611 AC_MSG_RESULT([don't know how to for compiler $CXX])
616 AC_MSG_RESULT([non-x86 arch ($host_cpu)]) ;;
619 if test "$GXX" = yes; then
620 dnl Default to enabling _FORTIFY_SOURCE at level 2. It shouldn't cause a
621 dnl problem to define it where it's not supported, but we need to check for
622 dnl an issue on mingw-w64 where some versions required linking with -lssp
623 dnl (this was fixed in v11.0.0 released 2023-04-28). We detect this with a
624 dnl configure-time link test and don't auto-enable _FORTIFY_SOURCE if using
625 dnl an affected version.
626 AC_MSG_CHECKING([if _D_FORTIFY_SOURCE=2 links without extra libraries])
627 save_CPPFLAGS=$CPPFLAGS
628 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
629 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
631 static char a[20], b[10];]], [[
634 [AC_MSG_RESULT([yes])
635 AC_DEFINE([FORTIFY_SOURCE_OK], [1], [Define to 1 if '-D_FORTIFY_SOURCE=2' link test passes])],
636 [AC_MSG_RESULT([no])])
637 CPPFLAGS=$save_CPPFLAGS
641 [/* Disable stupid MSVC warnings. */
643 /* Passing an empty parameter to a single parameter macro. */
644 # pragma warning(disable:4003)
645 /* Assignment in conditional expression; other compilers suppress with extra parentheses but not MSVC. */
646 # pragma warning(disable:4706)
647 /* A "performance" warning for converting int to bool. */
648 # pragma warning(disable:4800)
650 /* POSIX get to deprecate POSIX things, not Microsoft. */
651 # ifndef _CRT_NONSTDC_NO_WARNINGS
652 # define _CRT_NONSTDC_NO_WARNINGS
654 # ifndef _CRT_SECURE_NO_WARNINGS
655 # define _CRT_SECURE_NO_WARNINGS
660 /* MSVC defines _WIN32 but not __WIN32__. */
661 #if !defined __WIN32__ && defined _WIN32
665 /* MSVC defines _WIN64 but not __WIN64__. */
666 #if !defined __WIN64__ && defined _WIN64
670 /* Default to enabling _FORTIFY_SOURCE at level 2 for GCC-like compilers. It
671 * shouldn't cause a problem to define it where it's not supported.
673 * The FORTIFY_SOURCE_OK check avoids auto-enabling on some mingw-w64 versions
674 * which required linking with -lssp too. This was addressed in v11.0.0
675 * (released 2023-04-28).
677 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
678 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1" or
681 #if defined FORTIFY_SOURCE_OK && !defined _FORTIFY_SOURCE
682 # define _FORTIFY_SOURCE 2
685 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
686 * we can use __builtin_expect to give the compiler hints about branch
687 * prediction. See HACKING for how to use these.
689 #if HAVE_DECL___BUILTIN_EXPECT
690 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
691 * the first argument is always an integer expression, and always 0 or 1, but
692 * still has the same truth value for the if or while it is used in.
694 # define rare(COND) __builtin_expect(!!(COND), 0)
695 # define usual(COND) __builtin_expect(!!(COND), 1)
697 # define rare(COND) (COND)
698 # define usual(COND) (COND)
702 AC_DEFINE([XAPIAN_LIB_BUILD], [1], [Workaround for avoiding sub-header included error])
704 AC_SUBST([AM_CXXFLAGS])
706 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
707 CXXFLAGS=$save_CXXFLAGS
709 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
710 : ${AUTOM4TE=autom4te}
713 dnl We want to be able to use GNU make % pattern rules in maintainer targets
714 dnl but automake warns these aren't portable, so we substitute the % to avoid
719 dnl **************************
720 dnl * Build the output files *
721 dnl **************************
727 cmake/xapianletor-config.cmake
728 cmake/xapianletor-config-version.cmake
730 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
731 AC_CONFIG_FILES([tests/runtest], [chmod +x tests/runtest])
732 AC_CONFIG_FILES([xapianletor-config], [chmod +x xapianletor-config])