1 dnl Process this file with autoconf to produce a configure script.
3 m4_define([project_version], [1.4.26])
4 AC_INIT([xapian-omega], project_version, [https://xapian.org/bugs])
6 AM_INIT_AUTOMAKE([1.11 -Wportability subdir-objects tar-ustar no-dist-gzip dist-xz])
8 AC_CONFIG_SRCDIR([omega.cc])
10 AC_CONFIG_HEADERS([config.h])
12 AC_CONFIG_MACRO_DIR([m4])
16 dnl The AM_ICONV macro requires a stack of macros including AC_LIB_PROG_LD,
17 dnl which is just a copy of libtool's LT_PATH_LD with the name changed.
18 dnl We will already have run LT_PATH_LD, so make AC_LIB_PROG_LD a no-op
19 dnl as LT_PATH_LD will already have set the with_gnu_ld variable.
20 AC_DEFUN([AC_LIB_PROG_LD], [])
25 dnl -no-undefined causes problems on Solaris with Sun CC in C++11 mode, so only
26 dnl pass -no-undefined on platforms where it is required in order to link a
27 dnl shared library at all (Windows is the main one).
29 if test unsupported = "$allow_undefined_flag" ; then
30 NO_UNDEFINED=-no-undefined
32 AC_SUBST(NO_UNDEFINED)
34 dnl disable "maintainer only" rules by default
37 dnl Checks for programs.
42 # Checked: dragonfly6.4 freebsd8.0 netbsd9.3 openbsd4.6 solaris2.9 solaris2.10
44 linux* | k*bsd*-gnu | dragonfly* | freebsd* | netbsd* | openbsd* | solaris*)
45 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
46 link_all_deplibs_CXX=no
52 dnl Extract search path from ldconfig which is more reliable than the way
53 dnl vanilla libtool extracts them from ld.so.conf.
54 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
55 test -z "$d" || sys_lib_dlsearch_path_spec=$d
60 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
61 dnl On these platforms, libtool emits a warning if -no-install is passed,
62 dnl and uses -no-fast-install instead - the least ugly way to avoid that
63 dnl warnings seems to be to duplicate the above list of platforms from
64 dnl libtool and use -no-fast-install on them directly.
65 NO_INSTALL=-no-fast-install ;;
67 NO_INSTALL=-no-install ;;
69 AC_SUBST([NO_INSTALL])
71 dnl Probe for any options needed to enable C++11 support.
72 AX_CXX_COMPILE_STDCXX([11])
74 dnl Run tests using the C++ compiler.
77 dnl Enable large file support if possible.
80 dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
81 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
82 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
84 XTC_save_CXXFLAGS=$CXXFLAGS
85 CXXFLAGS="$CXXFLAGS $1"
86 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
87 [CXXFLAGS=$XTC_save_CXXFLAGS
90 [CXXFLAGS=$XTC_save_CXXFLAGS
94 dnl Check for xapian-core.
96 [xapian-config]regexp(project_version,
97 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
100 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
101 save_CXXFLAGS=$CXXFLAGS
102 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
104 dnl We need to specify the argument types for builtin functions, or else
105 dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
106 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
107 __builtin_sub_overflow(int, int, int*),
108 __builtin_mul_overflow(int, int, int*)], [], [], [ ])
109 AC_CHECK_DECLS([__builtin_bswap32(uint32_t)], [], [],
110 [#include <stdint.h>])
111 AC_CHECK_DECLS([_byteswap_ulong], [], [],
112 [#include <stdlib.h>])
113 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
114 AC_CHECK_DECLS([_addcarry_u32(unsigned char, unsigned, unsigned, unsigned*),
115 _addcarry_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*),
116 _subborrow_u32(unsigned char, unsigned, unsigned, unsigned*),
117 _subborrow_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*)],
118 [], [], [#include <intrin.h>])
120 dnl Check for time functions.
122 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
123 AC_CHECK_FUNCS([gmtime_r timegm])
127 dnl For _ftime64() on mingw we need to tell it we're happy to require
128 dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
129 AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
130 AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
134 AC_ARG_ENABLE(documentation,
135 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
136 [case ${enableval} in
138 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
140 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
141 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
142 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
145 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
148 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
150 dnl Check for headers.
151 AC_CHECK_HEADERS([strings.h sys/select.h], [], [], [ ])
152 AC_CHECK_HEADERS([sys/time.h]dnl
153 [sys/resource.h sys/socket.h sys/sysctl.h vm/vm_param.h]dnl
154 [sys/vmmeter.h sys/sysmp.h sys/sysinfo.h sys/pstat.h],
155 [], [], [#include <sys/types.h>])
157 dnl Check for zlib.h.
158 AC_CHECK_HEADERS([zlib.h], [], [
159 AC_MSG_ERROR([zlib.h not found])
162 dnl Check for zlibVersion in -lz.
165 dnl mingw build needs -lzlib or -lzdll.
166 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
167 AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll (you may need to install the zlib1g-dev or zlib-devel package)])
170 AC_SUBST([ZLIB_LIBS])
173 dnl POSIX requires setenv(). The final Unix-like platform without it seems
174 dnl to have been Solaris 9, which is now out of support.
176 dnl Microsoft don't provide setenv() and have marked putenv() as deprecated, so
177 dnl we use _putenv_s() to avoid deprecation warnings with MSVC. It's also a
178 dnl more similar interface to setenv() so easier to implement a setenv() wrapper
179 dnl around. We probe for both the function and a declaration since mingw
180 dnl doesn't currently (v3.20) declare it but it is present in the C runtime DLL
181 dnl so we can provide our own declaration to access it.
182 AC_CHECK_FUNCS([setenv _putenv_s])
183 AC_CHECK_DECLS([_putenv_s(const char*, const char*)], [], [],
184 [#include <stdlib.h>])
186 dnl See if we have closefrom(), or some functions that are useful to implement
187 dnl closefrom() on platforms which don't provide it.
188 AC_CHECK_FUNCS([closefrom getdirentries getrlimit])
190 if test $ac_cv_func_ftime = yes ; then
191 dnl See if ftime returns void (as it does on mingw)
192 AC_MSG_CHECKING([return type of ftime])
194 [AC_LANG_PROGRAM([[#include <sys/timeb.h>]],
195 [[struct timeb tp; int i = ftime(&tp);]])],
196 [AC_MSG_RESULT([int])],
197 [AC_MSG_RESULT([void])
198 AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void])])
201 dnl mingw (for instance) lacks ssize_t
208 XAPIAN_TYPE_SOCKLEN_T
210 dnl Used by omegatest to skip some testcases with 32-bit time_t.
211 AC_CHECK_SIZEOF([time_t], [#include <time.h>])
213 dnl Use for Unix permission checks.
214 AC_CHECK_FUNCS([getgrouplist])
216 dnl See if getgrouplist() takes gid_t * (e.g. Linux) or int * (e.g. macOS).
217 if test $ac_cv_func_getgrouplist = yes ; then
219 [AC_LANG_PROGRAM([[#include <grp.h>
220 #include <unistd.h>]],
221 [[int g[10]; int n = 10; return getgrouplist("root", 1, g, &n) == -1;]])],
222 [AC_DEFINE([GETGROUPLIST_TAKES_INT_P], 1, [Define if getgrouplist takes int *])],
226 dnl Check for lstat() (not available under mingw for example).
227 AC_CHECK_FUNCS(lstat)
229 dnl Add in portable replacement for mkdtemp() on platforms which lack it.
230 AC_CHECK_FUNCS(mkdtemp)
231 AM_CONDITIONAL(NEED_MKDTEMP, [test yes != "$ac_cv_func_mkdtemp"])
233 dnl Add in portable replacement for strptime() on platforms which lack it.
234 AC_CHECK_FUNCS(strptime)
235 AM_CONDITIONAL(NEED_STRPTIME, [test yes != "$ac_cv_func_strptime"])
237 dnl Need a full link check for posix_fadvise.
242 # define _POSIX_C_SOURCE 200112L /* for posix_fadvise from fcntl.h */
246 posix_fadvise(1, 0, 0, POSIX_FADV_NOREUSE);
247 posix_fadvise(1, 0, 0, POSIX_FADV_SEQUENTIAL);
248 posix_fadvise(1, 0, 0, POSIX_FADV_DONTNEED);
250 [AC_DEFINE(HAVE_POSIX_FADVISE, 1, [Define to 1 if you have the 'posix_fadvise' function])]
253 dnl omindex uses fork(), socketpair(), and setrlimit() to impose resource
254 dnl limits on filter programs.
255 AC_CHECK_FUNCS([mmap fork setrlimit sysmp pstat_getdynamic setpgid sigaction])
257 dnl -lxnet is needed on Solaris and apparently on HP-UX too.
258 AC_SEARCH_LIBS([socketpair], [xnet],
259 [AC_DEFINE(HAVE_SOCKETPAIR, 1,
260 [Define to 1 if you have the 'socketpair' function])])
262 dnl fnmatch() is used to match ignore pattern.
263 AC_CHECK_FUNCS([fnmatch])
265 dnl mingw has _snprintf so check for that too.
266 AC_MSG_CHECKING([for snprintf])
267 AC_CACHE_VAL([xo_cv_func_snprintf],
269 xo_cv_func_snprintf=no
270 for func in snprintf _snprintf ; do
278 char buffer[4] = "abc";
279 int res = $func(buffer, 4, "%s", "XYZ");
283 [xo_cv_func_snprintf=$func;break],
288 AC_MSG_RESULT([$xo_cv_func_snprintf])
289 if test "$xo_cv_func_snprintf" != no ; then
290 AC_DEFINE_UNQUOTED([SNPRINTF], [$xo_cv_func_snprintf],
291 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
294 AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [], [#include <time.h>])
297 [AS_HELP_STRING([--with-iconv], [force use of iconv (error if not found)])
298 AS_HELP_STRING([--without-iconv], [don't use iconv])],
299 [with_iconv=$withval], [with_iconv=auto])
301 if test no != "$with_iconv" ; then
302 dnl AM_ICONV modifies CPPFLAGS if it succeeds which is undesirable (configure
303 dnl shouldn't modify user variables like CPPFLAGS) so save and restore
304 dnl CPPFLAGS around it. We then add INCICONV where needed instead.
305 save_CPPFLAGS=$CPPFLAGS
307 CPPFLAGS=$save_CPPFLAGS
309 if test yes = "$with_iconv" && test yes != "$am_cv_func_iconv" ; then
310 AC_MSG_ERROR([iconv not found, but --with-iconv specified])
314 dnl Check processor endianness.
317 dnl Check for perl. Needed for outlookmsg2html script and omegatest.pl.
318 dnl (And in maintainer-mode, also to make man pages from "--help" output, and
319 dnl to make the omegascript vim syntax mode.)
320 AC_PATH_PROG(PERL, perl, [])
321 AC_ARG_VAR([PERL], [Perl interpreter])
322 test -z "$PERL" && AC_MSG_ERROR([perl is required])
324 if test x"$enable_documentation" = xyes; then
325 dnl Check for help2man. (Needed to make man pages from "--help" output).
326 AC_PATH_PROG(HELP2MAN, help2man, [])
327 AC_ARG_VAR([HELP2MAN], [help2man man page generator])
328 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
330 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
331 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
332 AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
333 AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
334 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation])
337 AC_ARG_VAR(PKG_CONFIG, [Location of pkg-config])
338 AC_PATH_TOOL(PKG_CONFIG, [pkg-config], [])
340 dnl libmagic used to detect MIME types for files we don't detect by extension.
342 if test -n "$PKG_CONFIG" ; then
343 MAGIC_CFLAGS=`$PKG_CONFIG libmagic --cflags 2>/dev/null`
344 MAGIC_LIBS=`$PKG_CONFIG libmagic --libs 2>/dev/null`
346 if test -z "$MAGIC_LIBS" ; then
348 AC_CHECK_HEADERS([magic.h])
349 if test $ac_cv_header_magic_h = yes ; then
350 dnl On mingw there are several dependent libraries, so AC_CHECK_LIB would
351 dnl fail - we'd have to use LT_OUTPUT and then perform the test link with
352 dnl libtool, but we've checked for magic.h, so checking the library would
353 dnl not really gain us much - we know it is -lmagic.
357 if test -z "$MAGIC_LIBS" ; then
358 if test -r /etc/debian_version ; then
361 pkg="file-devel (or maybe libmagic-devel)"
363 AC_MSG_ERROR([libmagic required but development files not found. If you're installing from packages, you probably need to install a package called something like $pkg in order to be able to build $PACKAGE_NAME.])
365 AC_SUBST([MAGIC_CFLAGS])
366 AC_SUBST([MAGIC_LIBS])
368 pcre_runtime_installed() {
369 dnl Simple check to see if the problem is likely to be that we're using a
370 dnl "packaged" pcre but only have the runtime package installed.
371 for sfx in '' 32 64 ; do
372 set /usr/lib$sfx/libpcre2-*.so.*
373 if test "/usr/lib$sfx/libpcre2-*.so.*" != "$1" ; then
374 if test -r /etc/debian_version ; then
385 PCRE2_LIBS_FLAG=--libs8
386 AC_ARG_VAR(PCRE2_CONFIG, [Location of pcre2-config])
387 if test -z "$PCRE2_CONFIG" ; then
388 if test -n "$PKG_CONFIG" ; then
389 pcre_try="$PKG_CONFIG libpcre2-8"
390 if $pcre_try 2>/dev/null ; then
391 PCRE2_CONFIG=$pcre_try
392 PCRE2_LIBS_FLAG=--libs
394 if pcre_runtime_installed ; then
395 AC_MSG_ERROR(['$pcre_try' failed, but the PCRE2 runtime library seems to be installed. If you've installed PCRE2 from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME.])
397 AC_MSG_ERROR(['$pcre_try' failed. If the PCRE2 library is installed, you need to add PCRE2_CONFIG=/path/to/pcre2-config to your configure command.])
401 dnl Fall back to looking for pcre2-config, but that's not installed on PATH
402 dnl with the platform tuple prefixed (at least under MXE), so preferring
403 dnl 'pkg-config libpcre2' works better when cross-compiling.
404 AC_PATH_TOOL(PCRE2_CONFIG, [pcre2-config])
405 if test -z $PCRE2_CONFIG ; then
406 if pcre_runtime_installed ; then
407 AC_MSG_ERROR([Can't find pcre2-config, although the PCRE2 runtime library seems to be installed. If you've installed PCRE2 from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME.])
409 AC_MSG_ERROR([Can't find pcre2-config. If the PCRE2 library is installed, you need to add PCRE2_CONFIG=/path/to/pcre2-config to your configure command.])
414 PCRE2_CFLAGS=`$PCRE2_CONFIG --cflags`
415 PCRE2_LIBS=`$PCRE2_CONFIG $PCRE2_LIBS_FLAG`
416 AC_SUBST(PCRE2_CFLAGS)
419 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
420 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
422 if test -n "${EATMYDATA-unset}" ; then
423 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
424 AC_ARG_VAR([EATMYDATA], [wrapper to disable fsync (optionally used by test harness)])
427 dnl ******************************
428 dnl * Set special compiler flags *
429 dnl ******************************
431 AC_ARG_ENABLE([werror],
432 [AS_HELP_STRING([--enable-werror], [enable treating compiler warnings as errors [default=maintainer-mode]])],
433 [case ${enableval} in
435 *) AC_MSG_ERROR([bad value ${enableval} for --enable-werror]) ;;
437 [enable_werror=$USE_MAINTAINER_MODE])
439 dnl Put -Werror or equivalent in its own make variable so that it can easily
440 dnl be overridden by `make WERROR=` if needed during development (e.g. if
441 dnl you want to get a full list of compile warnings to fix rather than
442 dnl stopping at the first file with warnings).
446 dnl Set flags to control warnings (enable more, or disable annoying ones).
447 if test yes = "$GXX"; then
448 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
449 dnl we actually have, as neither is really 100% compatible.
450 echo __INTEL_COMPILER __clang__ > conftest.cc
451 case `$CXX -E conftest.cc 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
452 *__INTEL_COMPILER*__clang__*)
453 dnl GCC (since neither substituted):
455 dnl The exact format of g++ --version seems to change with almost every
456 dnl minor release so use the preprocessor macros which should be more
457 dnl robust. Pass -xc++ to avoid warnings about any command-line options
458 dnl included in $CXX which aren't valid for C (such as -std=c++17).
459 AC_MSG_CHECKING([for version of $CXX])
460 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -xc++ -E -|sed '/^#/d;s/ //g'`
461 AC_MSG_RESULT([GCC $gxx_version])
463 dnl -Wundef was supported by g++ 3.0.
465 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
468 dnl -Wdouble-promotion was added in GCC 4.6.
470 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
471 dnl warns for this case with -Wuninitialized (implied by -W). We
472 dnl don't intend to use this idiom, so any instances are bugs we'd
473 dnl like to know about.
475 dnl All the other options were supported by g++ 2.95.
476 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"
479 [[0123]].*|4.[[0-6]].*)
480 AC_MSG_ERROR([Xapian requires GCC 4.7 or later])
485 AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond"
488 AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond -Wduplicated-branches"
493 dnl -Wold-style-cast is interesting, but triggers for macros from
494 dnl system headers (e.g. FD_SET). GCC 4.8 improved this by making
495 dnl -ftrack-macro-expansion=2 the default, but we still see such
496 dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
497 dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
498 dnl warnings from zlib.h).
503 dnl Intel's compiler (since __clang__ not substituted):
505 dnl -w1 stops the avalanche of uninteresting "remark" messages.
506 dnl -wd... disables warnings which don't have good code workarounds.
507 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
512 dnl clang (since __INTEL_COMPILER not substituted):
514 dnl These options all work at least as far back as clang++ 3.0:
515 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"
521 elif test yes = "$msvc"; then
522 dnl -W1 is command-line default, -W3 IDE default, -W4 highest numbered level.
523 dnl AM_CXXFLAGS="$AM_CXXFLAGS -W4"
527 dnl Not GCC, nor a compiler masquerading as GCC, nor MSVC.
530 dnl +w turns on more warnings.
531 dnl +wlint turns on "lint-like" warnings.
532 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
533 dnl 2340 (remark) "value copied to temporary, reference to temporary
534 dnl use", in: throw Xapian::UnimplementedError("...");
535 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
536 dnl virtual destructor for intrusive_base, since we never delete
537 dnl its subclasses by a intrusive_base *).
538 dnl 3348 "declaration hides constant ..." which seems to misfire!
539 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
540 dnl alignment boundary".
541 dnl 4273 "floating-point equality and inequality comparisons may be
542 dnl inappropriate due to roundoff common in floating-point computation"
543 dnl No obvious workaround for when you really do want == or !=.
544 dnl 4285 "operator= does not have a check for the source and destination
545 dnl addresses being non-identical" - fires for AutoPtr which
546 dnl includes such a check indirectly (internaltest's autoptr1 check this).
547 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
548 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
550 dnl Sun's C++ compiler.
552 dnl We use -errtags to report the tag for each warning emitted.
554 dnl We use -erroff to suppress some unhelpful warnings:
556 dnl oklambdaretmulti warns about a lambda with more than one return
557 dnl statement even if they all return the same type.
559 dnl voidretw warns about functions failing to return a value even when the
560 dnl function ends with a "throw" statement. That's just unhelpful noise,
561 dnl and adding a dummy "return" after "throw" seems a worse solution than
562 dnl simply disabling this warning - any genuinely missing return statements
563 dnl will get reported by compilers with superior warning machinery.
564 XAPIAN_TEST_CXXFLAGS([-errtags -erroff=oklambdaretmulti,voidretw], [AM_CXXFLAGS])
569 AC_MSG_CHECKING([for option to turn warnings into errors])
570 if test x$enable_werror != xyes; then
572 AC_MSG_RESULT([not requested])
573 elif test -z "$WERROR" ; then
574 AC_MSG_RESULT([unknown for $CXX])
576 AC_MSG_RESULT([$WERROR])
579 if test "$GXX" = yes; then
580 dnl Default to enabling _FORTIFY_SOURCE at level 2. It shouldn't cause a
581 dnl problem to define it where it's not supported, but we need to check for
582 dnl an issue on mingw-w64 where some versions required linking with -lssp
583 dnl (this was fixed in v11.0.0 released 2023-04-28). We detect this with a
584 dnl configure-time link test and don't auto-enable _FORTIFY_SOURCE if using
585 dnl an affected version.
586 AC_MSG_CHECKING([if _D_FORTIFY_SOURCE=2 links without extra libraries])
587 save_CPPFLAGS=$CPPFLAGS
588 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
589 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
591 static char a[20], b[10];]], [[
594 [AC_MSG_RESULT([yes])
595 AC_DEFINE([FORTIFY_SOURCE_OK], [1], [Define to 1 if '-D_FORTIFY_SOURCE=2' link test passes])],
596 [AC_MSG_RESULT([no])])
597 CPPFLAGS=$save_CPPFLAGS
601 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
603 # pragma warning(disable:4800)
606 /* MSVC defines _WIN32 but not __WIN32__. */
607 #if !defined __WIN32__ && defined _WIN32
611 /* MSVC defines _WIN64 but not __WIN64__. */
612 #if !defined __WIN64__ && defined _WIN64
616 /* Default to enabling _FORTIFY_SOURCE at level 2 for GCC-like compilers. It
617 * shouldn't cause a problem to define it where it's not supported.
619 * The FORTIFY_SOURCE_OK check avoids auto-enabling on some mingw-w64 versions
620 * which required linking with -lssp too. This was addressed in v11.0.0
621 * (released 2023-04-28).
623 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
624 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1" or
627 #if defined FORTIFY_SOURCE_OK && !defined _FORTIFY_SOURCE
628 # define _FORTIFY_SOURCE 2
631 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
632 * we can use __builtin_expect to give the compiler hints about branch
633 * prediction. See HACKING for how to use these.
635 #if HAVE_DECL___BUILTIN_EXPECT
636 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
637 * the first argument is always an integer expression, and always 0 or 1, but
638 * still has the same truth value for the if or while it is used in.
640 # define rare(COND) __builtin_expect(!!(COND), 0)
641 # define usual(COND) __builtin_expect(!!(COND), 1)
643 # define rare(COND) (COND)
644 # define usual(COND) (COND)
648 AC_SUBST([AM_CXXFLAGS])
650 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
651 CXXFLAGS=$save_CXXFLAGS
653 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
654 : ${AUTOM4TE=autom4te}
657 dnl **************************
658 dnl * Build the output files *
659 dnl **************************
666 dnl Allow AC_CONFIG_FILES with chmod +x without having to repeat the filename.
667 AC_DEFUN([SCRIPT_TEMPLATE], [AC_CONFIG_FILES([$1], [chmod +x "$1"])])
668 SCRIPT_TEMPLATE([makemanpage])
669 SCRIPT_TEMPLATE([mhtml2html])
670 SCRIPT_TEMPLATE([outlookmsg2html])
671 SCRIPT_TEMPLATE([rfc822tohtml])
672 SCRIPT_TEMPLATE([vcard2text])