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
5 m4_define([project_version], [1.3.0])
6 AC_INIT([xapian-letor], project_version, [https://xapian.org/bugs])
9 dnl Extract from the libtool info manual:
11 dnl Here are a set of rules to help you update your library version information:
13 dnl 1. Start with version information of '0:0:0' for each libtool library.
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
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').
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.
26 dnl 5. If any interfaces have been added since the last public release,
27 dnl then increment AGE.
29 dnl 6. If any interfaces have been removed since the last public release
30 dnl then set AGE to 0.
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 dnl Where xapian-letor.h, etc go. In development release append "/xapian-1.3".
41 AM_INIT_AUTOMAKE([1.10.1 -Wportability tar-ustar])
43 AC_CONFIG_SRCDIR([ranker/ranker.cc])
45 AC_CONFIG_HEADERS([config.h])
47 AC_CONFIG_MACRO_DIR([m4])
52 dnl disable "maintainer only" rules by default
55 dnl Checks for programs.
60 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
62 linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
63 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
64 link_all_deplibs_CXX=no
70 dnl Extract search path from ldconfig which is more reliable than the way
71 dnl vanilla libtool extracts them from ld.so.conf.
72 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
73 test -z "$d" || sys_lib_dlsearch_path_spec=$d
77 dnl Probe for any options needed to enable C++11 support.
78 AX_CXX_COMPILE_STDCXX_11
80 dnl Run tests using the C++ compiler.
83 dnl Check for xapian-core.
85 [xapian-config]regexp(project_version,
86 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
88 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
89 save_CXXFLAGS=$CXXFLAGS
90 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
91 dnl mingw (for instance) lacks ssize_t
98 dnl Check for perl (needed to generate some sources and documentation).
99 AC_PATH_PROG([PERL], [perl], [])
100 if test x$USE_MAINTAINER_MODE = xyes; then
101 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
104 AC_ARG_ENABLE([documentation],
105 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
106 [case ${enableval} in
108 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
110 [enable_documentation=$USE_MAINTAINER_MODE])
111 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
112 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
114 if test x"$enable_documentation" = xyes ; then
115 dnl Check for help2man. (Needed to make man pages from "--help" output).
116 AC_PATH_PROG([HELP2MAN], [help2man], [])
117 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
119 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
120 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
121 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
122 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
125 dnl Checks for header files.
126 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
128 dnl C++11 should have log2(), but keep this check for now to allow for
129 dnl compilers with incomplete library support for C++11.
130 AC_CHECK_DECLS([log2], [], [], [#include <cmath>])
132 dnl libsvm is required.
133 AC_CHECK_HEADER([libsvm/svm.h], [], AC_MSG_ERROR([libsvm required but libsvm/svm.h not found]), [ ])
136 AC_SEARCH_LIBS([svm_train], [svm], [], AC_MSG_ERROR([libsvm required]))
139 AC_SUBST([LIBSVM_LIBS])
141 dnl Check that snprintf actually works as it's meant to.
143 dnl Linux 'man snprintf' warns:
144 dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
145 dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
146 dnl size argument. Thus, the use of snprintf with early libc4 leads to
147 dnl serious security problems.
149 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C90
150 dnl implementations) return -1 when truncating so check that we get the
151 dnl ISO C90 semantics for the returned length when truncating. If we
152 dnl have a working snprintf but with non-ISO return semantics, handle
153 dnl that case separately as it may still be useful in many cases.
155 dnl mingw has _snprintf so check for that too.
156 AC_MSG_CHECKING([for working ISO C90 conforming snprintf])
157 ac_cv_func_snprintf_noniso=no
158 for func in snprintf _snprintf ; do
166 dnl Return different exit status for each error so we can see which
167 dnl check failed by consulting config.log.
169 char buffer[4] = "abc";
170 int res1 = $func(buffer, 2, "%s", "XYZ");
171 if (memcmp(buffer, "X\0c", 4) != 0) return 2;
172 int res2 = $func(buffer, 2, "%x", 0x12);
173 if (memcmp(buffer, "1\0c", 4) != 0) return 3;
174 if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
175 if (res1 != 3) return 4;
176 if (res2 != 2) return 5;
179 [ac_cv_func_snprintf=$func;break],
181 if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
182 ac_cv_func_snprintf_noniso=$func
184 ac_cv_func_snprintf=no
186 [ac_cv_func_snprintf=unknown;break]
189 AC_MSG_RESULT([$ac_cv_func_snprintf])
190 case $ac_cv_func_snprintf in
192 AC_MSG_CHECKING([for working non-ISO C90 conforming snprintf])
193 AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
194 if test no != "$ac_cv_func_snprintf_noniso" ; then
195 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
196 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
200 dnl be conservative when crosscompiling
203 AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
204 [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
205 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
206 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
210 dnl ******************************
211 dnl * Set special compiler flags *
212 dnl ******************************
214 dnl Set flags to control warnings (enable more, or disable annoying ones).
216 if test yes = "$GXX"; then
217 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
218 dnl we actually have, as neither is really 100% compatible.
219 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
220 *__INTEL_COMPILER*__clang__*)
221 dnl GCC (since neither substituted):
223 dnl -Wundef was supported by g++ 3.0.
225 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
228 dnl All the other options were supported by g++ 2.95.
229 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"
231 dnl The exact format of g++ --version seems to change with almost every
232 dnl minor release so use the preprocessor macros which should be more
234 AC_MSG_CHECKING([for version of $CXX])
235 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
236 AC_MSG_RESULT([GCC $gxx_version])
239 [[0123]].*|4.[[0123]].*)
240 AC_MSG_ERROR([Xapian requires GCC 4.4 or later])
244 dnl -Wdouble-promotion was added in GCC 4.6.
246 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
247 dnl warns for this case with -Wuninitialized (implied by -W). We
248 dnl don't intend to use this idiom, so any instances are bugs we'd
249 dnl like to know about.
250 AM_CXXFLAGS="$AM_CXXFLAGS -Wdouble-promotion -Winit-self" ;;
254 dnl -Wconversion in older GCC versions is intended to help migration
255 dnl from K&R to ISO C, and isn't useful for us. In 4.3 it was renamed
256 dnl to -Wtraditional-conversion and a new -Wconversion added which
257 dnl sounds useful but is a bit buggy currently. So we should consider
258 dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
260 dnl -Wold-style-cast is interesting, but triggers for macros from
261 dnl system headers (e.g. FD_SET) (tested with GCC 4.4).
263 dnl Automatically add -Werror if maintainer mode is enabled.
264 if test x$USE_MAINTAINER_MODE = xyes; then
265 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
269 dnl Intel's compiler (since __clang__ not substituted):
271 dnl -w1 stops the avalanche of uninteresting "remark" messages.
272 dnl -wd... disables warnings which don't have good code workarounds.
273 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
275 dnl Automatically add -Werror if maintainer mode is enabled.
276 if test x$USE_MAINTAINER_MODE = xyes; then
277 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
281 dnl clang (since __INTEL_COMPILER not substituted):
282 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual"
283 AM_CXXFLAGS="$AM_CXXFLAGS -Wshadow -Wstrict-overflow=1 -Winit-self -Wmissing-declarations"
285 dnl Automatically add -Werror if maintainer mode is enabled.
286 if test x$USE_MAINTAINER_MODE = xyes; then
287 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
292 if test no != "$enable_visibility"; then
293 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
295 AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
296 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
298 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
299 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
305 dnl Not GCC, nor a compiler masquerading as GCC.
308 dnl +w turns on more warnings.
309 dnl +wlint turns on "lint-like" warnings.
310 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
311 dnl 2340 (remark) "value copied to temporary, reference to temporary
312 dnl use", in: throw Xapian::UnimplementedError("...");
313 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
314 dnl virtual destructor for intrusive_base, since we never delete
315 dnl its subclasses by a intrusive_base *).
316 dnl 3348 "declaration hides constant ..." which seems to misfire!
317 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
318 dnl alignment boundary".
319 dnl 4273 "floating-point equality and inequality comparisons may be
320 dnl inappropriate due to roundoff common in floating-point computation"
321 dnl No obvious workaround for when you really do want == or !=.
322 dnl 4285 "operator= does not have a check for the source and destination
323 dnl addresses being non-identical" - fires for AutoPtr which
324 dnl includes such a check indirectly (internaltest's autoptr1 check this).
325 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
326 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
331 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
333 # pragma warning(disable:4800)
336 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
337 * shouldn't cause a problem to define it where it's not supported and some
338 * distros may have backported support, so hardcoding version checks is
339 * counter-productive.
341 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
342 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
344 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
345 # define _FORTIFY_SOURCE 2
348 /* For GCC >= 3.0 (and Intel's C++ compiler, which also defines __GNUC__),
349 * we can use __builtin_expect to give the compiler hints about branch
350 * prediction. See HACKING for how to use these.
353 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
354 * the first argument is always an integer expression, and always 0 or 1, but
355 * still has the same truth value for the if or while it is used in.
357 # define rare(COND) __builtin_expect(!!(COND), 0)
358 # define usual(COND) __builtin_expect(!!(COND), 1)
360 # define rare(COND) (COND)
361 # define usual(COND) (COND)
365 AC_DEFINE([XAPIAN_LIB_BUILD], [1], [Workaround for avoiding sub-header included error])
367 AC_SUBST([AM_CXXFLAGS])
369 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
370 CXXFLAGS=$save_CXXFLAGS
372 dnl Enable large file support if possible.
375 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
376 : ${AUTOM4TE=autom4te}
379 dnl We want to be able to use GNU make % pattern rules in maintainer targets
380 dnl but automake warns these aren't portable, so we substitute the % to avoid
385 dnl If valgrind is installed and new enough, we use it for leak checking in the
386 dnl testsuite. If VALGRIND is set to an empty value, then skip the check and
387 dnl don't use valgrind.
388 if test -n "${VALGRIND-unset}" ; then
389 AC_PATH_PROG([VALGRIND], [valgrind], [])
390 if test -n "$VALGRIND" ; then
391 dnl Check that the installed valgrind version works, and supports the
392 dnl options we use. This means we won't try to use valgrind < 3.3.0
393 dnl (released 7/12/2007) since before that --log-file didn't expand
394 dnl %p (and appended the process id).
396 dnl No need to check for VALGRIND_COUNT_LEAKS now - that was added before
398 AC_MSG_CHECKING([if valgrind supports --log-file with %p])
399 vglog=config.vglog.%p.tmp
400 vglogwild="config.vglog.*.tmp*"
402 if $VALGRIND --log-file="$vglog" -q true 2>&AS_MESSAGE_LOG_FD ; then
403 for f in $vglogwild ; do
405 $vglog*) VALGRIND= ;;
408 if test x"$VALGRIND" = x ; then
412 AC_CHECK_HEADERS([valgrind/memcheck.h], [], [VALGRIND=], [ ])
415 dnl The valgrind detected doesn't seem to work! Perhaps this is an
416 dnl x86_64 box with a 32 bit valgrind.
417 AC_MSG_RESULT([$VALGRIND doesn't work])
424 if test -n "$VALGRIND" ; then
425 AC_DEFINE([HAVE_VALGRIND], [1], [Define if a suitable valgrind is installed])
428 dnl If eatmydata is installed, we run the testsuite under it to speed it up.
429 dnl If EATMYDATA is set to an empty value, then skip this check and don't use
431 if test -n "${EATMYDATA-unset}" ; then
432 AC_PATH_PROG([EATMYDATA], [eatmydata], [])
435 dnl Used by tests/harness/testsuite.cc
436 AC_CHECK_FUNCS([sigaction])
437 AC_MSG_CHECKING([for sigsetjmp and siglongjmp])
438 AC_TRY_COMPILE([#include <setjmp.h>],
439 [sigjmp_buf jb; if (sigsetjmp(jb, 1)) { siglongjmp(jb, 1); }],
440 AC_DEFINE([HAVE_SIGSETJMP], [1], [Define to 1 if you have the 'sigsetjmp' function])
441 AC_MSG_RESULT([yes]),
444 AC_ARG_ENABLE([visibility],
445 [AS_HELP_STRING([--disable-visibility], [disable use of GCC visibility])],
446 [case ${enableval} in
448 *) AC_MSG_ERROR([bad value ${enableval} for --disable-visibility]) ;;
452 if test "`pwd`" != "`cd $srcdir;pwd`" ; then
455 AM_CONDITIONAL([VPATH_BUILD], [test yes = "$vpath_build"])
457 dnl Used to decide if we should use the zlib-vg.so LD_PRELOAD hack.
459 if test -n "$VALGRIND" ; then
461 linux*) use_zlib_vg=yes ;;
464 AM_CONDITIONAL([USE_ZLIB_VG], [test yes = "$use_zlib_vg"])
466 dnl **************************
467 dnl * Build the output files *
468 dnl **************************
475 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])
476 AC_CONFIG_FILES([tests/runtest], [chmod +x tests/runtest])