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".
38 dnl incdir=$includedir
39 incdir=$includedir/xapian-1.3
42 AM_INIT_AUTOMAKE([1.10.1 -Wportability tar-ustar])
44 AC_CONFIG_SRCDIR([api/letor.cc])
46 AC_CONFIG_HEADERS([config.h])
48 AC_CONFIG_MACRO_DIR([m4])
53 dnl disable "maintainer only" rules by default
56 dnl Checks for programs.
61 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
63 linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
64 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
65 link_all_deplibs_CXX=no
71 dnl Extract search path from ldconfig which is more reliable than the way
72 dnl vanilla libtool extracts them from ld.so.conf.
73 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
74 test -z "$d" || sys_lib_dlsearch_path_spec=$d
78 dnl Probe for any options needed to enable C++11 support.
79 AX_CXX_COMPILE_STDCXX_11
81 dnl Run tests using the C++ compiler.
84 dnl Check for xapian-core.
86 [xapian-config]regexp(project_version,
87 [^\([0-9]*\.[0-9]*[13579]\)\..*$], [-\1]))
90 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
91 save_CXXFLAGS=$CXXFLAGS
92 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
93 dnl mingw (for instance) lacks ssize_t
100 dnl Check for perl (needed to generate some sources and documentation).
101 AC_PATH_PROG([PERL], [perl], [])
102 if test x$USE_MAINTAINER_MODE = xyes; then
103 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
106 AC_ARG_ENABLE([documentation],
107 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
108 [case ${enableval} in
110 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
112 [enable_documentation=$USE_MAINTAINER_MODE])
113 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
114 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
116 if test x"$enable_documentation" = xyes ; then
117 dnl Check for help2man. (Needed to make man pages from "--help" output).
118 AC_PATH_PROG([HELP2MAN], [help2man], [])
119 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
121 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
122 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
123 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
124 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
127 dnl Checks for header files.
128 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
130 dnl libsvm is required.
131 AC_CHECK_HEADER([libsvm/svm.h], [], AC_MSG_ERROR([libsvm required but libsvm/svm.h not found]), [ ])
134 AC_SEARCH_LIBS([svm_train], [svm], [], AC_MSG_ERROR([libsvm required]))
137 AC_SUBST([LIBSVM_LIBS])
139 dnl Check that snprintf actually works as it's meant to.
141 dnl Linux 'man snprintf' warns:
142 dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
143 dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
144 dnl size argument. Thus, the use of snprintf with early libc4 leads to
145 dnl serious security problems.
147 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C90
148 dnl implementations) return -1 when truncating so check that we get the
149 dnl ISO C90 semantics for the returned length when truncating. If we
150 dnl have a working snprintf but with non-ISO return semantics, handle
151 dnl that case separately as it may still be useful in many cases.
153 dnl mingw has _snprintf so check for that too.
154 AC_MSG_CHECKING([for working ISO C90 conforming snprintf])
155 ac_cv_func_snprintf_noniso=no
156 for func in snprintf _snprintf ; do
164 dnl Return different exit status for each error so we can see which
165 dnl check failed by consulting config.log.
167 char buffer[4] = "abc";
168 int res1 = $func(buffer, 2, "%s", "XYZ");
169 if (memcmp(buffer, "X\0c", 4) != 0) return 2;
170 int res2 = $func(buffer, 2, "%x", 0x12);
171 if (memcmp(buffer, "1\0c", 4) != 0) return 3;
172 if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
173 if (res1 != 3) return 4;
174 if (res2 != 2) return 5;
177 [ac_cv_func_snprintf=$func;break],
179 if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
180 ac_cv_func_snprintf_noniso=$func
182 ac_cv_func_snprintf=no
184 [ac_cv_func_snprintf=unknown;break]
187 AC_MSG_RESULT([$ac_cv_func_snprintf])
188 case $ac_cv_func_snprintf in
190 AC_MSG_CHECKING([for working non-ISO C90 conforming snprintf])
191 AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
192 if test no != "$ac_cv_func_snprintf_noniso" ; then
193 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
194 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
198 dnl be conservative when crosscompiling
201 AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
202 [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
203 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
204 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
208 dnl ******************************
209 dnl * Set special compiler flags *
210 dnl ******************************
212 dnl Set flags to control warnings (enable more, or disable annoying ones).
214 if test yes = "$GXX"; then
215 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
216 dnl we actually have, as neither is really 100% compatible.
217 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
218 *__INTEL_COMPILER*__clang__*)
219 dnl GCC (since neither substituted):
221 dnl -Wundef was supported by g++ 3.0.
223 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
226 dnl All the other options were supported by g++ 2.95.
227 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"
229 dnl The exact format of g++ --version seems to change with almost every
230 dnl minor release so use the preprocessor macros which should be more
232 AC_MSG_CHECKING([for version of $CXX])
233 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
234 AC_MSG_RESULT([GCC $gxx_version])
237 [[0123]].*|4.[[0123]].*)
238 AC_MSG_ERROR([Xapian requires GCC 4.4 or later])
242 dnl -Wdouble-promotion was added in GCC 4.6.
244 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
245 dnl warns for this case with -Wuninitialized (implied by -W). We
246 dnl don't intend to use this idiom, so any instances are bugs we'd
247 dnl like to know about.
248 AM_CXXFLAGS="$AM_CXXFLAGS -Wdouble-promotion -Winit-self" ;;
252 dnl -Wconversion in older GCC versions is intended to help migration
253 dnl from K&R to ISO C, and isn't useful for us. In 4.3 it was renamed
254 dnl to -Wtraditional-conversion and a new -Wconversion added which
255 dnl sounds useful but is a bit buggy currently. So we should consider
256 dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
258 dnl -Wold-style-cast is interesting, but triggers for macros from
259 dnl system headers (e.g. FD_SET) (tested with GCC 4.4).
261 dnl Automatically add -Werror if maintainer mode is enabled.
262 if test x$USE_MAINTAINER_MODE = xyes; then
263 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
267 dnl Intel's compiler (since __clang__ not substituted):
269 dnl -w1 stops the avalanche of uninteresting "remark" messages.
270 dnl -wd... disables warnings which don't have good code workarounds.
271 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
273 dnl Automatically add -Werror if maintainer mode is enabled.
274 if test x$USE_MAINTAINER_MODE = xyes; then
275 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
279 dnl clang (since __INTEL_COMPILER not substituted):
280 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -W -Wredundant-decls -Wpointer-arith -Wcast-qual -Wcast-align -Wformat-security -fno-gnu-keywords -Wundef -Woverloaded-virtual"
281 AM_CXXFLAGS="$AM_CXXFLAGS -Wshadow -Wstrict-overflow=1 -Winit-self -Wmissing-declarations"
283 dnl Automatically add -Werror if maintainer mode is enabled.
284 if test x$USE_MAINTAINER_MODE = xyes; then
285 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
290 if test no != "$enable_visibility"; then
291 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
293 AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
294 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
296 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
297 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
303 dnl Not GCC, nor a compiler masquerading as GCC.
306 dnl +w turns on more warnings.
307 dnl +wlint turns on "lint-like" warnings.
308 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
309 dnl 2340 (remark) "value copied to temporary, reference to temporary
310 dnl use", in: throw Xapian::UnimplementedError("...");
311 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
312 dnl virtual destructor for intrusive_base, since we never delete
313 dnl its subclasses by a intrusive_base *).
314 dnl 3348 "declaration hides constant ..." which seems to misfire!
315 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
316 dnl alignment boundary".
317 dnl 4273 "floating-point equality and inequality comparisons may be
318 dnl inappropriate due to roundoff common in floating-point computation"
319 dnl No obvious workaround for when you really do want == or !=.
320 dnl 4285 "operator= does not have a check for the source and destination
321 dnl addresses being non-identical" - fires for AutoPtr which
322 dnl includes such a check indirectly (internaltest's autoptr1 check this).
323 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
324 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
329 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
331 # pragma warning(disable:4800)
334 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
335 * shouldn't cause a problem to define it where it's not supported and some
336 * distros may have backported support, so hardcoding version checks is
337 * counter-productive.
339 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
340 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
342 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
343 # define _FORTIFY_SOURCE 2
346 /* For GCC >= 3.0 (and Intel's C++ compiler, which also defines __GNUC__),
347 * we can use __builtin_expect to give the compiler hints about branch
348 * prediction. See HACKING for how to use these.
351 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
352 * the first argument is always an integer expression, and always 0 or 1, but
353 * still has the same truth value for the if or while it is used in.
355 # define rare(COND) __builtin_expect(!!(COND), 0)
356 # define usual(COND) __builtin_expect(!!(COND), 1)
358 # define rare(COND) (COND)
359 # define usual(COND) (COND)
363 AC_SUBST([AM_CXXFLAGS])
365 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
366 CXXFLAGS=$save_CXXFLAGS
368 dnl Enable large file support if possible.
371 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
372 : ${AUTOM4TE=autom4te}
375 dnl We want to be able to use GNU make % pattern rules in maintainer targets
376 dnl but automake warns these aren't portable, so we substitute the % to avoid
381 dnl **************************
382 dnl * Build the output files *
383 dnl **************************
389 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])