forked from groonga/groonga
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
446 lines (404 loc) · 12.6 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
AC_INIT([groonga],0.0.8,[[email protected]])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_C_BIGENDIAN
AC_PROG_CC
AM_PROG_CC_C_O
AC_DEFUN([CHECK_CFLAG], [
old_CFLAGS=$CFLAGS
CFLAGS="$CFLAGS $1 -Werror"
AC_COMPILE_IFELSE([[
#include <stdio.h>
int main(int argc, char **argv)
{
printf("test cflags, argc:%d argv[0]:%s", argc, argv[0]);
return 0;
}
]],
[check_cflag=yes],
[check_cflag=no])
CFLAGS="$old_CFLAGS"
if test "x$check_cflag" = "xyes"; then
CFLAGS="$CFLAGS $1"
fi
])
if test "$GCC" = "yes"; then
CHECK_CFLAG([-Wall])
CHECK_CFLAG([-Wextra])
if test "x$check_cflag" = "xno"; then
CHECK_CFLAG([-W])
fi
CHECK_CFLAG([-Wno-unused-parameter])
CHECK_CFLAG([-Wno-sign-compare])
CHECK_CFLAG([-Wno-pointer-sign])
CHECK_CFLAG([-Wno-missing-field-initializers])
CHECK_CFLAG([-Wformat=2])
CHECK_CFLAG([-Wstrict-aliasing=2])
CHECK_CFLAG([-Wdisabled-optimization])
CHECK_CFLAG([-Wfloat-equal])
CHECK_CFLAG([-Wpointer-arith])
CHECK_CFLAG([-Wdeclaration-after-statement])
CHECK_CFLAG([-Wbad-function-cast])
CHECK_CFLAG([-Wcast-align])
CHECK_CFLAG([-Wredundant-decls])
# CHECK_CFLAG([-Wunsafe-loop-optimizations])
# CHECK_CFLAG([-Wunreachable-code])
# CHECK_CFLAG([-Wswitch-enum])
# CHECK_CFLAG([-Wshadow])
# CHECK_CFLAG([-Wconversion])
# CHECK_CFLAG([-Wwrite-strings])
# CHECK_CFLAG([-Winline])
fi
AM_PROG_LIBTOOL
AC_CONFIG_FILES([Makefile
src/Makefile
lib/Makefile
examples/Makefile
test/Makefile
test/unit/Makefile
test/unit/lib/Makefile
test/unit/fixtures/Makefile
test/unit/fixtures/inverted-index/Makefile
test/unit/fixtures/stress/Makefile
test/unit/fixtures/performance/Makefile
test/unit/util/Makefile
test/unit/core/Makefile
test/unit/memcached/Makefile
test/ql/Makefile
test/benchmark/Makefile
test/benchmark/lib/Makefile
])
AC_CHECK_HEADERS(sys/mman.h sys/time.h sys/param.h sys/types.h pthread.h sys/resource.h)
AC_CHECK_HEADERS(netdb.h sys/wait.h sys/socket.h netinet/in.h netinet/tcp.h)
AC_CHECK_HEADERS(ucontext.h signal.h errno.h execinfo.h)
AC_CHECK_FUNCS(localtime_r)
AC_SYS_LARGEFILE
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(off_t)
AC_MSG_CHECKING([for fpclassify])
AC_COMPILE_IFELSE([[
#define _ISOC99_SOURCE
#include <math.h>
int main(int argc, char **argv)
{
return fpclassify (0.0);
}
]],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FPCLASSIFY, [1], [use fpclassify])
],
[
AC_MSG_RESULT(no)
])
# will deprecated
AC_ARG_WITH(groongahome,
[AC_HELP_STRING([--with-groongahome=DIR],
[specify Groonga home directory])],
GROONGA_HOME="$withval",
GROONGA_HOME="${prefix}/lib/$PACKAGE_NAME/$PACKAGE_VERSION")
AC_DEFINE_UNQUOTED(GROONGA_HOME, "$GROONGA_HOME", "specified home directory")
# log directory
AC_ARG_WITH(log,
[AC_HELP_STRING([--with-log=PATH],
[specify Groonga log path.])],
GROONGA_LOG_PATH="$withval",
GROONGA_LOG_PATH="/var/log/$PACKAGE_NAME/$PACKAGE_NAME.log")
AC_DEFINE_UNQUOTED(GROONGA_LOG_PATH, "$GROONGA_LOG_PATH", "specified log directory")
# default encoding
AC_ARG_WITH(encoding,
[AC_HELP_STRING([--with-encoding=ENCODING],
[specify Groonga default encoding(euc/sjis/utf8/latin1/koi8r/none)])],
GROONGA_DEFAULT_ENCODING="$withval",
GROONGA_DEFAULT_ENCODING="euc_jp")
AC_DEFINE_UNQUOTED(GROONGA_DEFAULT_ENCODING, "$GROONGA_DEFAULT_ENCODING", "specified default encoding")
# default query escalation threshold
AC_ARG_WITH(query_escalation_threshold,
[AC_HELP_STRING([--with-query-escalation-threshold=NUMBER],
[specify Groonga default query escalation threshold])],
GROONGA_DEFAULT_QUERY_ESCALATION_THRESHOLD="$withval",
GROONGA_DEFAULT_QUERY_ESCALATION_THRESHOLD="0")
AC_DEFINE_UNQUOTED(GROONGA_DEFAULT_QUERY_ESCALATION_THRESHOLD, $GROONGA_DEFAULT_QUERY_ESCALATION_THRESHOLD, "specified query escalation threshold")
AC_CHECK_LIB(m, log, [M_LIBS="-lm"], [AC_MSG_ERROR("No libm found")])
AC_CHECK_LIB(pthread, pthread_mutex_init, [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR("No libpthread found")])
AC_CHECK_LIB(nsl, gethostbyname, [NSL_LIBS="-lnsl"])
AC_CHECK_LIB(socket, socket, [SOCKET_LIBS="-lsocket"])
AC_CHECK_LIB(dl, dlopen, [NSL_LIBS="-ldl"])
# aio
AC_ARG_ENABLE(aio,
[AC_HELP_STRING([--enable-aio],
[use aio/dio based cache. [default=no]])],,
[enable_aio="no"])
if test "x$enable_aio" != "xno"; then
AC_CHECK_LIB(rt, nanosleep, [], [AC_MSG_ERROR("No librt found")])
AC_DEFINE(USE_AIO, [1], [use AIO/DIO])
fi
# nfkc
AC_ARG_ENABLE(nfkc,
[AC_HELP_STRING([--enable-nfkc],
[use nfkc based utf8 normalization. [default=yes]])],,
[enable_nfkc="yes"])
if test "x$enable_nfkc" != "xyes"; then
AC_DEFINE(NO_NFKC, [1], [compile without nfkc.c])
fi
# coverage
m4_ifdef([AC_CHECK_COVERAGE], [AC_CHECK_COVERAGE])
GENHTML_OPTIONS="--title 'Groonga Code Coverage'"
# microyield
AC_MSG_CHECKING([whether enable uyield])
AC_ARG_ENABLE(uyield,
[AC_HELP_STRING([--enable-uyield],
[build for detecting race conditions. [default=no]])],
,
[enable_uyield="no"])
if test "x$enable_uyield" != "xno"; then
AC_DEFINE(USE_UYIELD, [1], [use uyield])
fi
AC_MSG_RESULT($enable_uyield)
## malloc
force_enable_dynamic_malloc_change="no"
# failmalloc
AC_MSG_CHECKING([whether enable fmalloc])
AC_ARG_ENABLE(fmalloc,
[AC_HELP_STRING([--enable-fmalloc],
[make memory allocation failed in specified condition for debug. [default=no]])],
,
[enable_fmalloc="no"])
if test "x$enable_fmalloc" != "xno"; then
force_enable_dynamic_malloc_change="yes"
AC_DEFINE(USE_FAIL_MALLOC, [1], [use fmalloc])
fi
AC_MSG_RESULT($enable_fmalloc)
# abort
AC_MSG_CHECKING([whether enable abort])
AC_ARG_ENABLE(abort,
[AC_HELP_STRING([--enable-abort],
[enable query abortion. [default=no]])],
,
[enable_abort="no"])
if test "x$enable_abort" != "xno"; then
force_enable_dynamic_malloc_change="yes"
AC_DEFINE(USE_QUERY_ABORT, [1], [use abort])
fi
AC_MSG_RESULT($enable_abort)
# dynamic malloc change
AC_MSG_CHECKING([whether allow dynamic memory allocation change])
AC_ARG_ENABLE(dynamic-malloc-change,
[AC_HELP_STRING([--enable-dynamic-malloc-change],
[allow dynamic memory allocation change for testing. [default=no]])],
,
[enable_dynamic_malloc_change="no"])
if test "x$enable_dynamic_malloc_change" != "xyes" -a \
"x$force_enable_dynamic_malloc_change" = "xyes"; then
enable_dynamic_malloc_change="yes"
AC_MSG_RESULT([$enable_dynamic_malloc_change (force)])
else
AC_MSG_RESULT([$enable_dynamic_malloc_change])
fi
if test "x$enable_dynamic_malloc_change" = "xyes"; then
AC_DEFINE(USE_DYNAMIC_MALLOC_CHANGE, [1],
[Define to 1 if you enable dynamic malloc change])
fi
# epoll/kqueue/poll/select check
AC_CHECK_HEADER(sys/epoll.h, [
AC_CHECK_FUNC(epoll_create, [
AC_TRY_RUN([
#include <sys/epoll.h>
int main(int argc, char **argv) { return (epoll_create(16) < 0); }
],
[
have_epoll="yes"
AC_DEFINE(USE_EPOLL, [1], [use epoll])
]
)
])
])
if test "x$have_epoll" != "xyes"; then
AC_CHECK_HEADER(sys/event.h, [
AC_CHECK_FUNC(kevent, [
have_kqueue="yes"
AC_DEFINE(USE_KQUEUE, [1], [use kqueue])
])
])
if test "x$have_kqueue" != "xyes"; then
AC_CHECK_HEADER(sys/poll.h, [
AC_CHECK_FUNC(poll, [
have_poll="yes"
AC_DEFINE(USE_POLL, [1], [use poll])
])
])
if test "x$have_poll" != "xyes"; then
AC_CHECK_FUNC(select, [
have_select="yes"
AC_CHECK_HEADERS(sys/select.h)
AC_DEFINE(USE_SELECT, [1], [use select])
],[
AC_MSG_ERROR([epoll/kqueue/poll/select is missing.])
])
fi
fi
fi
# check MSG_MORE defined
AC_MSG_CHECKING([whether MSG_MORE defined])
AC_COMPILE_IFELSE([[
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char **argv)
{
return MSG_MORE;
}
]],
[
AC_MSG_RESULT(yes)
AC_DEFINE(USE_MSG_MORE, [1], [use MSG_MORE])
],
[
AC_MSG_RESULT(no)
])
# check MSG_NOSIGNAL defined
AC_MSG_CHECKING([whether MSG_NOSIGNAL defined])
AC_COMPILE_IFELSE([[
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char **argv)
{
return MSG_NOSIGNAL;
}
]],
[
AC_MSG_RESULT(yes)
AC_DEFINE(USE_MSG_NOSIGNAL, [1], [use MSG_NOSIGNAL])
],
[
AC_MSG_RESULT(no)
])
# check Cutter with GLib support if available
m4_ifdef([AC_CHECK_GCUTTER], [
AC_CHECK_GCUTTER
],
[ac_cv_use_cutter="no"])
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])
if test "$ac_cv_use_cutter" != "no"; then
AC_DEFINE(WITH_CUTTER, 1, [Define to 1 if you use Cutter])
ac_cv_have_libmemcached_memcached_h=no
AC_CHECK_HEADER(libmemcached/memcached.h,
[ac_cv_have_libmemcached_memcached_h=yes],
[ac_cv_have_libmemcached_memcached_h=no])
AM_CONDITIONAL([WITH_LIBMEMCACHED],
[test "$ac_cv_have_libmemcached_memcached_h" != "no"])
if test "$ac_cv_have_libmemcached_memcached_h" = "yes"; then
AC_DEFINE(WITH_LIBMEMCACHED, 1, [Define to 1 if you use libmemcached])
fi
else
AM_CONDITIONAL([WITH_LIBMEMCACHED], 0)
fi
# check GLib for benchmark
AC_MSG_NOTICE(chcking if benchmark is available)
m4_ifdef([AM_PATH_GLIB_2_0], [
GLIB_REQUIRED=2.8.0
AC_SUBST(GLIB_REQUIRED)
AM_PATH_GLIB_2_0($GLIB_REQUIRED,
[ac_cv_benchmark_available="yes"],
[ac_cv_benchmark_available="no"],
[gobject gthread])
],
[ac_cv_benchmark_available="no"])
if test "$ac_cv_benchmark_available" = "yes"; then
AC_MSG_NOTICE(benchmark is available)
else
AC_MSG_NOTICE(benchmark isn't available)
fi
AM_CONDITIONAL([WITH_BENCHMARK], [test "$ac_cv_benchmark_available" = "yes"])
if test "$ac_cv_benchmark_available" = "yes"; then
AC_DEFINE(WITH_BENCHMARK, 1, [Define to 1 if benchamrk is available])
fi
# zlib
AC_ARG_WITH(zlib,
[AC_HELP_STRING([--with-zlib],
[use zlib for data compression. [default=no]])],
[with_zlib="$withval"],
[with_zlib="no"])
if test "x$with_zlib" = "xno"; then
AC_DEFINE(NO_ZLIB, [1], [without zlib])
else
AC_CHECK_LIB(z, compress, [ZLIB_LIBS="-lz"], [AC_MSG_ERROR("No libz found")])
fi
# lzo
AC_ARG_WITH(lzo,
[AC_HELP_STRING([--with-lzo],
[use lzo for data compression. [default=no]])],
[with_lzo="$withval"],
[with_lzo="no"])
if test "x$with_lzo" = "xno"; then
AC_DEFINE(NO_LZO, [1], [without lzo])
else
AC_CHECK_LIB(lzo2, lzo1_compress, [LZO_LIBS="-llzo2"], [AC_MSG_ERROR("No liblzo2 found")])
fi
# mecab
# NOTE: MUST be checked last
AC_ARG_WITH(mecab,
[AC_HELP_STRING([--with-mecab],
[use mecab for morphological analysis. [default=yes]])],
[with_mecab="$withval"],
[with_mecab="yes"])
if test "x$with_mecab" = "xno"; then
AC_DEFINE(NO_MECAB, [1], [without MeCab])
else
# mecab-config
AC_ARG_WITH(mecab-config,
[AC_HELP_STRING([--with-mecab-config=PATH],
[set mecab-config location. [search path]])],
[AC_CHECK_FILE("$withval", MECAB_CONFIG="$withval", MECAB_CONFIG=no)],
[AC_PATH_PROG(MECAB_CONFIG, mecab-config, no)])
if test "x$MECAB_CONFIG" = "xno"; then
AC_DEFINE(NO_MECAB, [1], [without MeCab])
else
MECAB_CFLAGS="-I`$MECAB_CONFIG --inc-dir`"
LDFLAGS="$LDFLAGS -L`$MECAB_CONFIG --libs-only-L`"
AC_CHECK_LIB(mecab, mecab_new, [], [AC_MSG_ERROR("No libmecab found")])
CPPFLAGS="$CPPFLAGS $MECAB_CFLAGS"
AC_CHECK_HEADER(mecab.h, , [AC_MSG_ERROR("No mecab.h found")])
fi
fi
# futex check
AC_ARG_ENABLE(futex,
[AC_HELP_STRING([--enable-futex],
[use futex. [default=no]])],
,
[enable_futex="no"])
if test "x$enable_futex" != "xno"; then
AC_CHECK_HEADERS(linux/futex.h sys/syscall.h, [
AC_DEFINE(USE_UYIELD, [1], [use uyield])
], [
AC_MSG_ERROR("linux/futex.h or sys/syscall.h not found")
])
fi
AC_MSG_CHECKING([whether enable futex])
AC_MSG_RESULT($enable_futex)
# flags for compile groonga
CFLAGS="$CFLAGS $MECAB_CFLAGS $OPT_CFLAGS"
LIBS="$LIBS $ZLIB_LIBS $LZO_LIBS $PTHREAD_LIBS $M_LIBS $NSL_LIBS $SOCKET_LIBS"
AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS, "$ac_configure_args", "specified configure options")
# flags for groonga-cfg
#GROONGA_LIBDIR='-L${libdir}'
#GROONGA_INCLUDEDIR="-I${includedir}/groonga"
#GROONGA_CFLAGS=""
#GROONGA_LIBS="-lgroonga $PTHREAD_LIBS"
#AC_SUBST(GROONGA_LIBDIR)
#AC_SUBST(GROONGA_INCLUDEDIR)
#AC_SUBST(GROONGA_CFLAGS)
#AC_SUBST(GROONGA_LIBS)
AC_OUTPUT([
groonga.spec
groonga.pc
])
echo "
$PACKAGE_NAME $PACKAGE_VERSION configuration:
-----------------------
Compiler: ${CC}
CFLAGS: ${CFLAGS}
Libraries: ${LIBS}
Install path prefix: ${prefix}
Now type 'make' to build $PACKAGE_NAME $PACKAGE_VERSION!
"