Improve @param docs for Database::compact()
[xapian.git] / xapian-letor / configure.ac
blobb6eb74d015d2868a1718972b0fadf5643347e9f7
1 dnl Process this file with autoconf to produce a configure script.
3 dnl NB When updating the version for a release, update LIBRARY_VERSION_INFO
4 dnl below too.
5 m4_define([project_version], [1.3.0])
6 AC_INIT([xapian-letor], project_version, [http://xapian.org/bugs])
8 AC_PREREQ([2.64])
9 dnl Extract from the libtool info manual:
10 dnl
11 dnl Here are a set of rules to help you update your library version information:
12 dnl
13 dnl 1. Start with version information of '0:0:0' for each libtool library.
14 dnl
15 dnl 2. Update the version information only immediately before a public
16 dnl    release of your software.  More frequent updates are unnecessary,
17 dnl    and only guarantee that the current interface number gets larger
18 dnl    faster.
19 dnl
20 dnl 3. If the library source code has changed at all since the last
21 dnl    update, then increment REVISION ('C:R:A' becomes 'C:r+1:A').
22 dnl
23 dnl 4. If any interfaces have been added, removed, or changed since the
24 dnl    last update, increment CURRENT, and set REVISION to 0.
25 dnl
26 dnl 5. If any interfaces have been added since the last public release,
27 dnl    then increment AGE.
28 dnl
29 dnl 6. If any interfaces have been removed since the last public release
30 dnl    then set AGE to 0.
31 dnl
32 dnl LIBRARY_VERSION_INFO for libxapianletor:
33 dnl 0:0:0 1.3.1 First release with xapian-letor split out from xapian-core
34 LIBRARY_VERSION_INFO=0:0:0
35 AC_SUBST(LIBRARY_VERSION_INFO)
37 AM_INIT_AUTOMAKE([1.10.1 -Wportability tar-ustar])
39 AC_CONFIG_SRCDIR([letor.cc])
41 AC_CONFIG_HEADERS([config.h])
43 AC_CONFIG_MACRO_DIR([m4])
45 LT_PREREQ([2.2.8])
46 LT_INIT
48 dnl disable "maintainer only" rules by default
49 AM_MAINTAINER_MODE
51 dnl Checks for programs.
52 AC_PROG_CXX
54 AC_CANONICAL_HOST
56 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
57 case $host_os in
58   linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
59     dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
60     link_all_deplibs_CXX=no
61     ;;
62 esac
64 case $host_os in
65   linux*)
66     dnl Extract search path from ldconfig which is more reliable than the way
67     dnl vanilla libtool extracts them from ld.so.conf.
68     d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
69     test -z "$d" || sys_lib_dlsearch_path_spec=$d
70     ;;
71 esac
73 dnl Probe for any options needed to enable C++11 support.
74 AX_CXX_COMPILE_STDCXX_11
76 dnl Run tests using the C++ compiler.
77 AC_LANG_CPLUSPLUS
79 dnl Check for xapian-core.
80 XO_LIB_XAPIAN([], [],
81     [xapian-config]regexp(project_version,
82                           [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
84 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
85 save_CXXFLAGS=$CXXFLAGS
86 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
87 dnl mingw (for instance) lacks ssize_t
88 AC_TYPE_SSIZE_T
90 AC_TYPE_PID_T
92 AC_TYPE_MODE_T
94 dnl Check for perl (needed to generate some sources and documentation).
95 AC_PATH_PROG([PERL], [perl], [])
96 if test x$USE_MAINTAINER_MODE = xyes; then
97   test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
100 AC_ARG_ENABLE([documentation],
101   [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
102   [case ${enableval} in
103     yes|no) ;;
104     *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
105   esac],
106   [enable_documentation=$USE_MAINTAINER_MODE])
107 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
108 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
110 if test x"$enable_documentation" = xyes ; then
111   dnl Check for help2man. (Needed to make man pages from "--help" output).
112   AC_PATH_PROG([HELP2MAN], [help2man], [])
113   test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
115   dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
116   dnl Also look for rst2html.py, which archlinux reportedly installs it as.
117   AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
118   test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
121 dnl Checks for header files.
122 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
124 dnl libsvm is required.
125 AC_CHECK_HEADER([libsvm/svm.h], [], AC_MSG_ERROR([libsvm required but libsvm/svm.h not found]), [ ])
126 save_LIBS=$LIBS
127 LIBS=
128 AC_SEARCH_LIBS([svm_train], [svm], [], AC_MSG_ERROR([libsvm required]))
129 LIBSVM_LIBS=$LIBS
130 LIBS=$save_LIBS
131 AC_SUBST([LIBSVM_LIBS])
133 dnl Check that snprintf actually works as it's meant to.
135 dnl Linux 'man snprintf' warns:
136 dnl  Linux libc4.[45] does not have a snprintf, but provides a libbsd that
137 dnl  contains an snprintf equivalent to sprintf, i.e., one that ignores the
138 dnl  size argument.  Thus, the use of snprintf with early libc4 leads to
139 dnl  serious security problems.
141 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C90
142 dnl implementations) return -1 when truncating so check that we get the
143 dnl ISO C90 semantics for the returned length when truncating.  If we
144 dnl have a working snprintf but with non-ISO return semantics, handle
145 dnl that case separately as it may still be useful in many cases.
147 dnl mingw has _snprintf so check for that too.
148 AC_MSG_CHECKING([for working ISO C90 conforming snprintf])
149 ac_cv_func_snprintf_noniso=no
150 for func in snprintf _snprintf ; do
151   AC_RUN_IFELSE([
152     AC_LANG_PROGRAM(
153       [[
154 #include <cstdio>
155 #include <cstring>
156 using namespace std;
157       ]],
158       dnl Return different exit status for each error so we can see which
159       dnl check failed by consulting config.log.
160       [[
161         char buffer[4] = "abc";
162         int res1 = $func(buffer, 2, "%s", "XYZ");
163         if (memcmp(buffer, "X\0c", 4) != 0) return 2;
164         int res2 = $func(buffer, 2, "%x", 0x12);
165         if (memcmp(buffer, "1\0c", 4) != 0) return 3;
166         if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
167         if (res1 != 3) return 4;
168         if (res2 != 2) return 5;
169       ]]
170     )],
171     [ac_cv_func_snprintf=$func;break],
172     [
173     if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
174       ac_cv_func_snprintf_noniso=$func
175     fi
176     ac_cv_func_snprintf=no
177     ],
178     [ac_cv_func_snprintf=unknown;break]
179   )
180 done
181 AC_MSG_RESULT([$ac_cv_func_snprintf])
182 case $ac_cv_func_snprintf in
183   no)
184     AC_MSG_CHECKING([for working non-ISO C90 conforming snprintf])
185     AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
186     if test no != "$ac_cv_func_snprintf_noniso" ; then
187       AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
188         [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
189     fi
190     ;;
191   unknown)
192     dnl be conservative when crosscompiling
193     ;;
194   *)
195     AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
196        [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
197     AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
198        [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
199     ;;
200 esac
202 dnl ******************************
203 dnl * Set special compiler flags *
204 dnl ******************************
206 dnl Set flags to control warnings (enable more, or disable annoying ones).
207 dash_d_visibility=
208 if test yes = "$GXX"; then
209   dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
210   dnl we actually have, as neither is really 100% compatible.
211   case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
212     *__INTEL_COMPILER*__clang__*)
213       dnl GCC (since neither substituted):
214       dnl
215       dnl -Wundef was supported by g++ 3.0 and -fshow-column by g++ 3.1.
216       dnl
217       dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
218       dnl GCC 4.3.
219       dnl
220       dnl All the other options were supported by g++ 2.95.
221       AM_CXXFLAGS="$AM_CXXFLAGS -fshow-column -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual -Wstrict-null-sentinel -Wshadow -Wstrict-overflow=1 -Wlogical-op -Wmissing-declarations"
223       dnl The exact format of g++ --version seems to change with almost every
224       dnl minor release so use the preprocessor macros which should be more
225       dnl robust.
226       AC_MSG_CHECKING([for version of $CXX])
227       gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
228       AC_MSG_RESULT([GCC $gxx_version])
230       case $gxx_version in
231       [[0123]].*|4.[[0123]].*)
232         AC_MSG_ERROR([Xapian requires GCC 4.4 or later])
233         ;;
234       4.[[45]].*) ;;
235       *) dnl GCC >= 4.6
236         dnl -Wdouble-promotion was added in GCC 4.6.
237         dnl
238         dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
239         dnl warns for this case with -Wuninitialized (implied by -W).  We
240         dnl don't intend to use this idiom, so any instances are bugs we'd
241         dnl like to know about.
242         AM_CXXFLAGS="$AM_CXXFLAGS -Wdouble-promotion -Winit-self" ;;
243       esac
245       dnl FIXME:
246       dnl -Wconversion in older GCC versions is intended to help migration
247       dnl from K&R to ISO C, and isn't useful for us.  In 4.3 it was renamed
248       dnl to -Wtraditional-conversion and a new -Wconversion added which
249       dnl sounds useful but is a bit buggy currently.  So we should consider
250       dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
251       dnl
252       dnl -Wold-style-cast is interesting, but triggers for macros from
253       dnl system headers (e.g. FD_SET) (tested with GCC 4.4).
255       dnl Automatically add -Werror if maintainer mode is enabled.
256       if test x$USE_MAINTAINER_MODE = xyes; then
257         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
258       fi
259       ;;
260     *__clang__*)
261       dnl Intel's compiler (since __clang__ not substituted):
262       dnl
263       dnl -w1 stops the avalanche of uninteresting "remark" messages.
264       dnl -wd... disables warnings which don't have good code workarounds.
265       AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
267       dnl Automatically add -Werror if maintainer mode is enabled.
268       if test x$USE_MAINTAINER_MODE = xyes; then
269         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
270       fi
271       ;;
272     *__INTEL_COMPILER*)
273       dnl clang (since __INTEL_COMPILER not substituted):
274       AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wno-long-long -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual"
275       AM_CXXFLAGS="$AM_CXXFLAGS -Wshadow -Wstrict-overflow=1 -Winit-self -Wmissing-declarations"
277       dnl Automatically add -Werror if maintainer mode is enabled.
278       if test x$USE_MAINTAINER_MODE = xyes; then
279         AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
280       fi
281       ;;
282   esac
284   if test no != "$enable_visibility"; then
285     dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
286     dnl on mingw).
287     AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
288     if echo 'int bar() __attribute__((visibility("default"))); int foo() {return 42;}'|$CXX -Werror -fvisibility=hidden -c -oconftest.o -xc++ - >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
289       AC_MSG_RESULT([yes])
290       AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
291       dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
292     else
293       AC_MSG_RESULT([no])
294     fi
295   fi
296 else
297   dnl Not GCC, nor a compiler masquerading as GCC.
298   case /$CXX in
299   */aCC)
300     dnl +w turns on more warnings.
301     dnl +wlint turns on "lint-like" warnings.
302     dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
303     dnl 2340 (remark) "value copied to temporary, reference to temporary
304     dnl use", in: throw Xapian::UnimplementedError("...");
305     dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
306     dnl virtual destructor for intrusive_base, since we never delete
307     dnl       its subclasses by a intrusive_base *).
308     dnl 3348 "declaration hides constant ..." which seems to misfire!
309     dnl 4255 (remark) "padding size of struct "..." with ... bytes to
310     dnl alignment boundary".
311     dnl 4273 "floating-point equality and inequality comparisons may be
312     dnl inappropriate due to roundoff common in floating-point computation"
313     dnl No obvious workaround for when you really do want == or !=.
314     dnl 4285 "operator= does not have a check for the source and destination
315     dnl addresses being non-identical" - fires for AutoPtr which
316     dnl includes such a check indirectly (internaltest's autoptr1 check this).
317     dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
318     AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
319   esac
322 AH_BOTTOM(
323 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
324 #ifdef _MSC_VER
325 # pragma warning(disable:4800)
326 #endif
328 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
329  * shouldn't cause a problem to define it where it's not supported and some
330  * distros may have backported support, so hardcoding version checks is
331  * counter-productive.
333  * Check if _FORTIFY_SOURCE is already defined to allow the user to override
334  * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
335  */
336 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
337 # define _FORTIFY_SOURCE 2
338 #endif
340 /* For GCC >= 3.0 (and Intel's C++ compiler, which also defines __GNUC__),
341  * we can use __builtin_expect to give the compiler hints about branch
342  * prediction.  See HACKING for how to use these.
343  */
344 #if defined __GNUC__
345 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
346  * the first argument is always an integer expression, and always 0 or 1, but
347  * still has the same truth value for the if or while it is used in.
348  */
349 # define rare(COND) __builtin_expect(!!(COND), 0)
350 # define usual(COND) __builtin_expect(!!(COND), 1)
351 #else
352 # define rare(COND) (COND)
353 # define usual(COND) (COND)
354 #endif
357 AC_SUBST([AM_CXXFLAGS])
359 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
360 CXXFLAGS=$save_CXXFLAGS
362 dnl Enable large file support if possible.
363 AC_SYS_LARGEFILE
365 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
366 : ${AUTOM4TE=autom4te}
367 AC_SUBST([AUTOM4TE])
369 dnl We want to be able to use GNU make % pattern rules in maintainer targets
370 dnl but automake warns these aren't portable, so we substitute the % to avoid
371 dnl this warning.
372 PERCENT='%'
373 AC_SUBST([PERCENT])
375 dnl **************************
376 dnl * Build the output files *
377 dnl **************************
379 AC_CONFIG_FILES([
380  Makefile
381  docs/Makefile
382  ])
383 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
384 AC_OUTPUT