Add function to subtract with overflow check
[xapian.git] / xapian-applications / omega / configure.ac
blob8d7a5bc5affc68fffa2f372970d8f6bb3459bfb1
1 dnl Process this file with autoconf to produce a configure script.
3 m4_define([project_version], [1.4.19])
4 AC_INIT([xapian-omega], project_version, [https://xapian.org/bugs])
5 AC_PREREQ([2.63])
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])
14 dnl The AM_ICONV macro requires a stack of macros including AC_LIB_PROG_LD,
15 dnl which is just a copy of libtool's LT_PATH_LD with the name changed.
16 dnl We will already have run LT_PATH_LD, so make AC_LIB_PROG_LD a no-op
17 dnl as LT_PATH_LD will already have set the with_gnu_ld variable.
18 AC_DEFUN([AC_LIB_PROG_LD], [])
20 LT_PREREQ([2.2.6])
21 LT_INIT
23 dnl -no-undefined causes problems on Solaris with Sun CC in C++11 mode, so only
24 dnl pass -no-undefined on platforms where it is required in order to link a
25 dnl shared library at all (Windows is the main one).
26 NO_UNDEFINED=
27 if test unsupported = "$allow_undefined_flag" ; then
28   NO_UNDEFINED=-no-undefined
30 AC_SUBST(NO_UNDEFINED)
32 dnl disable "maintainer only" rules by default
33 AM_MAINTAINER_MODE
35 dnl Checks for programs.
36 AC_PROG_CXX
38 AC_CANONICAL_HOST
40 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
41 case $host_os in
42   linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
43     dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
44     link_all_deplibs_CXX=no
45     ;;
46 esac
48 case $host_os in
49   linux*)
50     dnl Extract search path from ldconfig which is more reliable than the way
51     dnl vanilla libtool extracts them from ld.so.conf.
52     d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
53     test -z "$d" || sys_lib_dlsearch_path_spec=$d
54     ;;
55 esac
57 case $host in
58   *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
59     dnl On these platforms, libtool emits a warning if -no-install is passed,
60     dnl and uses -no-fast-install instead - the least ugly way to avoid that
61     dnl warnings seems to be to duplicate the above list of platforms from
62     dnl libtool and use -no-fast-install on them directly.
63     NO_INSTALL=-no-fast-install ;;
64   *)
65     NO_INSTALL=-no-install ;;
66 esac
67 AC_SUBST([NO_INSTALL])
69 dnl Probe for any options needed to enable C++11 support.
70 AX_CXX_COMPILE_STDCXX_11
72 dnl Run tests using the C++ compiler.
73 AC_LANG([C++])
75 dnl Enable large file support if possible.
76 AC_SYS_LARGEFILE
78 dnl Test if the compiler works with $1 added to CXXFLAGS; if it does, add $1 to
79 dnl variable $2.  If the test passes, also do $3; if it fails, also do $4.
80 AC_DEFUN([XAPIAN_TEST_CXXFLAGS],
81   [
82   XTC_save_CXXFLAGS=$CXXFLAGS
83   CXXFLAGS="$CXXFLAGS $1"
84   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
85                     [CXXFLAGS=$XTC_save_CXXFLAGS
86                      $2="${$2} $1"
87                      $3],
88                     [CXXFLAGS=$XTC_save_CXXFLAGS
89                      $4])
90   ])
92 dnl Check for xapian-core.
93 XO_LIB_XAPIAN([], [],
94     [xapian-config]regexp(project_version,
95                           [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
96 XO_REQUIRE([1.4.0])
98 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
99 save_CXXFLAGS=$CXXFLAGS
100 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
102 dnl We need to specify the argument types for builtin functions, or else
103 dnl AC_CHECK_DECLS fails to detect them when the compiler is clang.
104 AC_CHECK_DECLS([__builtin_add_overflow(int, int, int*),
105                 __builtin_sub_overflow(int, int, int*),
106                 __builtin_mul_overflow(int, int, int*)], [], [], [ ])
107 AC_CHECK_DECLS([__builtin_bswap32(uint32_t)], [], [],
108                [#include <stdint.h>])
109 AC_CHECK_DECLS([_byteswap_ulong], [], [],
110                [#include <stdlib.h>])
111 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
112 AC_CHECK_DECLS([_addcarry_u32(unsigned char, unsigned, unsigned, unsigned*),
113                 _addcarry_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*),
114                 _subborrow_u32(unsigned char, unsigned, unsigned, unsigned*),
115                 _subborrow_u64(unsigned char, unsigned __int64, unsigned __int64, unsigned __int64*)],
116                [], [], [#include <intrin.h>])
118 dnl Check for time functions.
119 AC_FUNC_STRFTIME
120 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
121 AC_CHECK_FUNCS([gmtime_r timegm])
123 case $host_os in
124   *mingw*)
125     dnl For _ftime64() on mingw we need to tell it we're happy to require
126     dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
127     AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
128     AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
129     ;;
130 esac
132 AC_ARG_ENABLE(documentation,
133   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
134   [case ${enableval} in
135     yes|no) ;;
136     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
137   esac])
138 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
139 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
140 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
142 vpath_build=no
143 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
144   vpath_build=yes
146 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
148 dnl Check for headers.
149 AC_CHECK_HEADERS([strings.h sys/select.h], [], [], [ ])
150 AC_CHECK_HEADERS([sys/time.h]dnl
151                  [sys/resource.h sys/socket.h sys/sysctl.h vm/vm_param.h]dnl
152                  [sys/vmmeter.h sys/sysmp.h sys/sysinfo.h sys/pstat.h],
153                  [], [], [#include <sys/types.h>])
155 dnl Check for zlib.h.
156 AC_CHECK_HEADERS([zlib.h], [], [
157   AC_MSG_ERROR([zlib.h not found])
158   ], [ ])
160 dnl Check for zlibVersion in -lz.
161 SAVE_LIBS=$LIBS
162 LIBS=
163 dnl mingw build needs -lzlib or -lzdll.
164 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
165   AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll (you  may need to install the zlib1g-dev or zlib-devel package)])
166   ])
167 ZLIB_LIBS=$LIBS
168 AC_SUBST([ZLIB_LIBS])
169 LIBS=$SAVE_LIBS
171 dnl POSIX requires setenv().  The final Unix-like platform without it seems
172 dnl to have been Solaris 9, which is now out of support.
174 dnl Microsoft don't provide setenv() and have marked putenv() as deprecated, so
175 dnl we use _putenv_s() to avoid deprecation warnings with MSVC.  It's also a
176 dnl more similar interface to setenv() so easier to implement a setenv() wrapper
177 dnl around.  We probe for both the function and a declaration since mingw
178 dnl doesn't currently (v3.20) declare it but it is present in the C runtime DLL
179 dnl so we can provide our own declaration to access it.
180 AC_CHECK_FUNCS([setenv _putenv_s])
181 AC_CHECK_DECLS([_putenv_s(const char*, const char*)], [], [],
182 [#include <stdlib.h>])
184 dnl libmagic used to detect MIME types for files we don't detect by extension.
185 AC_CHECK_HEADERS([magic.h])
186 if test $ac_cv_header_magic_h != yes ; then
187   if test -r /etc/debian_version ; then
188     pkg="libmagic-dev"
189   else
190     pkg="file-devel (or maybe libmagic-devel)"
191   fi
192   AC_MSG_ERROR([libmagic required but magic.h 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.])
195 dnl On mingw there are several dependent libraries, so AC_CHECK_LIB would
196 dnl fail - we'd have to use LT_OUTPUT and then perform the test link with
197 dnl libtool, but we've checked for magic.h, so checking the library would
198 dnl not really gain us much - we know it is -lmagic.
199 MAGIC_LIBS=-lmagic
200 AC_SUBST([MAGIC_LIBS])
202 if test $ac_cv_func_ftime = yes ; then
203   dnl See if ftime returns void (as it does on mingw)
204   AC_MSG_CHECKING([return type of ftime])
205   AC_COMPILE_IFELSE(
206     [AC_LANG_PROGRAM([[#include <sys/timeb.h>]],
207                      [[struct timeb tp; int i = ftime(&tp);]])],
208     [AC_MSG_RESULT([int])],
209     [AC_MSG_RESULT([void])
210     AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void])])
213 dnl mingw (for instance) lacks ssize_t
214 AC_TYPE_SSIZE_T
216 AC_TYPE_PID_T
218 AC_TYPE_MODE_T
220 dnl Use for Unix permission checks.
221 AC_CHECK_FUNCS([getgrouplist])
223 dnl See if getgrouplist() takes gid_t * (e.g. Linux) or int * (e.g. OS X).
224 if test $ac_cv_func_getgrouplist = yes ; then
225   AC_COMPILE_IFELSE(
226     [AC_LANG_PROGRAM([[#include <grp.h>
227 #include <unistd.h>]],
228                      [[int g[10]; int n = 10; return getgrouplist("root", 1, g, &n) == -1;]])],
229     [AC_DEFINE([GETGROUPLIST_TAKES_INT_P], 1, [Define if getgrouplist takes int *])],
230     [])
233 dnl Check for lstat() (not available under mingw for example).
234 AC_CHECK_FUNCS(lstat)
236 dnl Add in portable replacement for mkdtemp() on platforms which lack it.
237 AC_CHECK_FUNCS(mkdtemp)
238 AM_CONDITIONAL(NEED_MKDTEMP, [test yes != "$ac_cv_func_mkdtemp"])
240 dnl Add in portable replacement for strptime() on platforms which lack it.
241 AC_CHECK_FUNCS(strptime)
242 AM_CONDITIONAL(NEED_STRPTIME, [test yes != "$ac_cv_func_strptime"])
244 dnl Need a full link check for posix_fadvise.
245 AC_LINK_IFELSE([
246   AC_LANG_PROGRAM(
247     [[
248 #ifdef __linux__
249 # define _POSIX_C_SOURCE 200112L /* for posix_fadvise from fcntl.h */
250 #endif
251 #include <fcntl.h>
252     ]], [[
253       posix_fadvise(1, 0, 0, POSIX_FADV_NOREUSE);
254       posix_fadvise(1, 0, 0, POSIX_FADV_SEQUENTIAL);
255       posix_fadvise(1, 0, 0, POSIX_FADV_DONTNEED);
256     ]])],
257   [AC_DEFINE(HAVE_POSIX_FADVISE, 1, [Define to 1 if you have the 'posix_fadvise' function])]
260 dnl omindex uses fork(), socketpair(), and setrlimit() to impose resource
261 dnl limits on filter programs.
262 AC_CHECK_FUNCS([mmap fork setrlimit sysmp pstat_getdynamic setpgid sigaction])
264 dnl -lxnet is needed on Solaris and apparently on HP-UX too.
265 AC_SEARCH_LIBS([socketpair], [xnet],
266   [AC_DEFINE(HAVE_SOCKETPAIR, 1,
267     [Define to 1 if you have the 'socketpair' function])])
269 dnl fnmatch() is used to match ignore pattern.
270 AC_CHECK_FUNCS([fnmatch])
272 dnl mingw has _snprintf so check for that too.
273 AC_MSG_CHECKING([for  snprintf])
274 AC_CACHE_VAL([xo_cv_func_snprintf],
275   [
276   xo_cv_func_snprintf=no
277   for func in snprintf _snprintf ; do
278     AC_COMPILE_IFELSE([
279       AC_LANG_PROGRAM(
280         [[
281 #include <cstdio>
282 using namespace std;
283         ]],
284         [[
285           char buffer[4] = "abc";
286           int res = $func(buffer, 4, "%s", "XYZ");
287           return res;
288         ]]
289       )],
290       [xo_cv_func_snprintf=$func;break],
291       []
292     )
293   done
294   ])
295 AC_MSG_RESULT([$xo_cv_func_snprintf])
296 if test "$xo_cv_func_snprintf" != no ; then
297   AC_DEFINE_UNQUOTED([SNPRINTF], [$xo_cv_func_snprintf],
298     [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
301 AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [], [#include <time.h>])
303 AC_ARG_WITH(iconv,
304 [AS_HELP_STRING([--with-iconv], [force use of iconv (error if not found)])
305 AS_HELP_STRING([--without-iconv], [don't use iconv])],
306   [with_iconv=$withval], [with_iconv=auto])
308 if test no != "$with_iconv" ; then
309   dnl AM_ICONV modifies CPPFLAGS if it succeeds which is undesirable (configure
310   dnl shouldn't modify user variables like CPPFLAGS) so save and restore
311   dnl CPPFLAGS around it.  We then add INCICONV where needed instead.
312   save_CPPFLAGS=$CPPFLAGS
313   AM_ICONV
314   CPPFLAGS=$save_CPPFLAGS
315   AC_SUBST([INCICONV])
316   if test yes = "$with_iconv" && test yes != "$am_cv_func_iconv" ; then
317     AC_MSG_ERROR([iconv not found, but --with-iconv specified])
318   fi
321 dnl Check processor endianness.
322 AC_C_BIGENDIAN
324 dnl Check for perl.  Needed for outlookmsg2html script.
325 dnl (And in maintainer-mode, also to make man pages from "--help" output, and
326 dnl to make the omegascript vim syntax mode.)
327 AC_PATH_PROG(PERL, perl, [])
328 AC_ARG_VAR([PERL], [Perl interpreter])
329 test -z "$PERL" && AC_MSG_ERROR([perl is required])
331 if test x"$enable_documentation" = xyes; then
332   dnl Check for help2man. (Needed to make man pages from "--help" output).
333   AC_PATH_PROG(HELP2MAN, help2man, [])
334   AC_ARG_VAR([HELP2MAN], [help2man man page generator])
335   test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
337   dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
338   dnl Also look for rst2html.py, which archlinux reportedly installs it as.
339   AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
340   AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
341   test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation])
344 pcre_runtime_installed() {
345   dnl Simple check to see if the problem is likely to be that we're using a
346   dnl "packaged" pcre but only have the runtime package installed.
347   for sfx in '' 32 64 ; do
348     set /usr/lib$sfx/libpcre2-*.so.*
349     if test "/usr/lib$sfx/libpcre2-*.so.*" != "$1" ; then
350       if test -r /etc/debian_version ; then
351         pkg="libpcre2-dev"
352       else
353         pkg="pcre2-devel"
354       fi
355       AS_SET_STATUS([0])
356     fi
357   done
358   AS_SET_STATUS([1])
361 PCRE2_LIBS_FLAG=--libs8
362 AC_ARG_VAR(PCRE2_CONFIG, [Location of pcre2-config])
363 if test -z "$PCRE2_CONFIG" ; then
364   AC_ARG_VAR(PKG_CONFIG, [Location of pkg-config])
365   AC_PATH_TOOL(PKG_CONFIG, [pkg-config])
366   if test -n "$PKG_CONFIG" ; then
367     pcre_try="$PKG_CONFIG libpcre2-8"
368     if $pcre_try 2>/dev/null ; then
369       PCRE2_CONFIG=$pcre_try
370       PCRE2_LIBS_FLAG=--libs
371     else
372       if pcre_runtime_installed ; then
373         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.])
374       else
375         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.])
376       fi
377     fi
378   else
379     dnl Fall back to looking for pcre2-config, but that's not installed on PATH
380     dnl with the platform tuple prefixed (at least under MXE), so preferring
381     dnl 'pkg-config libpcre2' works better when cross-compiling.
382     AC_PATH_TOOL(PCRE2_CONFIG, [pcre2-config])
383     if test -z $PCRE2_CONFIG ; then
384       if pcre_runtime_installed ; then
385         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.])
386       else
387         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.])
388       fi
389     fi
390   fi
392 PCRE2_CFLAGS=`$PCRE2_CONFIG --cflags`
393 PCRE2_LIBS=`$PCRE2_CONFIG $PCRE2_LIBS_FLAG`
394 AC_SUBST(PCRE2_CFLAGS)
395 AC_SUBST(PCRE2_LIBS)
397 dnl ******************************
398 dnl * Set special compiler flags *
399 dnl ******************************
401 dnl Set flags to control warnings (enable more, or disable annoying ones).
402 if test yes = "$GXX"; then
403   dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
404   dnl we actually have, as neither is really 100% compatible.
405   case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
406     *__INTEL_COMPILER*__clang__*)
407       dnl GCC (since neither substituted):
409       dnl The exact format of g++ --version seems to change with almost every
410       dnl minor release so use the preprocessor macros which should be more
411       dnl robust.
412       AC_MSG_CHECKING([for version of $CXX])
413       gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
414       AC_MSG_RESULT([GCC $gxx_version])
416       dnl -Wundef was supported by g++ 3.0.
417       dnl
418       dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
419       dnl GCC 4.3.
420       dnl
421       dnl -Wdouble-promotion was added in GCC 4.6.
422       dnl
423       dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
424       dnl warns for this case with -Wuninitialized (implied by -W).  We
425       dnl don't intend to use this idiom, so any instances are bugs we'd
426       dnl like to know about.
427       dnl
428       dnl All the other options were supported by g++ 2.95.
429       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"
431       case $gxx_version in
432       [[0123]].*|4.[[0-6]].*)
433         AC_MSG_ERROR([Xapian requires GCC 4.7 or later])
434         ;;
435       4.*|5.*)
436         ;;
437       6.*)
438         AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond"
439         ;;
440       *)
441         AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond -Wduplicated-branches"
442         ;;
443       esac
445       dnl FIXME:
446       dnl -Wold-style-cast is interesting, but triggers for macros from
447       dnl system headers (e.g. FD_SET).  GCC 4.8 improved this by making
448       dnl -ftrack-macro-expansion=2 the default, but we still see such
449       dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
450       dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
451       dnl warnings from zlib.h).
453       dnl Automatically add -Werror if maintainer mode is enabled.
454       if test x$USE_MAINTAINER_MODE = xyes; then
455         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
456       fi
457       ;;
458     *__clang__*)
459       dnl Intel's compiler (since __clang__ not substituted):
460       dnl
461       dnl -w1 stops the avalanche of uninteresting "remark" messages.
462       dnl -wd... disables warnings which don't have good code workarounds.
463       AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
465       dnl Automatically add -Werror if maintainer mode is enabled.
466       if test x$USE_MAINTAINER_MODE = xyes; then
467         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
468       fi
469       ;;
470     *__INTEL_COMPILER*)
471       dnl clang (since __INTEL_COMPILER not substituted):
473       dnl These options all work at least as far back as clang++ 3.0:
474       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"
476       dnl Automatically add -Werror if maintainer mode is enabled.
477       if test x$USE_MAINTAINER_MODE = xyes; then
478         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
479       fi
480       ;;
481   esac
482 else
483   dnl Not GCC, nor a compiler masquerading as GCC.
484   case /$CXX in
485   */aCC)
486     dnl +w turns on more warnings.
487     dnl +wlint turns on "lint-like" warnings.
488     dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
489     dnl 2340 (remark) "value copied to temporary, reference to temporary
490     dnl use", in: throw Xapian::UnimplementedError("...");
491     dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
492     dnl virtual destructor for intrusive_base, since we never delete
493     dnl       its subclasses by a intrusive_base *).
494     dnl 3348 "declaration hides constant ..." which seems to misfire!
495     dnl 4255 (remark) "padding size of struct "..." with ... bytes to
496     dnl alignment boundary".
497     dnl 4273 "floating-point equality and inequality comparisons may be
498     dnl inappropriate due to roundoff common in floating-point computation"
499     dnl No obvious workaround for when you really do want == or !=.
500     dnl 4285 "operator= does not have a check for the source and destination
501     dnl addresses being non-identical" - fires for AutoPtr which
502     dnl includes such a check indirectly (internaltest's autoptr1 check this).
503     dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
504     AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
505   */sunCC|*/CC)
506     dnl Sun's C++ compiler.
507     dnl
508     dnl We use -errtags to report the tag for each warning emitted.
509     dnl
510     dnl We use -erroff to suppress some unhelpful warnings:
511     dnl
512     dnl oklambdaretmulti warns about a lambda with more than one return
513     dnl statement even if they all return the same type.
514     dnl
515     dnl voidretw warns about functions failing to return a value even when the
516     dnl function ends with a "throw" statement.  That's just unhelpful noise,
517     dnl and adding a dummy "return" after "throw" seems a worse solution than
518     dnl simply disabling this warning - any genuinely missing return statements
519     dnl will get reported by compilers with superior warning machinery.
520     XAPIAN_TEST_CXXFLAGS([-errtags -erroff=oklambdaretmulti,voidretw], [AM_CXXFLAGS])
521     ;;
522   esac
525 AH_BOTTOM(
526 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
527 #ifdef _MSC_VER
528 # pragma warning(disable:4800)
529 #endif
531 /* Default to enabling _FORTIFY_SOURCE at level 2.  It shouldn't cause a
532  * problem to define it where it's not supported.
534  * Check if _FORTIFY_SOURCE is already defined to allow the user to override
535  * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
536  */
537 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
538 # define _FORTIFY_SOURCE 2
539 # ifdef __MINGW32__
540 /* Both mingw32 and mingw-w64 define __MINGW32__. */
541 #  include <stddef.h>
542 #  ifdef __MINGW64_VERSION_MAJOR
543 /* Enabling _FORTIFY_SOURCE on newer mingw-w64 requires linking with -lssp so
544  * we simply don't automatically enable it there.
545  */
546 #   undef _FORTIFY_SOURCE
547 #  endif
548 # endif
549 #endif
551 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
552  * we can use __builtin_expect to give the compiler hints about branch
553  * prediction.  See HACKING for how to use these.
554  */
555 #if HAVE_DECL___BUILTIN_EXPECT
556 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
557  * the first argument is always an integer expression, and always 0 or 1, but
558  * still has the same truth value for the if or while it is used in.
559  */
560 # define rare(COND) __builtin_expect(!!(COND), 0)
561 # define usual(COND) __builtin_expect(!!(COND), 1)
562 #else
563 # define rare(COND) (COND)
564 # define usual(COND) (COND)
565 #endif
568 AC_SUBST([AM_CXXFLAGS])
570 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
571 CXXFLAGS=$save_CXXFLAGS
573 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
574 : ${AUTOM4TE=autom4te}
575 AC_SUBST([AUTOM4TE])
577 dnl **************************
578 dnl * Build the output files *
579 dnl **************************
581 AC_CONFIG_FILES([
582  Makefile
583  docs/Makefile
584  xapian-omega.spec
585  ])
586 dnl Allow AC_CONFIG_FILES with chmod +x without having to repeat the filename.
587 AC_DEFUN([SCRIPT_TEMPLATE], [AC_CONFIG_FILES([$1], [chmod +x "$1"])])
588 SCRIPT_TEMPLATE([makemanpage])
589 SCRIPT_TEMPLATE([mhtml2html])
590 SCRIPT_TEMPLATE([outlookmsg2html])
591 SCRIPT_TEMPLATE([rfc822tohtml])
592 SCRIPT_TEMPLATE([vcard2text])
593 AC_OUTPUT