1
dnl Process this file with autoconf to produce a configure script.
4
AC_INIT([sphinx], [2.0.4], [shodan(at)sphinxsearch.com])
6
dnl --------------------------------------------------------------------------
8
SPHINX_CONFIGURE_PART([checking build environment])
10
AC_CONFIG_AUX_DIR([config])
11
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
13
AC_CONFIG_SRCDIR([src/searchd.cpp])
14
AC_CONFIG_HEADER([config/config.h])
16
# hack to locate expat/iconv in /usr/local on BSD systems
17
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
18
LIBS="$LIBS -L/usr/local/lib"
20
dnl --------------------------------------------------------------------------
22
SPHINX_CONFIGURE_PART([checking for compiler programs])
25
AC_HELP_STRING([--with-debug], [compile slower debug version (default is disabled)]),
26
[ac_cv_use_debug=$withval], [ac_cv_use_debug=no]
29
AC_MSG_CHECKING([whether to compile debug version])
30
if test x$ac_cv_use_debug != xno; then
31
SPHINX_CFLAGS="-Wall -g -D_FILE_OFFSET_BITS=64"
32
SPHINX_INJECT_FLAGS="-D_FILE_OFFSET_BITS=64"
35
SPHINX_CFLAGS="-Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG"
36
SPHINX_INJECT_FLAGS="-D_FILE_OFFSET_BITS=64 -DNDEBUG"
40
dnl set flags for C compiler if there are no user overrides
41
dnl inject required defines if there are
42
if test x$ac_env_CFLAGS_set != xset; then
45
CFLAGS="$CFLAGS $SPHINX_INJECT_FLAGS"
48
dnl set flags for C++ compiler if there are no user overrides
49
dnl inject required defines if there are
50
if test x$ac_env_CXXFLAGS_set != xset; then
51
CXXFLAGS=$SPHINX_CFLAGS
53
CXXFLAGS="$CXXFLAGS $SPHINX_INJECT_FLAGS"
62
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
68
], [], [AC_MSG_ERROR([Gcc version error. Minspec is 3.4])])
70
AC_DEFINE_UNQUOTED([COMPILER],"$CC `$CC -dumpversion`",[Define to be the name of the compiler.])
71
AC_DEFINE_UNQUOTED([OS_UNAME],"`uname -a`",[Full name OS])
73
dnl --------------------------------------------------------------------------
75
SPHINX_CONFIGURE_PART([checking for header files])
77
# Checks for header files.
80
AC_CHECK_HEADERS([fcntl.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/file.h sys/socket.h sys/time.h unistd.h pthread.h execinfo.h])
81
AC_CHECK_HEADER(expat.h,[have_expat_h=yes],[have_expat_h=no])
82
AC_CHECK_HEADER(iconv.h,[have_iconv_h=yes],[have_iconv_h=no])
83
AC_CHECK_HEADER(zlib.h,[have_zlib_h=yes],[have_zlib_h=no])
84
AC_CHECK_HEADER(sql.h,[have_sql_h=yes],[have_sql_h=no])
85
AC_CHECK_HEADER(syslog.h,[have_syslog_h=yes],[have_syslog_h=no])
87
dnl --------------------------------------------------------------------------
89
SPHINX_CONFIGURE_PART([checking for types])
91
# Checks for typedefs, structures, and compiler characteristics.
99
dnl --------------------------------------------------------------------------
101
SPHINX_CONFIGURE_PART([checking for library functions])
103
# Checks for library functions.
107
AC_FUNC_SELECT_ARGTYPES
111
AC_SEARCH_LIBS([setsockopt],[socket])
112
AC_SEARCH_LIBS([gethostbyname],[nsl socket resolv])
113
AC_SEARCH_LIBS([XML_Parse],[expat],[have_libexpat=yes],[have_libexpat=no])
114
AC_SEARCH_LIBS([iconv],[iconv],[have_libiconv=yes],[have_libiconv=no])
115
AC_SEARCH_LIBS([inflate],[z],[have_lz=yes],[have_lz=no])
116
AC_SEARCH_LIBS([logf],[m])
117
AC_CHECK_FUNCS([dup2 gethostbyname gettimeofday memmove memset select socket strcasecmp strchr strerror strncasecmp strstr strtol logf pread])
118
AC_CHECK_FUNCS([backtrace backtrace_symbols])
120
# most systems require the program be linked with librt library to use
121
# the function clock_gettime
124
AC_CHECK_LIB(rt,clock_gettime)
131
AC_CHECK_FUNCS(clock_gettime)
133
SPHINX_CHECK_DEFINE(LOCK_EX,sys/file.h)
134
SPHINX_CHECK_DEFINE(F_SETLKW,fcntl.h)
137
# FIXME! technically, only needed in searchd
138
# but as UDF manager is curently in libsphinx, we link everything
139
AC_CHECK_LIB(dl,dlopen)
140
AC_CHECK_FUNCS(dlopen dlerror)
142
dnl --------------------------------------------------------------------------
144
SPHINX_CONFIGURE_PART([configuring Sphinx])
150
dnl helper that runs a test program and checks for success
155
void * thread_routine ( void * data )
163
pthread_mutexattr_t mattr;
164
pthread_once_t once_init = PTHREAD_ONCE_INIT;
167
pthread_mutexattr_init ( &mattr );
168
return pthread_create ( &thd, NULL, thread_routine, &data );
172
AC_DEFUN([PTHREADS_TRY_RUNCOMPILE],[
173
if test x$cross_compiling = xno ; then
174
AC_TRY_RUN($pthread_prog, [pthreads_try_run=yes], [pthreads_try_run=no], [pthreads_try_run=no])
175
if test x$pthreads_try_run = xyes ; then
179
AC_COMPILE_IFELSE($pthread_prog, [pthreads_try_compile=yes], [pthreads_try_compile=no], [pthreads_try_compile=no])
180
if test x$pthreads_try_compile = xyes ; then
187
AC_DEFUN([PTHREADS_TRY_RUNLINK],[
188
if test x$cross_compiling = xno ; then
189
AC_TRY_RUN($pthread_prog, [pthreads_try_run=yes], [pthreads_try_run=no], [pthreads_try_run=no])
190
if test x$pthreads_try_run = xyes ; then
194
AC_LINK_IFELSE($pthread_prog, [pthreads_try_link=yes], [pthreads_try_link=no], [pthreads_try_link=no])
195
if test x$pthreads_try_link = xyes ; then
201
# check for needed cflags
202
AC_CACHE_CHECK([for CFLAGS needed for pthreads], [sphinx_cv_pthreads_cflags],
205
for flag in none -kthread -pthread -pthreads -mt -mthreads -Kthread -threads; do
207
test "x$flag" != "xnone" && CFLAGS="$CFLAGS $flag"
208
PTHREADS_TRY_RUNCOMPILE([
209
sphinx_cv_pthreads_cflags="$flag"
216
if test -n "$sphinx_cv_pthreads_cflags"; then
218
if test "x$sphinx_cv_pthreads_cflags" != "xnone"; then
219
CPPFLAGS="$CPPFLAGS $sphinx_cv_pthreads_cflags"
223
# check for needed libs
224
AC_CACHE_CHECK([for LIBS needed for pthreads], [sphinx_cv_pthreads_libs], [
226
for lib in -lpthread -lpthreads -lc_r; do
227
LIBS="$save_libs $lib"
228
PTHREADS_TRY_RUNLINK([
229
sphinx_cv_pthreads_libs=$lib
236
if test -n "$sphinx_cv_pthreads_libs"; then
238
LIBS="$LIBS $sphinx_cv_pthreads_libs"
242
AC_MSG_CHECKING([for pthreads])
243
if test x$have_pthreads = xyes; then
244
if test x$cross_compiling = xno; then
245
AC_MSG_RESULT([found])
247
AC_MSG_RESULT([assumed as found (cross-compiling)])
250
AC_MSG_ERROR([no working pthreads library found])
253
AC_CHECK_FUNCS([pthread_mutex_timedlock])
257
# check if we should compile with MySQL support
259
AC_HELP_STRING([--with-mysql], [compile with MySQL support (default is enabled)]),
260
[ac_cv_use_mysql=$withval], [ac_cv_use_mysql=yes]
262
AC_MSG_CHECKING([whether to compile with MySQL support])
263
if test x$ac_cv_use_mysql != xno; then
265
AC_CHECK_MYSQL([$ac_cv_use_mysql])
266
AC_DEFINE(USE_MYSQL,1,[Define to 1 if you want to compile with MySQL support])
267
AC_SUBST([MYSQL_LIBS])
268
AC_SUBST([MYSQL_CFLAGS])
272
AM_CONDITIONAL(USE_MYSQL, test x$ac_cv_use_mysql != xno)
274
# check if we should statically link the mysql library
275
AC_ARG_WITH([static-mysql],
276
AC_HELP_STRING([--with-static-mysql], [link statically with MySQL library (default is no)]),
277
[ac_cv_use_static_mysql=$withval], [ac_cv_use_static_mysql=no]
279
AC_MSG_CHECKING([whether to link statically with MySQL support])
280
if test x$ac_cv_use_mysql != xno; then
281
if test x$ac_cv_use_static_mysql != xno; then
282
AC_CHECK_MYSQL([$ac_cv_use_static_mysql])
283
MYSQL_LIBS=`echo $MYSQL_LIBS | sed -e 's/\-Bdynamic/\-Bstatic/g'`
284
MYSQL_LIBS="-Wl,-Bstatic $MYSQL_LIBS -Wl,-Bdynamic"
291
# check if we should compile with PostgreSQL support
293
AC_HELP_STRING([--with-pgsql], [compile with PostgreSQL support (default is disabled)]),
294
[ac_cv_use_pgsql=$withval], [ac_cv_use_pgsql=no]
296
AC_MSG_CHECKING([whether to compile with PostgreSQL support])
297
if test x$ac_cv_use_pgsql != xno; then
299
AC_CHECK_PGSQL([$ac_cv_use_pgsql])
300
AC_DEFINE(USE_PGSQL,1,[Define to 1 if you want to compile with PostgreSQL support])
301
AC_SUBST([PGSQL_LIBS])
302
AC_SUBST([PGSQL_CFLAGS])
306
AM_CONDITIONAL(USE_PGSQL, test x$ac_cv_use_pgsql != xno)
308
# add macports include directory
309
if (echo $MYSQL_LIBS | grep -q -- -L/opt/local/lib); then
310
MYSQL_CFLAGS="$MYSQL_CFLAGS -I/opt/local/include"
313
# we can now set preprocessor flags for both C and C++ compilers
314
CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS $PGSQL_CFLAGS"
318
AC_MSG_CHECKING([whether to use 64-bit document/word IDs])
320
AC_ARG_ENABLE([id64],
321
[ --enable-id64 use 64-bit document and word IDs (default is no)],
322
[sph_enable_id64=$enableval])
323
if test x$sph_enable_id64 != xno; then
324
AC_DEFINE(USE_64BIT, 1, [64-bit document and word IDs])
327
AC_DEFINE(USE_64BIT, 0, [64-bit document and word IDs])
333
AC_ARG_WITH([libstemmer],
334
AC_HELP_STRING([--with-libstemmer], [compile with libstemmer support (default is disabled)]),
335
[ac_cv_use_libstemmer=$withval], [ac_cv_use_libstemmer=no]
338
AC_MSG_CHECKING([whether to compile with libstemmer support])
339
if test x$ac_cv_use_libstemmer != xno; then
340
if test -d libstemmer_c && test -f libstemmer_c/include/libstemmer.h; then
342
AC_DEFINE(USE_LIBSTEMMER, 1, [libstemmer support])
344
AC_MSG_ERROR([missing libstemmer sources from libstemmer_c.
346
Please download the C version of libstemmer library from
347
http://snowball.tartarus.org/ and extract its sources over libstemmer_c/
348
subdirectory in order to build Sphinx with libstemmer support.
353
AC_DEFINE(USE_LIBSTEMMER, 0, [libstemmer support])
355
AM_CONDITIONAL(USE_LIBSTEMMER, test x$ac_cv_use_libstemmer != xno)
360
AC_MSG_CHECKING([for libexpat])
361
if test [ $have_expat_h = yes -a $have_libexpat = yes ]; then
362
AC_DEFINE([USE_LIBEXPAT],1,[define to use expat XML library])
363
AC_MSG_RESULT([found])
366
AC_MSG_RESULT([not found])
367
AC_MSG_WARN([xmlpipe2 will NOT be available])
373
AC_HELP_STRING([--with-iconv], [compile with iconv support (default is autodetect)]),
374
[ac_cv_use_iconv=$withval], [ac_cv_use_iconv=yes]
376
AC_MSG_CHECKING([for libiconv])
377
if test [ $have_iconv_h = yes \
378
-a $have_libiconv = yes \
379
-a $got_expat -eq 1 \
380
-a $ac_cv_use_iconv != no ]; \
382
AC_DEFINE([USE_LIBICONV],1,[define to use iconv library])
383
AC_MSG_RESULT([found])
385
AC_MSG_CHECKING([for iconv() arg types])
390
#include <stdio.h>]],
393
iconv ( cd, &inbuf, NULL, NULL, NULL );
395
[iconv_inbuf_const=yes],
396
[iconv_inbuf_const=no])
398
if test [ $iconv_inbuf_const = yes ]; then
399
AC_DEFINE([ICONV_INBUF_CONST],1,[whether 2nd arg to iconv() is const ptr])
400
AC_MSG_RESULT([const char **])
402
AC_DEFINE([ICONV_INBUF_CONST],0,[whether 2nd arg to iconv() is const ptr])
403
AC_MSG_RESULT([char **])
406
if test [ $got_expat -eq 1 ]; then
407
if test [ $ac_cv_use_iconv = no ]; then
408
AC_MSG_RESULT([disabled])
410
AC_MSG_RESULT([not found])
412
AC_MSG_WARN([xmlpipe2 will only support default encodings (latin-1, utf-8)])
414
AC_MSG_RESULT([not required])
420
if test [ $have_zlib_h = yes -a $have_lz = yes ]; then
421
AC_DEFINE([USE_ZLIB],1,[define to use Zlib])
426
AC_ARG_WITH([unixodbc],
427
AC_HELP_STRING([--with-unixodbc], [compile with UnixODBC support (default is autodetect)]),
428
[ac_cv_use_unixodbc=$withval], [ac_cv_use_unixodbc=yes]
430
AC_MSG_CHECKING([for UnixODBC])
431
if test [ $ac_cv_use_unixodbc != no ]; then
432
if test [ $have_sql_h = yes ]; then
433
AC_SEARCH_LIBS([SQLConnect],[odbc iodbc],[have_libodbc=yes],[have_libodbc=no])
434
if test [ $have_libodbc = yes ]; then
435
AC_DEFINE([USE_ODBC],1,[define to use ODBC library])
436
AC_MSG_RESULT([found])
438
AC_MSG_RESULT([not found])
439
AC_MSG_WARN([ODBC source support will NOT be available])
443
AC_MSG_RESULT([disabled])
449
AC_ARG_WITH([syslog],
450
AC_HELP_STRING([--with-syslog], [compile with possibility to use syslog for logging (default is no)]),
451
[ac_cv_use_syslog=$withval], [ac_cv_use_syslog=no]
453
AC_MSG_CHECKING([for Syslog])
454
if test [ $ac_cv_use_syslog != no ]; then
455
if test [ $have_syslog_h = yes ]; then
456
AC_DEFINE([USE_SYSLOG],1,[define to use POSIX Syslog for logging])
462
AC_MSG_RESULT([disabled])
467
AC_CACHE_CHECK([for unaligned RAM access],[sphinx_cv_unaligned_ram_access],[
472
#include <string.h>]],
473
[[char * sBuf = new char [ 8*sizeof(int) ];
474
for ( int i=0; i<8*sizeof(int); i++ )
477
// check for crashes (SPARC)
478
volatile int iRes = 0;
479
for ( int i=0; i<(int)sizeof(int); i++ )
481
int * pPtr = (int*)( sBuf+i );
485
// check for correct values (ARM)
486
iRes = *(int*)( sBuf+1 );
487
if (!( iRes==0x01020304 || iRes==0x04030201 ))
491
[sphinx_cv_unaligned_ram_access=yes],
492
[sphinx_cv_unaligned_ram_access=no],
493
[AC_MSG_RESULT([unknown (cross-compiling), assume no])
494
sphinx_cv_unaligned_ram_access=no])
497
if test x$sphinx_cv_unaligned_ram_access = xyes ; then
498
AC_DEFINE([UNALIGNED_RAM_ACCESS],1,[whether unaligned RAM access is possible])
500
AC_DEFINE([UNALIGNED_RAM_ACCESS],0)
505
AC_DEFINE(USE_LITTLE_ENDIAN, 0, [big-endian]),
506
AC_DEFINE(USE_LITTLE_ENDIAN, 1, [little-endian]),
507
AC_MSG_ERROR(unknown endianess not supported),
508
AC_MSG_ERROR(universial endianess not supported)
511
dnl --------------------------------------------------------------------------
513
SPHINX_CONFIGURE_PART([generating configuration files])
515
if test "$prefix" = "NONE"; then
518
my_op_prefix="$localstatedir"
522
CONFDIR=`eval echo "${my_op_prefix}"`
525
AC_CONFIG_FILES([Makefile src/Makefile libstemmer_c/Makefile doc/Makefile sphinx.conf.dist:sphinx.conf.in \
526
sphinx-min.conf.dist:sphinx-min.conf.in])
529
dnl --------------------------------------------------------------------------
531
SPHINX_CONFIGURE_PART([configuration done])
533
echo "You can now run 'make install' to build and install Sphinx binaries."
534
echo "On a multi-core machine, try 'make -j4 install' to speed up the build."
536
echo "Updates, articles, help forum, and commercial support, consulting, training,"
537
echo "and development services are available at http://sphinxsearch.com/"
539
echo "Thank you for choosing Sphinx!"