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 AC_INIT([xapian-letor], [1.3.0], [http://xapian.org/bugs])
7 dnl Extract from the libtool info manual:
9 dnl Here are a set of rules to help you update your library version information:
11 dnl 1. Start with version information of '0:0:0' for each libtool library.
13 dnl 2. Update the version information only immediately before a public
14 dnl release of your software. More frequent updates are unnecessary,
15 dnl and only guarantee that the current interface number gets larger
18 dnl 3. If the library source code has changed at all since the last
19 dnl update, then increment REVISION ('C:R:A' becomes 'C:r+1:A').
21 dnl 4. If any interfaces have been added, removed, or changed since the
22 dnl last update, increment CURRENT, and set REVISION to 0.
24 dnl 5. If any interfaces have been added since the last public release,
25 dnl then increment AGE.
27 dnl 6. If any interfaces have been removed since the last public release
28 dnl then set AGE to 0.
30 dnl LIBRARY_VERSION_INFO for libxapianletor:
31 dnl 0:0:0 1.3.1 First release with xapian-letor split out from xapian-core
32 LIBRARY_VERSION_INFO=0:0:0
33 AC_SUBST(LIBRARY_VERSION_INFO)
35 AM_INIT_AUTOMAKE([1.10.1 -Wportability tar-ustar])
37 AC_CONFIG_SRCDIR([letor.cc])
39 AC_CONFIG_HEADERS([config.h])
41 AC_CONFIG_MACRO_DIR([m4])
46 dnl disable "maintainer only" rules by default
49 dnl Checks for programs.
54 # Checked: freebsd8.0 openbsd4.6 solaris2.9 solaris2.10
56 linux* | k*bsd*-gnu | freebsd* | openbsd* | solaris*)
57 dnl Vanilla libtool sets this to "unknown" which it then handles as "yes".
58 link_all_deplibs_CXX=no
64 dnl Extract search path from ldconfig which is more reliable than the way
65 dnl vanilla libtool extracts them from ld.so.conf.
66 d=`/sbin/ldconfig -N -X -v 2>&AS_MESSAGE_LOG_FD|$SED 's,^\(/.*\):\( (.*)\)\?$,\1,p;d'|tr '\n' ' '`
67 test -z "$d" || sys_lib_dlsearch_path_spec=$d
71 dnl Probe for any options needed to enable C++11 support.
72 AX_CXX_COMPILE_STDCXX_11
74 dnl Run tests using the C++ compiler.
77 dnl Check for xapian-core.
78 XO_LIB_XAPIAN([], [], [xapian-config])
80 dnl We want XAPIAN_CXXFLAGS to be used for configure tests.
81 save_CXXFLAGS=$CXXFLAGS
82 CXXFLAGS="$CXXFLAGS $XAPIAN_CXXFLAGS"
83 dnl mingw (for instance) lacks ssize_t
90 dnl Check for perl (needed to generate some sources and documentation).
91 AC_PATH_PROG([PERL], [perl], [])
92 if test x$USE_MAINTAINER_MODE = xyes; then
93 test -z "$PERL" && AC_MSG_ERROR([perl is required in maintainer mode])
96 AC_ARG_ENABLE([documentation],
97 [AS_HELP_STRING([--enable-documentation], [enable make rules to rebuild documentation [default=maintainer-mode]])],
100 *) AC_MSG_ERROR([bad value ${enableval} for --enable-documentation]) ;;
102 [enable_documentation=$USE_MAINTAINER_MODE])
103 AM_CONDITIONAL([DOCUMENTATION_RULES], [test x"$enable_documentation" = xyes])
104 AM_CONDITIONAL([MAINTAINER_NO_DOCS], [test x"$USE_MAINTAINER_MODE$enable_documentation" = xyesno])
106 if test x"$enable_documentation" = xyes ; then
107 dnl Check for help2man. (Needed to make man pages from "--help" output).
108 AC_PATH_PROG([HELP2MAN], [help2man], [])
109 test -z "$HELP2MAN" && AC_MSG_ERROR([help2man is required to build documentation])
111 dnl Check for rst2html. (Needed to make HTML from reStructuredText format)
112 dnl Also look for rst2html.py, which archlinux reportedly installs it as.
113 AC_PATH_PROGS([RST2HTML], [rst2html rst2html.py], [])
114 test -z "$RST2HTML" && AC_MSG_ERROR([rst2html is required to build documentation (try package python-docutils)])
117 dnl Checks for header files.
118 AC_CHECK_HEADERS([fcntl.h limits.h sys/errno.h sys/select.h], [], [], [ ])
120 dnl libsvm is required.
121 AC_CHECK_HEADER([libsvm/svm.h], [], AC_MSG_ERROR([libsvm required but libsvm/svm.h not found]), [ ])
124 AC_SEARCH_LIBS([svm_train], [svm], [], AC_MSG_ERROR([libsvm required]))
127 AC_SUBST([LIBSVM_LIBS])
129 dnl Check that snprintf actually works as it's meant to.
131 dnl Linux 'man snprintf' warns:
132 dnl Linux libc4.[45] does not have a snprintf, but provides a libbsd that
133 dnl contains an snprintf equivalent to sprintf, i.e., one that ignores the
134 dnl size argument. Thus, the use of snprintf with early libc4 leads to
135 dnl serious security problems.
137 dnl It also warns that glibc < 2.0.6 (and presumably other pre-C90
138 dnl implementations) return -1 when truncating so check that we get the
139 dnl ISO C90 semantics for the returned length when truncating. If we
140 dnl have a working snprintf but with non-ISO return semantics, handle
141 dnl that case separately as it may still be useful in many cases.
143 dnl mingw has _snprintf so check for that too.
144 AC_MSG_CHECKING([for working ISO C90 conforming snprintf])
145 ac_cv_func_snprintf_noniso=no
146 for func in snprintf _snprintf ; do
154 dnl Return different exit status for each error so we can see which
155 dnl check failed by consulting config.log.
157 char buffer[4] = "abc";
158 int res1 = $func(buffer, 2, "%s", "XYZ");
159 if (memcmp(buffer, "X\0c", 4) != 0) return 2;
160 int res2 = $func(buffer, 2, "%x", 0x12);
161 if (memcmp(buffer, "1\0c", 4) != 0) return 3;
162 if (res1 == -1 && res2 == -1) return 15; /* Pre-ISO semantics. */
163 if (res1 != 3) return 4;
164 if (res2 != 2) return 5;
167 [ac_cv_func_snprintf=$func;break],
169 if test 15no = "$?$ac_cv_func_snprintf_noniso" ; then
170 ac_cv_func_snprintf_noniso=$func
172 ac_cv_func_snprintf=no
174 [ac_cv_func_snprintf=unknown;break]
177 AC_MSG_RESULT([$ac_cv_func_snprintf])
178 case $ac_cv_func_snprintf in
180 AC_MSG_CHECKING([for working non-ISO C90 conforming snprintf])
181 AC_MSG_RESULT([$ac_cv_func_snprintf_noniso])
182 if test no != "$ac_cv_func_snprintf_noniso" ; then
183 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf_noniso],
184 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
188 dnl be conservative when crosscompiling
191 AC_DEFINE_UNQUOTED([SNPRINTF_ISO], [$ac_cv_func_snprintf],
192 [Define to the name of a function implementing snprintf with ISO C99 semantics (if one exists)])
193 AC_DEFINE_UNQUOTED([SNPRINTF], [$ac_cv_func_snprintf],
194 [Define to the name of a function implementing snprintf but not caring about ISO C99 return value semantics (if one exists)])
198 dnl ******************************
199 dnl * Set special compiler flags *
200 dnl ******************************
202 dnl Set flags to control warnings (enable more, or disable annoying ones).
204 if test yes = "$GXX"; then
205 dnl Intel's C++ compiler and clang both lie and define __GNUC__, so check which
206 dnl we actually have, as neither is really 100% compatible.
207 case `echo __INTEL_COMPILER __clang__|$CXX -E - 2>&AS_MESSAGE_LOG_FD|grep -v '^#'` in
208 *__INTEL_COMPILER*__clang__*)
209 dnl GCC (since neither substituted):
211 dnl -Wundef was supported by g++ 3.0 and -fshow-column by g++ 3.1.
213 dnl -Wlogical-op and -Wmissing-declarations (for C++) were added in
216 dnl All the other options were supported by g++ 2.95.
217 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"
219 dnl The exact format of g++ --version seems to change with almost every
220 dnl minor release so use the preprocessor macros which should be more
222 AC_MSG_CHECKING([for version of $CXX])
223 gxx_version=`echo __GNUC__.__GNUC_MINOR__.__GNUC_PATCHLEVEL__|$CXX -E -|sed '/^#/d;s/ //g'`
224 AC_MSG_RESULT([GCC $gxx_version])
227 [[0123]].*|4.[[0123]].*)
228 AC_MSG_ERROR([Xapian requires GCC 4.4 or later])
232 dnl -Wdouble-promotion was added in GCC 4.6.
234 dnl -Winit-self was added in GCC 3.4, but for GCC < 4.7 g++ always
235 dnl warns for this case with -Wuninitialized (implied by -W). We
236 dnl don't intend to use this idiom, so any instances are bugs we'd
237 dnl like to know about.
238 AM_CXXFLAGS="$AM_CXXFLAGS -Wdouble-promotion -Winit-self" ;;
242 dnl -Wconversion in older GCC versions is intended to help migration
243 dnl from K&R to ISO C, and isn't useful for us. In 4.3 it was renamed
244 dnl to -Wtraditional-conversion and a new -Wconversion added which
245 dnl sounds useful but is a bit buggy currently. So we should consider
246 dnl enabling -Wconversion once it is stabilised (GCC 4.4 or ...)
248 dnl -Wold-style-cast is interesting, but triggers for macros from
249 dnl system headers (e.g. FD_SET) (tested with GCC 4.4).
251 dnl Automatically add -Werror if maintainer mode is enabled.
252 if test x$USE_MAINTAINER_MODE = xyes; then
253 AM_CXXFLAGS="$AM_CXXFLAGS -Werror"
257 dnl Intel's compiler (since __clang__ not substituted):
259 dnl -w1 stops the avalanche of uninteresting "remark" messages.
260 dnl -wd... disables warnings which don't have good code workarounds.
261 AM_CXXFLAGS="$AM_CXXFLAGS -Wall -w1 -wd177,1572"
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 clang (since __INTEL_COMPILER not substituted):
270 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"
271 AM_CXXFLAGS="$AM_CXXFLAGS -Wshadow -Wstrict-overflow=1 -Winit-self -Wmissing-declarations"
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"
280 if test no != "$enable_visibility"; then
281 dnl GCC doesn't support symbol visibility on all platforms (e.g. it isn't
283 AC_MSG_CHECKING([if $CXX -fvisibility=hidden works])
284 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
286 AM_CXXFLAGS="$AM_CXXFLAGS -fvisibility=hidden"
287 dash_d_visibility=-DXAPIAN_ENABLE_VISIBILITY
293 dnl Not GCC, nor a compiler masquerading as GCC.
296 dnl +w turns on more warnings.
297 dnl +wlint turns on "lint-like" warnings.
298 dnl +W<n1>,<n2>,... suppresses warnings n1, n2, ...
299 dnl 2340 (remark) "value copied to temporary, reference to temporary
300 dnl use", in: throw Xapian::UnimplementedError("...");
301 dnl 2401 "destructor for base class ... is non-virtual" (we don't need a
302 dnl virtual destructor for intrusive_base, since we never delete
303 dnl its subclasses by a intrusive_base *).
304 dnl 3348 "declaration hides constant ..." which seems to misfire!
305 dnl 4255 (remark) "padding size of struct "..." with ... bytes to
306 dnl alignment boundary".
307 dnl 4273 "floating-point equality and inequality comparisons may be
308 dnl inappropriate due to roundoff common in floating-point computation"
309 dnl No obvious workaround for when you really do want == or !=.
310 dnl 4285 "operator= does not have a check for the source and destination
311 dnl addresses being non-identical" - fires for AutoPtr which
312 dnl includes such a check indirectly (internaltest's autoptr1 check this).
313 dnl 20201 "Memory leak is detected" which triggers for "return new Foo;"!
314 AM_CXXFLAGS="$AM_CXXFLAGS +w +wlint +W2340,2401,3348,4255,4273,4285,20201" ;;
319 [/* Disable stupid MSVC "performance" warning for converting int to bool. */
321 # pragma warning(disable:4800)
324 /* _FORTIFY_SOURCE is only supported by GCC >= 4.1 and glibc >= 2.3.4, but it
325 * shouldn't cause a problem to define it where it's not supported and some
326 * distros may have backported support, so hardcoding version checks is
327 * counter-productive.
329 * Check if _FORTIFY_SOURCE is already defined to allow the user to override
330 * our choice with "./configure CPPFLAGS=-D_FORTIFY_SOURCE=0" or "...=1".
332 #if defined __GNUC__ && !defined _FORTIFY_SOURCE
333 # define _FORTIFY_SOURCE 2
336 /* For GCC >= 3.0 (and Intel's C++ compiler, which also defines __GNUC__),
337 * we can use __builtin_expect to give the compiler hints about branch
338 * prediction. See HACKING for how to use these.
341 /* The arguments of __builtin_expect() are both long, so use !! to ensure that
342 * the first argument is always an integer expression, and always 0 or 1, but
343 * still has the same truth value for the if or while it is used in.
345 # define rare(COND) __builtin_expect(!!(COND), 0)
346 # define usual(COND) __builtin_expect(!!(COND), 1)
348 # define rare(COND) (COND)
349 # define usual(COND) (COND)
353 AC_SUBST([AM_CXXFLAGS])
355 dnl Restore CXXFLAGS to those the user specified or autoconf defaulted to.
356 CXXFLAGS=$save_CXXFLAGS
358 dnl Enable large file support if possible.
361 dnl Required for auto regeneration to work in a combined maintainer-mode tree.
362 : ${AUTOM4TE=autom4te}
365 dnl We want to be able to use GNU make % pattern rules in maintainer targets
366 dnl but automake warns these aren't portable, so we substitute the % to avoid
371 dnl **************************
372 dnl * Build the output files *
373 dnl **************************
379 AC_CONFIG_FILES([makemanpage], [chmod +x makemanpage])