Sync common code between configure.ac files
[xapian.git] / xapian-applications / omega / configure.ac
blobd68167723fa2f163bcdb1501d86620ce2844a1a7
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_mul_overflow(int, int, int*)], [], [], [ ])
106 AC_CHECK_DECLS([__builtin_bswap32(uint32_t)], [], [],
107                [#include <stdint.h>])
108 AC_CHECK_DECLS([_byteswap_ulong], [], [],
109                [#include <stdlib.h>])
110 AC_CHECK_DECLS([__builtin_expect(long, long)], [], [], [ ])
112 dnl Check for time functions.
113 AC_FUNC_STRFTIME
114 AC_CHECK_FUNCS([clock_gettime sleep nanosleep gettimeofday ftime])
115 AC_CHECK_FUNCS([gmtime_r timegm])
117 case $host_os in
118   *mingw*)
119     dnl For _ftime64() on mingw we need to tell it we're happy to require
120     dnl MSVCRT 6.10 or higher, which isn't too onerous a requirement it seems.
121     AC_DEFINE([__MSVCRT_VERSION__], [0x0601], [Define on mingw to the minimum msvcrt version to assume])
122     AC_DEFINE([MINGW_HAS_SECURE_API], [1], [Define on mingw to get _s suffixed "secure" functions declared in headers])
123     ;;
124 esac
126 AC_ARG_ENABLE(documentation,
127   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
128   [case ${enableval} in
129     yes|no) ;;
130     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
131   esac])
132 test -z "$enable_documentation" && enable_documentation=$USE_MAINTAINER_MODE
133 AM_CONDITIONAL(DOCUMENTATION_RULES, test x"$enable_documentation" = xyes)
134 AM_CONDITIONAL(MAINTAINER_NO_DOCS, test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno)
136 vpath_build=no
137 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
138   vpath_build=yes
140 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
142 dnl Check for headers.
143 AC_CHECK_HEADERS([strings.h sys/select.h], [], [], [ ])
144 AC_CHECK_HEADERS([sys/time.h]dnl
145                  [sys/resource.h sys/socket.h sys/sysctl.h vm/vm_param.h]dnl
146                  [sys/vmmeter.h sys/sysmp.h sys/sysinfo.h sys/pstat.h],
147                  [], [], [#include <sys/types.h>])
149 dnl Check for zlib.h.
150 AC_CHECK_HEADERS([zlib.h], [], [
151   AC_MSG_ERROR([zlib.h not found])
152   ], [ ])
154 dnl Check for zlibVersion in -lz.
155 SAVE_LIBS=$LIBS
156 LIBS=
157 dnl mingw build needs -lzlib or -lzdll.
158 AC_SEARCH_LIBS([zlibVersion], [z zlib zdll], [], [
159   AC_MSG_ERROR([zlibVersion() not found in -lz, -lzlib, or -lzdll (you  may need to install the zlib1g-dev or zlib-devel package)])
160   ])
161 ZLIB_LIBS=$LIBS
162 AC_SUBST([ZLIB_LIBS])
163 LIBS=$SAVE_LIBS
165 dnl POSIX requires setenv().  The final Unix-like platform without it seems
166 dnl to have been Solaris 9, which is now out of support.
168 dnl Microsoft don't provide setenv() and have marked putenv() as deprecated, so
169 dnl we use _putenv_s() to avoid deprecation warnings with MSVC.  It's also a
170 dnl more similar interface to setenv() so easier to implement a setenv() wrapper
171 dnl around.  We probe for both the function and a declaration since mingw
172 dnl doesn't currently (v3.20) declare it but it is present in the C runtime DLL
173 dnl so we can provide our own declaration to access it.
174 AC_CHECK_FUNCS([setenv _putenv_s])
175 AC_CHECK_DECLS([_putenv_s(const char*, const char*)], [], [],
176 [#include <stdlib.h>])
178 dnl libmagic used to detect MIME types for files we don't detect by extension.
179 AC_CHECK_HEADERS([magic.h])
180 if test $ac_cv_header_magic_h != yes ; then
181   if test -r /etc/debian_version ; then
182     pkg="libmagic-dev"
183   else
184     pkg="file-devel (or maybe libmagic-devel)"
185   fi
186   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.])
189 dnl On mingw there are several dependent libraries, so AC_CHECK_LIB would
190 dnl fail - we'd have to use LT_OUTPUT and then perform the test link with
191 dnl libtool, but we've checked for magic.h, so checking the library would
192 dnl not really gain us much - we know it is -lmagic.
193 MAGIC_LIBS=-lmagic
194 AC_SUBST([MAGIC_LIBS])
196 if test $ac_cv_func_ftime = yes ; then
197   dnl See if ftime returns void (as it does on mingw)
198   AC_MSG_CHECKING([return type of ftime])
199   AC_COMPILE_IFELSE(
200     [AC_LANG_PROGRAM([[#include <sys/timeb.h>]],
201                      [[struct timeb tp; int i = ftime(&tp);]])],
202     [AC_MSG_RESULT([int])],
203     [AC_MSG_RESULT([void])
204     AC_DEFINE([FTIME_RETURNS_VOID], [1], [Define if ftime returns void])])
207 dnl mingw (for instance) lacks ssize_t
208 AC_TYPE_SSIZE_T
210 AC_TYPE_PID_T
212 AC_TYPE_MODE_T
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. OS X).
218 if test $ac_cv_func_getgrouplist = yes ; then
219   AC_COMPILE_IFELSE(
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 *])],
224     [])
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 dnl Need a full link check for posix_fadvise.
239 AC_LINK_IFELSE([
240   AC_LANG_PROGRAM(
241     [[
242 #ifdef __linux__
243 # define _POSIX_C_SOURCE 200112L /* for posix_fadvise from fcntl.h */
244 #endif
245 #include <fcntl.h>
246     ]], [[
247       posix_fadvise(1, 0, 0, POSIX_FADV_NOREUSE);
248       posix_fadvise(1, 0, 0, POSIX_FADV_SEQUENTIAL);
249       posix_fadvise(1, 0, 0, POSIX_FADV_DONTNEED);
250     ]])],
251   [AC_DEFINE(HAVE_POSIX_FADVISE, 1, [Define to 1 if you have the 'posix_fadvise' function])]
254 dnl omindex uses fork(), socketpair(), and setrlimit() to impose resource
255 dnl limits on filter programs.
256 AC_CHECK_FUNCS([mmap fork setrlimit sysmp pstat_getdynamic setpgid sigaction])
258 dnl -lxnet is needed on Solaris and apparently on HP-UX too.
259 AC_SEARCH_LIBS([socketpair], [xnet],
260   [AC_DEFINE(HAVE_SOCKETPAIR, 1,
261     [Define to 1 if you have the 'socketpair' function])])
263 dnl fnmatch() is used to match ignore pattern.
264 AC_CHECK_FUNCS([fnmatch])
266 dnl mingw has _snprintf so check for that too.
267 AC_MSG_CHECKING([for  snprintf])
268 AC_CACHE_VAL([xo_cv_func_snprintf],
269   [
270   xo_cv_func_snprintf=no
271   for func in snprintf _snprintf ; do
272     AC_COMPILE_IFELSE([
273       AC_LANG_PROGRAM(
274         [[
275 #include <cstdio>
276 using namespace std;
277         ]],
278         [[
279           char buffer[4] = "abc";
280           int res = $func(buffer, 4, "%s", "XYZ");
281           return res;
282         ]]
283       )],
284       [xo_cv_func_snprintf=$func;break],
285       []
286     )
287   done
288   ])
289 AC_MSG_RESULT([$xo_cv_func_snprintf])
290 if test "$xo_cv_func_snprintf" != no ; then
291   AC_DEFINE_UNQUOTED([SNPRINTF], [$xo_cv_func_snprintf],
292     [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
295 AC_CHECK_MEMBERS([struct tm.tm_gmtoff], [], [], [#include <time.h>])
297 AC_ARG_WITH(iconv,
298 [AS_HELP_STRING([--with-iconv], [force use of iconv (error if not found)])
299 AS_HELP_STRING([--without-iconv], [don't use iconv])],
300   [with_iconv=$withval], [with_iconv=auto])
302 if test no != "$with_iconv" ; then
303   dnl AM_ICONV modifies CPPFLAGS if it succeeds which is undesirable (configure
304   dnl shouldn't modify user variables like CPPFLAGS) so save and restore
305   dnl CPPFLAGS around it.  We then add INCICONV where needed instead.
306   save_CPPFLAGS=$CPPFLAGS
307   AM_ICONV
308   CPPFLAGS=$save_CPPFLAGS
309   AC_SUBST([INCICONV])
310   if test yes = "$with_iconv" && test yes != "$am_cv_func_iconv" ; then
311     AC_MSG_ERROR([iconv not found, but --with-iconv specified])
312   fi
315 dnl Check processor endianness.
316 AC_C_BIGENDIAN
318 dnl Check for perl.  Needed for outlookmsg2html script.
319 dnl (And in maintainer-mode, also to make man pages from "--help" output, and
320 dnl to make the omegascript vim syntax mode.)
321 AC_PATH_PROG(PERL, perl, [])
322 AC_ARG_VAR([PERL], [Perl interpreter])
323 test -z "$PERL" && AC_MSG_ERROR([perl is required])
325 if test x"$enable_documentation" = xyes; then
326   dnl Check for help2man. (Needed to make man pages from "--help" output).
327   AC_PATH_PROG(HELP2MAN, help2man, [])
328   AC_ARG_VAR([HELP2MAN], [help2man man page generator])
329   test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
331   dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
332   dnl Also look for rst2html.py, which archlinux reportedly installs it as.
333   AC_PATH_PROGS(RST2HTML, [rst2html rst2html.py], [])
334   AC_ARG_VAR([RST2HTML], [reST to HTML convertor])
335   test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation])
338 pcre_runtime_installed() {
339   dnl Simple check to see if the problem is likely to be that we're using a
340   dnl "packaged" pcre but only have the runtime package installed.
341   for sfx in '' 32 64 ; do
342     set /usr/lib$sfx/libpcre2-*.so.*
343     if test "/usr/lib$sfx/libpcre2-*.so.*" != "$1" ; then
344       if test -r /etc/debian_version ; then
345         pkg="libpcre2-dev"
346       else
347         pkg="pcre2-devel"
348       fi
349       AS_SET_STATUS([0])
350     fi
351   done
352   AS_SET_STATUS([1])
355 PCRE2_LIBS_FLAG=--libs8
356 AC_ARG_VAR(PCRE2_CONFIG, [Location of pcre2-config])
357 if test -z "$PCRE2_CONFIG" ; then
358   AC_ARG_VAR(PKG_CONFIG, [Location of pkg-config])
359   AC_PATH_TOOL(PKG_CONFIG, [pkg-config])
360   if test -n "$PKG_CONFIG" ; then
361     pcre_try="$PKG_CONFIG libpcre2-8"
362     if $pcre_try 2>/dev/null ; then
363       PCRE2_CONFIG=$pcre_try
364       PCRE2_LIBS_FLAG=--libs
365     else
366       if pcre_runtime_installed ; then
367         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.])
368       else
369         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.])
370       fi
371     fi
372   else
373     dnl Fall back to looking for pcre2-config, but that's not installed on PATH
374     dnl with the platform tuple prefixed (at least under MXE), so preferring
375     dnl 'pkg-config libpcre2' works better when cross-compiling.
376     AC_PATH_TOOL(PCRE2_CONFIG, [pcre2-config])
377     if test -z $PCRE2_CONFIG ; then
378       if pcre_runtime_installed ; then
379         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.])
380       else
381         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.])
382       fi
383     fi
384   fi
386 PCRE2_CFLAGS=`$PCRE2_CONFIG --cflags`
387 PCRE2_LIBS=`$PCRE2_CONFIG $PCRE2_LIBS_FLAG`
388 AC_SUBST(PCRE2_CFLAGS)
389 AC_SUBST(PCRE2_LIBS)
391 dnl ******************************
392 dnl * Set special compiler flags *
393 dnl ******************************
395 dnl Set flags to control warnings (enable more, or disable annoying ones).
396 if test yes = "$GXX"; then
397   dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
398   dnl we actually have, as neither is really 100% compatible.
399   case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
400     *__INTEL_COMPILER*__clang__*)
401       dnl GCC (since neither substituted):
403       dnl The exact format of g++ --version seems to change with almost every
404       dnl minor release so use the preprocessor macros which should be more
405       dnl robust.
406       AC_MSG_CHECKING([for version of $CXX])
407       gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
408       AC_MSG_RESULT([GCC $gxx_version])
410       dnl -Wundef was supported by g++ 3.0.
411       dnl
412       dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
413       dnl GCC 4.3.
414       dnl
415       dnl -Wdouble-promotion was added in GCC 4.6.
416       dnl
417       dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
418       dnl warns for this case with -Wuninitialized (implied by -W).  We
419       dnl don't intend to use this idiom, so any instances are bugs we'd
420       dnl like to know about.
421       dnl
422       dnl All the other options were supported by g++ 2.95.
423       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"
425       case $gxx_version in
426       [[0123]].*|4.[[0-6]].*)
427         AC_MSG_ERROR([Xapian requires GCC 4.7 or later])
428         ;;
429       4.*|5.*)
430         ;;
431       6.*)
432         AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond"
433         ;;
434       *)
435         AM_CXXFLAGS="$AM_CXXFLAGS -Wduplicated-cond -Wduplicated-branches"
436         ;;
437       esac
439       dnl FIXME:
440       dnl -Wold-style-cast is interesting, but triggers for macros from
441       dnl system headers (e.g. FD_SET).  GCC 4.8 improved this by making
442       dnl -ftrack-macro-expansion=2 the default, but we still see such
443       dnl warnings on some platforms for some reason (e.g. Cygwin with GCC
444       dnl 5.4.0 warns about FD_SET, and on Debian with GCC 4.9.2 we see
445       dnl warnings from zlib.h).
447       dnl Automatically add -Werror if maintainer mode is enabled.
448       if test x$USE_MAINTAINER_MODE = xyes; then
449         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
450       fi
451       ;;
452     *__clang__*)
453       dnl Intel's compiler (since __clang__ not substituted):
454       dnl
455       dnl -w1 stops the avalanche of uninteresting "remark" messages.
456       dnl -wd... disables warnings which don't have good code workarounds.
457       AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
459       dnl Automatically add -Werror if maintainer mode is enabled.
460       if test x$USE_MAINTAINER_MODE = xyes; then
461         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
462       fi
463       ;;
464     *__INTEL_COMPILER*)
465       dnl clang (since __INTEL_COMPILER not substituted):
467       dnl These options all work at least as far back as clang++ 3.0:
468       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"
470       dnl Automatically add -Werror if maintainer mode is enabled.
471       if test x$USE_MAINTAINER_MODE = xyes; then
472         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
473       fi
474       ;;
475   esac
476 else
477   dnl Not GCC, nor a compiler masquerading as GCC.
478   case /$CXX in
479   */aCC)
480     dnl +w turns on more warnings.
481     dnl +wlint turns on "lint-like" warnings.
482     dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
483     dnl 2340 (remark) "value copied to temporary, reference to temporary
484     dnl use", in: throw Xapian::UnimplementedError("...");
485     dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
486     dnl virtual destructor for intrusive_base, since we never delete
487     dnl       its subclasses by a intrusive_base *).
488     dnl 3348 "declaration hides constant ..." which seems to misfire!
489     dnl 4255 (remark) "padding size of struct "..." with ... bytes to
490     dnl alignment boundary".
491     dnl 4273 "floating-point equality and inequality comparisons may be
492     dnl inappropriate due to roundoff common in floating-point computation"
493     dnl No obvious workaround for when you really do want == or !=.
494     dnl 4285 "operator= does not have a check for the source and destination
495     dnl addresses being non-identical" - fires for AutoPtr which
496     dnl includes such a check indirectly (internaltest's autoptr1 check this).
497     dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
498     AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
499   */sunCC|*/CC)
500     dnl Sun's C++ compiler.
501     dnl
502     dnl We use -errtags to report the tag for each warning emitted.
503     dnl
504     dnl We use -erroff to suppress some unhelpful warnings:
505     dnl
506     dnl oklambdaretmulti warns about a lambda with more than one return
507     dnl statement even if they all return the same type.
508     dnl
509     dnl voidretw warns about functions failing to return a value even when the
510     dnl function ends with a "throw" statement.  That's just unhelpful noise,
511     dnl and adding a dummy "return" after "throw" seems a worse solution than
512     dnl simply disabling this warning - any genuinely missing return statements
513     dnl will get reported by compilers with superior warning machinery.
514     XAPIAN_TEST_CXXFLAGS([-errtags -erroff=oklambdaretmulti,voidretw], [AM_CXXFLAGS])
515     ;;
516   esac
519 AH_BOTTOM(
520 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
521 #ifdef _MSC_VER
522 # pragma warning(disable:4800)
523 #endif
525 /* Default to enabling _FORTIFY_SOURCE at level 2.  It shouldn't cause a
526  * problem to define it where it's not supported.
528  * Check if _FORTIFY_SOURCE is already defined to allow the user to override
529  * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
530  */
531 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
532 # define _FORTIFY_SOURCE 2
533 # ifdef __MINGW32__
534 /* Both mingw32 and mingw-w64 define __MINGW32__. */
535 #  include <stddef.h>
536 #  ifdef __MINGW64_VERSION_MAJOR
537 /* Enabling _FORTIFY_SOURCE on newer mingw-w64 requires linking with -lssp so
538  * we simply don't automatically enable it there.
539  */
540 #   undef _FORTIFY_SOURCE
541 #  endif
542 # endif
543 #endif
545 /* For compilers which support it (such as GCC, clang, Intel's C++ compiler)
546  * we can use __builtin_expect to give the compiler hints about branch
547  * prediction.  See HACKING for how to use these.
548  */
549 #if HAVE_DECL___BUILTIN_EXPECT
550 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
551  * the first argument is always an integer expression, and always 0 or 1, but
552  * still has the same truth value for the if or while it is used in.
553  */
554 # define rare(COND) __builtin_expect(!!(COND), 0)
555 # define usual(COND) __builtin_expect(!!(COND), 1)
556 #else
557 # define rare(COND) (COND)
558 # define usual(COND) (COND)
559 #endif
562 AC_SUBST([AM_CXXFLAGS])
564 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
565 CXXFLAGS=$save_CXXFLAGS
567 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
568 : ${AUTOM4TE=autom4te}
569 AC_SUBST([AUTOM4TE])
571 dnl **************************
572 dnl * Build the output files *
573 dnl **************************
575 AC_CONFIG_FILES([
576  Makefile
577  docs/Makefile
578  xapian-omega.spec
579  ])
580 dnl Allow AC_CONFIG_FILES with chmod +x without having to repeat the filename.
581 AC_DEFUN([SCRIPT_TEMPLATE], [AC_CONFIG_FILES([$1], [chmod +x "$1"])])
582 SCRIPT_TEMPLATE([makemanpage])
583 SCRIPT_TEMPLATE([mhtml2html])
584 SCRIPT_TEMPLATE([outlookmsg2html])
585 SCRIPT_TEMPLATE([rfc822tohtml])
586 SCRIPT_TEMPLATE([vcard2text])
587 AC_OUTPUT