-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
307 lines (254 loc) · 8.82 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT([sphinx], [0.9.8], [shodan(at)shodan.ru])
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([checking build environment])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_MAINTAINER_MODE
AC_CONFIG_SRCDIR([src/searchd.cpp])
AC_CONFIG_HEADER([config/config.h])
# hack to locate expat/iconv in /usr/local on BSD systems
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
LIBS="$LIBS -L/usr/local/lib"
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([checking for compiler programs])
AC_ARG_WITH([debug],
AC_HELP_STRING([--with-debug], [compile slower debug version (default is disabled)]),
[ac_cv_use_debug=$withval], [ac_cv_use_debug=no]
)
AC_MSG_CHECKING([whether to compile debug version])
if test x$ac_cv_use_debug != xno; then
SPHINX_CFLAGS="-Wall -g -D_FILE_OFFSET_BITS=64"
SPHINX_INJECT_FLAGS="-D_FILE_OFFSET_BITS=64"
AC_MSG_RESULT([yes])
else
SPHINX_CFLAGS="-Wall -g -D_FILE_OFFSET_BITS=64 -O3 -DNDEBUG"
SPHINX_INJECT_FLAGS="-D_FILE_OFFSET_BITS=64 -DNDEBUG"
AC_MSG_RESULT([no])
fi
dnl set flags for C compiler if there are no user overrides
dnl inject required defines if there are
if test x$ac_env_CFLAGS_set != xset; then
CFLAGS=$SPHINX_CFLAGS
else
CFLAGS="$CFLAGS $SPHINX_INJECT_FLAGS"
fi
dnl set flags for C++ compiler if there are no user overrides
dnl inject required defines if there are
if test x$ac_env_CXXFLAGS_set != xset; then
CXXFLAGS=$SPHINX_CFLAGS
else
CXXFLAGS="$CXXFLAGS $SPHINX_INJECT_FLAGS"
fi
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([checking for header files])
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
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])
AC_CHECK_HEADER(expat.h,[have_expat_h=yes],[have_expat_h=no])
AC_CHECK_HEADER(iconv.h,[have_iconv_h=yes],[have_iconv_h=no])
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([checking for types])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([checking for library functions])
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_VPRINTF
AC_SEARCH_LIBS([setsockopt],[socket])
AC_SEARCH_LIBS([gethostbyname],[nsl socket resolv])
AC_SEARCH_LIBS([XML_Parse],[expat],[have_libexpat=yes],[have_libexpat=no])
AC_SEARCH_LIBS([iconv],[iconv],[have_libiconv=yes],[have_libiconv=no])
AC_SEARCH_LIBS([logf],[m])
AC_CHECK_FUNCS([dup2 gethostbyname gettimeofday memmove memset select socket strcasecmp strchr strerror strncasecmp strstr strtol logf])
SPHINX_CHECK_DEFINE(LOCK_EX,sys/file.h)
SPHINX_CHECK_DEFINE(F_SETLKW,fcntl.h)
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([configuring Sphinx])
# check if we should compile with MySQL support
AC_ARG_WITH([mysql],
AC_HELP_STRING([--with-mysql], [compile with MySQL support (default is enabled)]),
[ac_cv_use_mysql=$withval], [ac_cv_use_mysql=yes]
)
AC_MSG_CHECKING([whether to compile with MySQL support])
if test x$ac_cv_use_mysql != xno; then
AC_MSG_RESULT([yes])
AC_CHECK_MYSQL([$ac_cv_use_mysql])
AC_DEFINE(USE_MYSQL,1,[Define to 1 if you want to compile with MySQL support])
AC_SUBST([MYSQL_LIBS])
AC_SUBST([MYSQL_CFLAGS])
else
AC_MSG_RESULT([no])
fi
AM_CONDITIONAL(USE_MYSQL, test x$ac_cv_use_mysql != xno)
# check if we should compile with PostgreSQL support
AC_ARG_WITH([pgsql],
AC_HELP_STRING([--with-pgsql], [compile with PostgreSQL support (default is disabled)]),
[ac_cv_use_pgsql=$withval], [ac_cv_use_pgsql=no]
)
AC_MSG_CHECKING([whether to compile with PostgreSQL support])
if test x$ac_cv_use_pgsql != xno; then
AC_MSG_RESULT([yes])
AC_CHECK_PGSQL([$ac_cv_use_pgsql])
AC_DEFINE(USE_PGSQL,1,[Define to 1 if you want to compile with PostgreSQL support])
AC_SUBST([PGSQL_LIBS])
AC_SUBST([PGSQL_CFLAGS])
else
AC_MSG_RESULT([no])
fi
AM_CONDITIONAL(USE_PGSQL, test x$ac_cv_use_pgsql != xno)
# we can now set preprocessor flags for both C and C++ compilers
CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS $PGSQL_CFLAGS"
dnl ---
AC_MSG_CHECKING([whether to use 64-bit document/word IDs])
sph_enable_id64=no
AC_ARG_ENABLE([id64],
[ --enable-id64 use 64-bit document and word IDs (default is no)],
[sph_enable_id64=$enableval])
if test x$sph_enable_id64 != xno; then
AC_DEFINE(USE_64BIT, 1, [64-bit document and word IDs])
AC_MSG_RESULT([yes])
else
AC_DEFINE(USE_64BIT, 0, [64-bit document and word IDs])
AC_MSG_RESULT([no])
fi
dnl ---
AC_ARG_WITH([libstemmer],
AC_HELP_STRING([--with-libstemmer], [compile with libstemmer support (default is disabled)]),
[ac_cv_use_libstemmer=$withval], [ac_cv_use_libstemmer=no]
)
AC_MSG_CHECKING([whether to compile with libstemmer support])
if test x$ac_cv_use_libstemmer != xno; then
if test -d libstemmer_c && test -f libstemmer_c/include/libstemmer.h; then
AC_MSG_RESULT([yes])
AC_DEFINE(USE_LIBSTEMMER, 1, [libstemmer support])
else
AC_MSG_ERROR([missing libstemmer sources from libstemmer_c.
Please download the C version of libstemmer library from
http://snowball.tartarus.org/ and extract its sources over libstemmer_c/
subdirectory in order to build Sphinx with libstemmer support.
])
fi
else
AC_MSG_RESULT([no])
AC_DEFINE(USE_LIBSTEMMER, 0, [libstemmer support])
fi
AM_CONDITIONAL(USE_LIBSTEMMER, test x$ac_cv_use_libstemmer != xno)
dnl ---
got_expat=0
AC_MSG_CHECKING([for libexpat])
if test [ $have_expat_h = yes -a $have_libexpat = yes ]; then
AC_DEFINE([USE_LIBEXPAT],1,[define to use expat XML library])
AC_MSG_RESULT([found])
got_expat=1
else
AC_MSG_RESULT([not found])
AC_MSG_WARN([xmlpipe2 will NOT be available])
fi
dnl ---
AC_ARG_WITH([iconv],
AC_HELP_STRING([--with-iconv], [compile with iconv support (default is autodetect)]),
[ac_cv_use_iconv=$withval], [ac_cv_use_iconv=yes]
)
AC_MSG_CHECKING([for libiconv])
if test [ $have_iconv_h = yes \
-a $have_libiconv = yes \
-a $got_expat -eq 1 \
-a $ac_cv_use_iconv != no ]; \
then
AC_DEFINE([USE_LIBICONV],1,[define to use iconv library])
AC_MSG_RESULT([found])
AC_MSG_CHECKING([for iconv() arg types])
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[
#include <iconv.h>
#include <stdio.h>]],
[const char * inbuf;
iconv_t cd;
iconv ( cd, &inbuf, NULL, NULL, NULL );
])],
[iconv_inbuf_const=yes],
[iconv_inbuf_const=no])
AC_LANG_POP([C++])
if test [ $iconv_inbuf_const = yes ]; then
AC_DEFINE([ICONV_INBUF_CONST],1,[whether 2nd arg to iconv() is const ptr])
AC_MSG_RESULT([const char **])
else
AC_DEFINE([ICONV_INBUF_CONST],0,[whether 2nd arg to iconv() is const ptr])
AC_MSG_RESULT([char **])
fi
else
if test [ $got_expat -eq 1 ]; then
if test [ $ac_cv_use_iconv = no ]; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([not found])
fi
AC_MSG_WARN([xmlpipe2 will only support default encodings (latin-1, utf-8)])
else
AC_MSG_RESULT([not required])
fi
fi
dnl ---
AC_MSG_CHECKING([for unaligned RAM access])
AC_LANG_PUSH([C++])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM([[
#include <stdlib.h>
#include <string.h>]],
[[char * sBuf = new char [ 8*sizeof(int) ];
for ( int i=0; i<8*sizeof(int); i++ )
sBuf[i] = i;
// check for crashes (SPARC)
volatile int iRes = 0;
for ( int i=0; i<(int)sizeof(int); i++ )
{
int * pPtr = (int*)( sBuf+i );
iRes += *pPtr;
}
// check for correct values (ARM)
iRes = *(int*)( sBuf+1 );
if (!( iRes==0x01020304 || iRes==0x04030201 ))
return 1;
// all seems ok
return 0;]])],
[AC_MSG_RESULT([yes])
AC_DEFINE([UNALIGNED_RAM_ACCESS],1,[whether unaligned RAM access is possible])],
[AC_MSG_RESULT([no])
AC_DEFINE([UNALIGNED_RAM_ACCESS],0)],
[AC_MSG_RESULT([unknown (cross-compiling), assume yes])
AC_DEFINE([UNALIGNED_RAM_ACCESS],1)])
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([generating configuration files])
if test "$prefix" = "NONE"; then
my_op_prefix="/var"
else
my_op_prefix="$localstatedir"
fi
CONFDIR=`eval echo "${my_op_prefix}"`
AC_SUBST(CONFDIR)
AC_CONFIG_FILES([Makefile src/Makefile libstemmer_c/Makefile sphinx.conf.dist:sphinx.conf.in \
sphinx-min.conf.dist:sphinx-min.conf.in])
AC_OUTPUT
dnl --------------------------------------------------------------------------
SPHINX_CONFIGURE_PART([configuration done])
echo You can now run \'make\' to build Sphinx binaries,
echo and then run \'make install\' to install them.
echo