1 dnl Process this file with autoconf to produce a configure script.
3 m4_define([project_version], [1.5.0])
4 AC_INIT([xapian-omega], project_version, [https://xapian.org/bugs])
6 AM_INIT_AUTOMAKE([1.13 -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_DIRS([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 Only pass -no-undefined on platforms where it is required in order to link
26 dnl a shared library at all (Microsoft Windows is the main one) as it can cause
27 dnl problems on other platforms (e.g. Solaris with Sun CC in C++11 mode, though
28 dnl we don't support that compiler now as it lacks C++17 support).
30 if test unsupported = "$allow_undefined_flag" ; then
31 NO_UNDEFINED=-no-undefined
33 AC_SUBST(NO_UNDEFINED)
35 dnl disable "maintainer only" rules by default
38 dnl Checks for programs.
43 # Checked: dragonfly6.4 freebsd8.0 netbsd9.3 openbsd4.6 solaris2.9 solaris2.10
45 linux* | k*bsd*-gnu | dragonfly* | freebsd* | netbsd* | openbsd* | solaris*)
46 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
47 link_all_deplibs_CXX=no
53 dnl Extract search path from ldconfig which is more reliable than the way
54 dnl vanilla libtool extracts them from ld.so.conf.
55 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
56 test -z "$d" || sys_lib_dlsearch_path_spec=$d
61 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
62 dnl On these platforms, libtool emits a warning if -no-install is passed,
63 dnl and uses -no-fast-install instead - the least ugly way to avoid that
64 dnl warnings seems to be to duplicate the above list of platforms from
65 dnl libtool and use -no-fast-install on them directly.
66 NO_INSTALL=-no-fast-install ;;
68 NO_INSTALL=-no-install ;;
70 AC_SUBST([NO_INSTALL])
72 dnl Probe for any options needed to enable C++17 support.
73 AX_CXX_COMPILE_STDCXX([17])
75 dnl Run tests using the C++ compiler.
78 dnl Enable large file support if possible.
81 dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
82 dnl variable $2. If the test passes, also do $3; if it fails, also do $4.
83 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
85 XTC_save_CXXFLAGS=$CXXFLAGS
86 CXXFLAGS="$CXXFLAGS $1"
87 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
88 [CXXFLAGS=$XTC_save_CXXFLAGS
91 [CXXFLAGS=$XTC_save_CXXFLAGS
95 dnl Check for xapian-core.
97 [xapian-config]regexp(project_version,
98 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
101 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
102 save_CXXFLAGS=$CXXFLAGS
103 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
105 dnl We need to specify the argument types for builtin functions, or else
106 dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
107 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
108 __builtin_sub_overflow(int, int, int*),
109 __builtin_mul_overflow(int, int, int*)], [], [], [ ])
110 AC_CHECK_DECLS([__builtin_bswap32(uint32_t)], [], [],
111 [#include <stdint.h>])
112 AC_CHECK_DECLS([_byteswap_ulong], [], [],
113 [#include <stdlib.h>])
114 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
115 AC_CHECK_DECLS([_addcarry_u32(unsigned char, unsigned, unsigned, unsigned*),
116 _addcarry_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*),
117 _subborrow_u32(unsigned char, unsigned, unsigned, unsigned*),
118 _subborrow_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*)],
119 [], [], [#include <intrin.h>])
121 dnl Check for time functions.
123 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
124 AC_CHECK_FUNCS([gmtime_r timegm])
128 dnl For _ftime64() on mingw we need to tell it we're happy to require
129 dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
130 AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
131 AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
135 AC_ARG_ENABLE(documentation,
136 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
137 [case ${enableval} in
139 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
141 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
142 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
143 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
146 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
149 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
151 dnl Check for headers.
152 AC_CHECK_HEADERS([strings.h sys/select.h], [], [], [ ])
153 AC_CHECK_HEADERS([sysexits.h sys/time.h]dnl
154 [sys/resource.h sys/socket.h sys/sysctl.h vm/vm_param.h]dnl
155 [sys/vmmeter.h sys/sysmp.h sys/sysinfo.h sys/pstat.h],
156 [], [], [#include <sys/types.h>])
158 dnl Check for zlib.h.
159 AC_CHECK_HEADERS([zlib.h], [], [
160 AC_MSG_ERROR([zlib.h not found])
163 dnl Check for zlibVersion in -lz.
166 dnl mingw build needs -lzlib or -lzdll.
167 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
168 AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll (you may need to install the zlib1g-dev or zlib-devel package)])
171 AC_SUBST([ZLIB_LIBS])
174 dnl POSIX requires setenv(). The final Unix-like platform without it seems
175 dnl to have been Solaris 9, which is now out of support.
177 dnl Microsoft don't provide setenv() and have marked putenv() as deprecated, so
178 dnl we use _putenv_s() to avoid deprecation warnings with MSVC. It's also a
179 dnl more similar interface to setenv() so easier to implement a setenv() wrapper
180 dnl around. We probe for both the function and a declaration since mingw
181 dnl doesn't currently (v3.20) declare it but it is present in the C runtime DLL
182 dnl so we can provide our own declaration to access it.
183 AC_CHECK_FUNCS([setenv _putenv_s])
184 AC_CHECK_DECLS([_putenv_s(const char*, const char*)], [], [],
185 [#include <stdlib.h>])
187 dnl See if we have closefrom(), or some functions that are useful to implement
188 dnl closefrom() on platforms which don't provide it.
189 AC_CHECK_FUNCS([closefrom getdirentries getrlimit])
191 if test $ac_cv_func_ftime = yes ; then
192 dnl See if ftime returns void (as it does on mingw)
193 AC_MSG_CHECKING([return type of ftime])
195 [AC_LANG_PROGRAM([[#include <sys/timeb.h>]],
196 [[struct timeb tp; int i = ftime(&tp);]])],
197 [AC_MSG_RESULT([int])],
198 [AC_MSG_RESULT([void])
199 AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void])])
202 dnl mingw (for instance) lacks ssize_t
209 XAPIAN_TYPE_SOCKLEN_T
211 dnl Used by omegatest to skip some testcases with 32-bit time_t.
212 AC_CHECK_SIZEOF([time_t], [#include <time.h>])
214 dnl Use for Unix permission checks.
215 AC_CHECK_FUNCS([getgrouplist])
217 dnl See if getgrouplist() takes gid_t * (e.g. Linux) or int * (e.g. macOS).
218 if test $ac_cv_func_getgrouplist = yes ; then
220 [AC_LANG_PROGRAM([[#include <grp.h>
221 #include <unistd.h>]],
222 [[int g[10]; int n = 10; return getgrouplist("root", 1, g, &n) == -1;]])],
223 [AC_DEFINE([GETGROUPLIST_TAKES_INT_P], 1, [Define if getgrouplist takes int *])],
227 dnl Check for lstat() (not available under mingw for example).
228 AC_CHECK_FUNCS(lstat)
230 dnl Add in portable replacement for mkdtemp() on platforms which lack it.
231 AC_CHECK_FUNCS(mkdtemp)
232 AM_CONDITIONAL(NEED_MKDTEMP, [test yes != "$ac_cv_func_mkdtemp"])
234 dnl Add in portable replacement for strptime() on platforms which lack it.
235 AC_CHECK_FUNCS(strptime)
236 AM_CONDITIONAL(NEED_STRPTIME, [test yes != "$ac_cv_func_strptime"])
238 AC_CHECK_FUNCS([posix_fadvise])
240 dnl omindex uses fork(), socketpair(), setrlimit() and alarm() to impose resource
241 dnl limits on filter programs and workers.
242 AC_CHECK_FUNCS([mmap fork setrlimit sysmp pstat_getdynamic setpgid sigaction alarm])
243 AC_CHECK_FUNCS([waitpid])
245 dnl -lxnet is needed on Solaris and apparently on HP-UX too.
246 AC_SEARCH_LIBS([socketpair], [xnet],
247 [AC_DEFINE(HAVE_SOCKETPAIR, 1,
248 [Define to 1 if you have the 'socketpair' function])])
250 dnl fnmatch() is used to match ignore pattern.
251 AC_CHECK_FUNCS([fnmatch])
255 dnl check if poppler is available.
256 PKG_CHECK_MODULES([POPPLER], [poppler-glib >= 0.16], [
257 AC_DEFINE(HAVE_POPPLER, 1, [Define HAVE_POPPLER if the library is available])
258 OMINDEX_MODULES="$OMINDEX_MODULES omindex_poppler"],[ ])
260 dnl check if libe-book is available.
261 PKG_CHECK_MODULES([LIBEBOOK], [libe-book-0.1,librevenge-0.0,librevenge-generators-0.0,librevenge-stream-0.0], [
262 AC_DEFINE(HAVE_LIBEBOOK, 1, [Define HAVE_LIBEBOOK if the library is available])
263 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libebook"],[ ])
265 dnl check if libetonyek is available.
266 PKG_CHECK_MODULES([LIBETONYEK], [libetonyek-0.1,librevenge-0.0,librevenge-generators-0.0,librevenge-stream-0.0], [
267 AC_DEFINE(HAVE_LIBETONYEK, 1, [Define HAVE_LIBETONYEK if the library is available])
268 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libetonyek"],[ ])
270 dnl check if libgepub is available.
271 PKG_CHECK_MODULES([LIBGEPUB], [libgepub-0.7], [
272 AC_DEFINE(HAVE_LIBGEPUB, 1, [Define HAVE_LIBGEPUB if the library is available])
273 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libgepub"],
274 [PKG_CHECK_MODULES([LIBGEPUB], [libgepub-0.6], [
275 AC_DEFINE(HAVE_LIBGEPUB, 1, [Define HAVE_LIBGEPUB if the library is available])
276 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libgepub"],[ ])])
278 dnl check if libtesseract is available.
279 PKG_CHECK_MODULES([TESSERACT], [tesseract, lept], [
280 AC_DEFINE(HAVE_TESSERACT, 1, [Define HAVE_TESSERACT if the library is available])
281 OMINDEX_MODULES="$OMINDEX_MODULES omindex_tesseract"],[ ])
283 dnl Check if gmime is available, using gmime-3.0 in preference.
284 PKG_CHECK_MODULES([GMIME], [gmime-3.0, glib-2.0], [
285 AC_DEFINE(HAVE_GMIME, 1, [Define HAVE_GMIME if the library is available])
286 OMINDEX_MODULES="$OMINDEX_MODULES omindex_gmime"],
287 [PKG_CHECK_MODULES([GMIME], [gmime-2.6, glib-2.0], [
288 AC_DEFINE(HAVE_GMIME, 1, [Define HAVE_GMIME if the library is available])
289 OMINDEX_MODULES="$OMINDEX_MODULES omindex_gmime"],[ ])])
291 dnl check if libarchive is available.
292 PKG_CHECK_MODULES([LIBARCHIVE], [libarchive], [
293 AC_DEFINE(HAVE_LIBARCHIVE, 1, [Define HAVE_LIBARCHIVE if the library is available])
294 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libarchive"],[ ])
296 dnl check if libabw is available.
297 PKG_CHECK_MODULES([LIBABW], [libabw-0.1,librevenge-0.0,librevenge-generators-0.0,librevenge-stream-0.0], [
298 AC_DEFINE(HAVE_LIBABW, 1, [Define HAVE_LIBABW if the library is available])
299 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libabw"],[ ])
301 dnl check if libcdr is available.
302 PKG_CHECK_MODULES([LIBCDR], [libcdr-0.1,librevenge-0.0,librevenge-generators-0.0,librevenge-stream-0.0], [
303 AC_DEFINE(HAVE_LIBCDR, 1, [Define HAVE_LIBCDR if the library is available])
304 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libcdr"],[ ])
306 dnl check if libextractor is available.
307 PKG_CHECK_MODULES([LIBEXTRACTOR], [libextractor], [
308 AC_DEFINE(HAVE_LIBEXTRACTOR, 1, [Define HAVE_LIBEXTRACTOR if the library is available])
309 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libextractor"],[ ])
311 dnl check if libmwaw is available.
312 PKG_CHECK_MODULES([LIBMWAW], [libmwaw-0.3,librevenge-0.0,librevenge-generators-0.0,librevenge-stream-0.0], [
313 AC_DEFINE(HAVE_LIBMWAW, 1, [Define HAVE_LIBMWAW if the library is available])
314 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libmwaw"],[ ])
316 dnl Check if libreofficekit is available. It's know to be broken on macOS
317 dnl so avoid trying to use it there as it only fails at runtime:
318 dnl https://bugs.documentfoundation.org/show_bug.cgi?id=145127
320 case $host_vendir-$host_os in
323 AC_CHECK_HEADERS([LibreOfficeKit/LibreOfficeKit.hxx], [
324 if test x"$LO_INCLUDE_PATH" != x ; then
325 LIBREOFFICEKIT_CPPFLAGS="-I'$LO_INCLUDE_PATH'"
326 AC_SUBST([LIBREOFFICEKIT_CPPFLAGS])
329 dnl LibreOfficeKit/LibreOfficeKitInit.h has inline code which calls dlopen()
330 dnl (unless _WIN32 or IOS is defined).
331 AC_SEARCH_LIBS([dlopen], [dl], [LIBREOFFICEKIT_LIBS=-ldl])
333 OMINDEX_MODULES="$OMINDEX_MODULES omindex_libreofficekit"
337 AC_SUBST([LIBREOFFICEKIT_LIBS])
338 dnl Allow easy building against uninstalled LibreOffice.
339 AC_ARG_VAR([LO_INCLUDE_PATH], [Path to directory containing LibreOffice headers])
341 AC_SUBST([OMINDEX_MODULES])
343 AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [], [#include <time.h>])
346 [AS_HELP_STRING([--with-iconv], [force use of iconv (error if not found)])
347 AS_HELP_STRING([--without-iconv], [don't use iconv])],
348 [with_iconv=$withval], [with_iconv=auto])
350 if test no != "$with_iconv" ; then
351 dnl AM_ICONV modifies CPPFLAGS if it succeeds which is undesirable (configure
352 dnl shouldn't modify user variables like CPPFLAGS) so save and restore
353 dnl CPPFLAGS around it. We then add INCICONV where needed instead.
354 save_CPPFLAGS=$CPPFLAGS
356 CPPFLAGS=$save_CPPFLAGS
358 if test yes = "$with_iconv" && test yes != "$am_cv_func_iconv" ; then
359 AC_MSG_ERROR([iconv not found, but --with-iconv specified])
363 dnl Check processor endianness.
366 dnl Check for perl. Needed for outlookmsg2html script and omegatest.pl.
367 dnl (And in maintainer-mode, also to make man pages from "--help" output, and
368 dnl to make the omegascript vim syntax mode.)
369 AC_PATH_PROG(PERL, perl, [])
370 AC_ARG_VAR([PERL], [Perl interpreter])
371 test -z "$PERL" && AC_MSG_ERROR([perl is required])
373 if test x"$enable_documentation" = xyes; then
374 dnl Check for help2man. (Needed to make man pages from "--help" output).
375 AC_PATH_PROG(HELP2MAN, help2man, [])
376 AC_ARG_VAR([HELP2MAN], [help2man man page generator])
377 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
379 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
380 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
381 AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
382 AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
383 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation])
386 AC_ARG_VAR(PKG_CONFIG, [Location of pkg-config])
387 AC_PATH_TOOL(PKG_CONFIG, [pkg-config], [])
389 dnl libmagic used to detect MIME types for files we don't detect by extension.
391 if test -n "$PKG_CONFIG" ; then
392 MAGIC_CFLAGS=`$PKG_CONFIG libmagic --cflags 2>/dev/null`
393 MAGIC_LIBS=`$PKG_CONFIG libmagic --libs 2>/dev/null`
395 if test -z "$MAGIC_LIBS" ; then
397 AC_CHECK_HEADERS([magic.h])
398 if test $ac_cv_header_magic_h = yes ; then
399 dnl On mingw there are several dependent libraries, so AC_CHECK_LIB would
400 dnl fail - we'd have to use LT_OUTPUT and then perform the test link with
401 dnl libtool, but we've checked for magic.h, so checking the library would
402 dnl not really gain us much - we know it is -lmagic.
406 if test -z "$MAGIC_LIBS" ; then
407 if test -r /etc/debian_version ; then
410 pkg="file-devel (or maybe libmagic-devel)"
412 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.])
414 AC_SUBST([MAGIC_CFLAGS])
415 AC_SUBST([MAGIC_LIBS])
417 pcre_runtime_installed() {
418 dnl Simple check to see if the problem is likely to be that we're using a
419 dnl "packaged" pcre but only have the runtime package installed.
420 for sfx in '' 32 64 ; do
421 set /usr/lib$sfx/libpcre2-*.so.*
422 if test "/usr/lib$sfx/libpcre2-*.so.*" != "$1" ; then
423 if test -r /etc/debian_version ; then
434 PCRE2_LIBS_FLAG=--libs8
435 AC_ARG_VAR(PCRE2_CONFIG, [Location of pcre2-config])
436 if test -z "$PCRE2_CONFIG" ; then
437 if test -n "$PKG_CONFIG" ; then
438 pcre_try="$PKG_CONFIG libpcre2-8"
439 if $pcre_try 2>/dev/null ; then
440 PCRE2_CONFIG=$pcre_try
441 PCRE2_LIBS_FLAG=--libs
443 if pcre_runtime_installed ; then
444 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.])
446 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.])
450 dnl Fall back to looking for pcre2-config, but that's not installed on PATH
451 dnl with the platform tuple prefixed (at least under MXE), so preferring
452 dnl 'pkg-config libpcre2' works better when cross-compiling.
453 AC_PATH_TOOL(PCRE2_CONFIG, [pcre2-config])
454 if test -z $PCRE2_CONFIG ; then
455 if pcre_runtime_installed ; then
456 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.])
458 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.])
463 PCRE2_CFLAGS=`$PCRE2_CONFIG --cflags`
464 PCRE2_LIBS=`$PCRE2_CONFIG $PCRE2_LIBS_FLAG`
465 AC_SUBST(PCRE2_CFLAGS)
468 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
469 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
471 if test -n "${EATMYDATA-unset}" ; then
472 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
473 AC_ARG_VAR([EATMYDATA], [wrapper to disable fsync (optionally used by test harness)])
476 AC_MSG_CHECKING([for /dev/stdin])
477 if test -c /dev/stdin && (echo hello|$GREP hello /dev/stdin >&AS_MESSAGE_LOG_FD 2>&1); then
479 AC_DEFINE([HAVE_DEV_STDIN], [1], [Define to 1 if you have the '/dev/stdin' special file])
484 dnl ******************************
485 dnl * Set special compiler flags *
486 dnl ******************************
488 AC_ARG_ENABLE([werror],
489 [AS_HELP_STRING([--enable-werror], [enable treating compiler warnings as errors [default=maintainer-mode]])],
490 [case ${enableval} in
492 *) AC_MSG_ERROR([bad value ${enableval} for --enable-werror]) ;;
494 [enable_werror=$USE_MAINTAINER_MODE])
496 dnl Put -Werror or equivalent in its own make variable so that it can easily
497 dnl be overridden by `make WERROR=` if needed during development (e.g. if
498 dnl you want to get a full list of compile warnings to fix rather than
499 dnl stopping at the first file with warnings).
503 dnl Set flags to control warnings (enable more, or disable annoying ones).
504 if test yes = "$GXX"; then
505 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
506 dnl we actually have, as neither is really 100% compatible.
507 echo __INTEL_COMPILER __clang__ > conftest.cc
508 case `$CXX -E conftest.cc 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
509 *__INTEL_COMPILER*__clang__*)
510 dnl GCC (since neither substituted):
512 dnl The exact format of g++ --version seems to change with almost every
513 dnl minor release so use the preprocessor macros which should be more
514 dnl robust. Pass -xc++ to avoid warnings about any command-line options
515 dnl included in $CXX which aren't valid for C (such as -std=c++17).
516 AC_MSG_CHECKING([for version of $CXX])
517 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -xc++ -E -|sed '/^#/d;s/ //g'`
518 AC_MSG_RESULT([GCC $gxx_version])
520 dnl -Wundef was supported by g++ 3.0.
522 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
525 dnl -Wdouble-promotion was added in GCC 4.6.
527 dnl -Wduplicated-cond was added in GCC 6.
529 dnl -Wduplicated-branches was added in GCC 7.
531 dnl All the other options were supported by g++ 2.95.
532 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"
536 AC_MSG_ERROR([Xapian requires GCC 7.0 or later])
541 dnl -Wold-style-cast is interesting, but triggers for macros from
542 dnl system headers (e.g. FD_SET). GCC 4.8 improved this by making
543 dnl -ftrack-macro-expansion=2 the default, but we still see such
544 dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
545 dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
546 dnl warnings from zlib.h).
551 dnl Intel's compiler (since __clang__ not substituted):
553 dnl -w1 stops the avalanche of uninteresting "remark" messages.
554 dnl -wd... disables warnings which don't have good code workarounds.
555 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
560 dnl clang (since __INTEL_COMPILER not substituted):
562 dnl These options all work at least as far back as clang++ 3.0:
563 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"
569 elif test yes = "$msvc"; then
570 dnl -W1 is command-line default, -W3 IDE default, -W4 highest numbered level.
571 dnl AM_CXXFLAGS="$AM_CXXFLAGS -W4"
576 AC_MSG_CHECKING([for option to turn warnings into errors])
577 if test x$enable_werror != xyes; then
579 AC_MSG_RESULT([not requested])
580 elif test -z "$WERROR" ; then
581 AC_MSG_RESULT([unknown for $CXX])
583 AC_MSG_RESULT([$WERROR])
586 if test "$GXX" = yes; then
587 dnl Default to enabling _FORTIFY_SOURCE at level 2. It shouldn't cause a
588 dnl problem to define it where it's not supported, but we need to check for
589 dnl an issue on mingw-w64 where some versions required linking with -lssp
590 dnl (this was fixed in v11.0.0 released 2023-04-28). We detect this with a
591 dnl configure-time link test and don't auto-enable _FORTIFY_SOURCE if using
592 dnl an affected version.
593 AC_MSG_CHECKING([if _D_FORTIFY_SOURCE=2 links without extra libraries])
594 save_CPPFLAGS=$CPPFLAGS
595 CPPFLAGS="$CPPFLAGS -D_FORTIFY_SOURCE=2"
596 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
598 static char a[20], b[10];]], [[
601 [AC_MSG_RESULT([yes])
602 AC_DEFINE([FORTIFY_SOURCE_OK], [1], [Define to 1 if '-D_FORTIFY_SOURCE=2' link test passes])],
603 [AC_MSG_RESULT([no])])
604 CPPFLAGS=$save_CPPFLAGS
608 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
610 # pragma warning(disable:4800)
613 /* MSVC defines _WIN32 but not __WIN32__. */
614 #if !defined __WIN32__ && defined _WIN32
618 /* MSVC defines _WIN64 but not __WIN64__. */
619 #if !defined __WIN64__ && defined _WIN64
623 /* Default to enabling _FORTIFY_SOURCE at level 2 for GCC-like compilers. It
624 * shouldn't cause a problem to define it where it's not supported.
626 * The FORTIFY_SOURCE_OK check avoids auto-enabling on some mingw-w64 versions
627 * which required linking with -lssp too. This was addressed in v11.0.0
628 * (released 2023-04-28).
630 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
631 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1" or
634 #if defined FORTIFY_SOURCE_OK && !defined _FORTIFY_SOURCE
635 # define _FORTIFY_SOURCE 2
638 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
639 * we can use __builtin_expect to give the compiler hints about branch
640 * prediction. See HACKING for how to use these.
642 #if HAVE_DECL___BUILTIN_EXPECT
643 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
644 * the first argument is always an integer expression, and always 0 or 1, but
645 * still has the same truth value for the if or while it is used in.
647 # define rare(COND) __builtin_expect(!!(COND), 0)
648 # define usual(COND) __builtin_expect(!!(COND), 1)
650 # define rare(COND) (COND)
651 # define usual(COND) (COND)
654 /* This macro can be used around expressions which intentionally make use of
655 * unsigned integer overflow (which is defined behaviour, unlike signed integer
656 * overflow) so that we can use UBSan's optional unsigned-integer-overflow
657 * check to find potential bugs where we unintentionally overflow an unsigned
661 #define UNSIGNED_OVERFLOW_OK(X) \
662 ([&]() __attribute__((no_sanitize("unsigned-integer-overflow"))) {\
666 # define UNSIGNED_OVERFLOW_OK(X) (X)
670 AC_SUBST([AM_CXXFLAGS])
672 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
673 CXXFLAGS=$save_CXXFLAGS
675 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
676 : ${AUTOM4TE=autom4te}
679 dnl **************************
680 dnl * Build the output files *
681 dnl **************************
687 dnl Allow AC_CONFIG_FILES with chmod +x without having to repeat the filename.
688 AC_DEFUN([SCRIPT_TEMPLATE], [AC_CONFIG_FILES([$1], [chmod +x "$1"])])
689 SCRIPT_TEMPLATE([makemanpage])
690 SCRIPT_TEMPLATE([mhtml2html])
691 SCRIPT_TEMPLATE([outlookmsg2html])
692 SCRIPT_TEMPLATE([rfc822tohtml])
693 SCRIPT_TEMPLATE([vcard2text])