1AC_PREREQ(2.59)
2m4_define([groonga_version], m4_include(base_version))
3AC_INIT([groonga], groonga_version, [groonga@razil.jp])
4AC_CONFIG_MACRO_DIR([m4])
5AM_CONFIG_HEADER(config.h)
6
7GRN_VERSION_RC=`echo groonga_version | sed -e 's/\./,/g'`
8AC_SUBST(GRN_VERSION_RC)
9
10AM_INIT_AUTOMAKE([foreign tar-pax subdir-objects])
11m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
12
13PACKAGE_LABEL=Groonga
14AC_SUBST(PACKAGE_LABEL)
15AC_DEFINE_UNQUOTED(PACKAGE_LABEL, ["$PACKAGE_LABEL"], [Label of package])
16
17# for Autoconf 2.60 or earlier.
18if test -z "${datarootdir}"; then
19   datarootdir="\${prefix}/share"
20   AC_SUBST(datarootdir)
21fi
22
23# for Autoconf 2.59 or earlier.
24if test -z "${docdir}"; then
25   docdir="\${datarootdir}/doc/\${PACKAGE_TARNAME}"
26   AC_SUBST(docdir)
27fi
28
29AC_CANONICAL_HOST
30AC_DEFINE_UNQUOTED(HOST_CPU, ["$host_cpu"], [host CPU])
31AC_DEFINE_UNQUOTED(HOST_OS, ["$host_os"], [host OS])
32
33AC_MSG_CHECKING([for native Win32])
34case "$host_os" in
35  mingw*)
36    os_win32=yes
37    ;;
38  *)
39    os_win32=no
40    ;;
41esac
42AC_MSG_RESULT([$os_win32])
43
44AC_MSG_CHECKING([for some Win32 platform])
45case "$host_os" in
46  mingw*|cygwin*)
47    platform_win32=yes
48    ;;
49  *)
50    platform_win32=no
51    ;;
52esac
53AC_MSG_RESULT([$platform_win32])
54
55AM_CONDITIONAL(OS_WIN32, test "$os_win32" = "yes")
56AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
57
58AC_MSG_CHECKING([for NetBSD.])
59case "$host_os" in
60  netbsd*)
61    netbsd=yes
62    ;;
63  *)
64    netbsd=no
65    ;;
66esac
67AC_MSG_RESULT([$netbsd])
68
69AC_MSG_CHECKING([for Solaris.])
70case "$host_os" in
71  solaris*)
72    solaris=yes
73    ;;
74  *)
75    solaris=no
76    ;;
77esac
78AC_MSG_RESULT([$solaris])
79
80AC_C_BIGENDIAN
81AC_PROG_CXX
82m4_ifdef([AX_CXX_COMPILE_STDCXX_11],
83         [AX_CXX_COMPILE_STDCXX_11([ext], [optional])])
84AC_PROG_CC
85m4_ifdef([AC_PROG_CC_C99],
86         [AC_PROG_CC_C99])
87AM_PROG_CC_C_O
88m4_ifdef([PKG_PROG_PKG_CONFIG],
89         [PKG_PROG_PKG_CONFIG([0.19])
90          m4_pattern_allow(PKG_CONFIG_LIBDIR)])
91
92AC_MSG_CHECKING([for clang])
93if test "$CC" = "clang"; then
94  CLANG=yes
95else
96  CLANG=no
97fi
98AC_MSG_RESULT([$CLANG])
99
100AC_DEFUN([CHECK_CFLAG], [
101  AC_MSG_CHECKING([if gcc supports $1])
102  old_CFLAGS=$CFLAGS
103  flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
104  CFLAGS="$CFLAGS $flag -Werror"
105  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
106    [check_cflag=yes],
107    [check_cflag=no])
108  CFLAGS="$old_CFLAGS"
109  if test "x$check_cflag" = "xyes"; then
110    CFLAGS="$CFLAGS $1"
111  fi
112  AC_MSG_RESULT([$check_cflag])
113])
114
115AC_DEFUN([CHECK_CXXFLAG], [
116  AC_MSG_CHECKING([if g++ supports $1])
117  old_CXXFLAGS=$CXXFLAGS
118  flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
119  CXXFLAGS="$CXXFLAGS $flag -Werror"
120  AC_LANG_PUSH([C++])
121  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
122    [check_cxxflag=yes],
123    [check_cxxflag=no])
124  AC_LANG_POP([C++])
125  CXXFLAGS="$old_CXXFLAGS"
126  if test "x$check_cxxflag" = "xyes"; then
127    CXXFLAGS="$CXXFLAGS $1"
128  fi
129  AC_MSG_RESULT([$check_cxxflag])
130])
131
132AC_DEFUN([CHECK_BUILD_FLAG], [
133  CHECK_CFLAG([$1])
134  CHECK_CXXFLAG([$1])
135])
136
137AC_DEFUN([REMOVE_CXXFLAG], [
138  AC_MSG_CHECKING([whether g++ option $1 is needed to be removed])
139  if echo "$CXXFLAGS" | grep -q -- "$1"; then
140    CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's,$1,,'`
141    remove_cxxflag=yes
142  else
143    remove_cxxflag=no
144  fi
145  AC_MSG_RESULT([$remove_cxxflag])
146])
147
148TEST_CFLAGS=""
149TEST_CXXFLAGS=""
150NO_STRICT_ALIASING_CFLAGS=""
151NO_FLOAT_EQUAL_CFLAGS=""
152NO_BAD_FUNCTION_CAST_CFLAGS=""
153if test "$GCC" = "yes"; then
154  CHECK_BUILD_FLAG([-Wall])
155  if test "x$check_cflag" = "xno"; then
156    CHECK_BUILD_FLAG([-W])
157  fi
158  CHECK_BUILD_FLAG([-Wno-unused-but-set-variable]) # FIXME: enable it.
159  CHECK_CFLAG([-Wno-pointer-sign])
160  CHECK_CFLAG([-Wno-declaration-after-statement])
161
162  CHECK_BUILD_FLAG([-Wformat])
163  CHECK_BUILD_FLAG([-Wstrict-aliasing=2])
164  if test "x$check_cflag" = "xyes"; then
165    NO_STRICT_ALIASING_CFLAGS="-fno-strict-aliasing"
166  fi
167  CHECK_BUILD_FLAG([-Wdisabled-optimization])
168  CHECK_BUILD_FLAG([-Wfloat-equal])
169  if test "x$check_cflag" = "xyes"; then
170    NO_FLOAT_EQUAL_CFLAGS="-Wno-float-equal"
171  fi
172  CHECK_BUILD_FLAG([-Wpointer-arith])
173  CHECK_CFLAG([-Wbad-function-cast])
174  if test "x$check_cflag" = "xyes"; then
175    NO_BAD_FUNCTION_CAST_CFLAGS="-Wno-bad-function-cast"
176  fi
177  if test "$CLANG" = "no"; then
178    CHECK_BUILD_FLAG([-Wcast-align])
179  fi
180#  CHECK_BUILD_FLAG([-Wredundant-decls])
181#  CHECK_BUILD_FLAG([-Wunsafe-loop-optimizations])
182#  CHECK_BUILD_FLAG([-Wunreachable-code])
183#  CHECK_BUILD_FLAG([-Wswitch-enum])
184#  CHECK_BUILD_FLAG([-Wshadow])
185#  CHECK_BUILD_FLAG([-Wconversion])
186  CHECK_BUILD_FLAG([-Wwrite-strings])
187#  CHECK_BUILD_FLAG([-Winline])
188
189  CHECK_CXXFLAG([-fexceptions])
190  CHECK_CXXFLAG([-fimplicit-templates])
191fi
192AC_SUBST(TEST_CFLAGS)
193AC_SUBST(TEST_CXXFLAGS)
194AC_SUBST(NO_STRICT_ALIASING_CFLAGS)
195AC_SUBST(NO_FLOAT_EQUAL_CFLAGS)
196AC_SUBST(NO_BAD_FUNCTION_CAST_CFLAGS)
197
198LT_INIT([dlopen win32-dll])
199LT_LANG([Windows Resource])
200LT_OUTPUT
201
202LT_CURRENT=0
203LT_REVISION=0
204LT_AGE=0
205LT_VERSION_INFO="\$(LT_CURRENT):\$(LT_REVISION):\$(LT_AGE)"
206AC_SUBST(LT_CURRENT)
207AC_SUBST(LT_REVISION)
208AC_SUBST(LT_AGE)
209AC_SUBST(LT_VERSION_INFO)
210
211GRN_DLL_FILENAME="libgroonga-\$(LT_CURRENT).dll"
212AC_SUBST(GRN_DLL_FILENAME)
213
214if test "$srcdir/version.sh"; then
215  . "$srcdir/version.sh"
216  AC_SUBST(GRN_VERSION)
217  AC_DEFINE_UNQUOTED(GRN_VERSION, ["$GRN_VERSION"], [groonga version])
218fi
219
220AC_CONFIG_FILES([
221  Makefile
222  build/Makefile
223  build/cmake_modules/Makefile
224  src/Makefile
225  src/suggest/Makefile
226  src/httpd/Makefile
227  lib/Makefile
228  lib/dat/Makefile
229  lib/mrb/Makefile
230  lib/mrb/scripts/Makefile
231  lib/mrb/scripts/command_line/Makefile
232  lib/mrb/scripts/context/Makefile
233  lib/mrb/scripts/expression_tree/Makefile
234  lib/mrb/scripts/initialize/Makefile
235  lib/mrb/scripts/logger/Makefile
236  lib/mrb/scripts/query_logger/Makefile
237  lib/proc/Makefile
238  lib/ts/Makefile
239  include/Makefile
240  include/groonga/Makefile
241  plugins/Makefile
242  plugins/tokenizers/Makefile
243  plugins/suggest/Makefile
244  plugins/query_expanders/Makefile
245  plugins/ruby/Makefile
246  plugins/token_filters/Makefile
247  plugins/sharding/Makefile
248  plugins/functions/Makefile
249  plugins/expression_rewriters/Makefile
250  examples/Makefile
251  examples/dictionary/Makefile
252  examples/dictionary/edict/Makefile
253  examples/dictionary/eijiro/Makefile
254  examples/dictionary/gene95/Makefile
255  examples/dictionary/jmdict/Makefile
256  packages/Makefile
257  packages/apt/Makefile
258  packages/ubuntu/Makefile
259  packages/rpm/Makefile
260  packages/rpm/centos/Makefile
261  packages/yum/Makefile
262  packages/source/Makefile
263  packages/windows/Makefile
264  packages/windows/patches/Makefile
265  packages/windows/language-files/Makefile
266  packages/windows/setup-x64.nsi
267  data/Makefile
268  data/html/Makefile
269  data/munin/Makefile
270  data/init.d/Makefile
271  data/init.d/centos/Makefile
272  data/init.d/centos/sysconfig/Makefile
273  data/logrotate.d/Makefile
274  data/logrotate.d/centos/Makefile
275  data/systemd/Makefile
276  data/systemd/centos/Makefile
277  data/systemd/centos/sysconfig/Makefile
278  data/scripts/Makefile
279  data/tmpfiles.d/Makefile
280  tools/Makefile
281  doc/Makefile
282  doc/locale/Makefile
283  doc/locale/en/Makefile
284  doc/locale/en/LC_MESSAGES/Makefile
285  doc/locale/ja/Makefile
286  doc/locale/ja/LC_MESSAGES/Makefile
287  test/Makefile
288  test/unit/Makefile
289  test/unit/lib/Makefile
290  test/unit/fixtures/Makefile
291  test/unit/fixtures/inverted-index/Makefile
292  test/unit/fixtures/stress/Makefile
293  test/unit/fixtures/plugins/Makefile
294  test/unit/fixtures/geo/Makefile
295  test/unit/fixtures/story/Makefile
296  test/unit/fixtures/story/taiyaki/Makefile
297  test/unit/util/Makefile
298  test/unit/core/Makefile
299  test/unit/core/dat/Makefile
300  test/unit/story/Makefile
301  test/command/Makefile
302  benchmark/Makefile
303  benchmark/fixtures/Makefile
304  benchmark/fixtures/geo-select/Makefile
305  benchmark/lib/Makefile
306  vendor/Makefile
307  vendor/lz4/Makefile
308  vendor/onigmo/Makefile
309  vendor/mecab/Makefile
310  vendor/message_pack/Makefile
311  vendor/mruby/Makefile
312])
313
314if test "$GCC" = "yes"; then
315  AC_DEFINE(_GNU_SOURCE, [1], [Define to 1 if you use GCC.])
316fi
317
318if test "$netbsd" = "yes"; then
319  AC_DEFINE(_NETBSD_SOURCE, [1], [Define to 1 if you are on NetBSD.])
320fi
321
322if test "$solaris" = "yes"; then
323  AC_DEFINE(_XPG4_2, [1],
324            [Define to 1 for msghdr.msg_control if you are on Solaris.])
325  AC_DEFINE(__EXTENSIONS__, [1],
326            [Define to 1 for singal.h with _XPG4_2 if you are on Solaris.])
327fi
328
329# For debug
330AC_ARG_ENABLE(debug,
331  [AS_HELP_STRING([--enable-debug],
332                  [use debug flags (default=no)])],
333  [grn_debug="$enableval"],
334  [grn_debug="no"])
335if test "x$grn_debug" != "xno"; then
336  grn_debug="yes"
337  if test "$CLANG" = "yes"; then
338    CFLAGS="$CFLAGS -O0 -g"
339    CXXFLAGS="$CXXFLAGS -O0 -g"
340  elif test "$GCC" = "yes"; then
341    CFLAGS="$CFLAGS -O0 -g3"
342    CXXFLAGS="$CXXFLAGS -O0 -g3"
343  fi
344fi
345AC_SUBST(grn_debug)
346
347AC_SEARCH_LIBS(log, m, [], [AC_MSG_ERROR("No libm found")])
348AC_MSG_CHECKING([for fpclassify])
349AC_LINK_IFELSE(
350  [AC_LANG_PROGRAM(
351    [#include <math.h>],
352    [if (fpclassify(0.0)) {return 0;}]
353   )],
354  [
355    AC_DEFINE(HAVE_FPCLASSIFY, [1], [use fpclassify])
356    AC_MSG_RESULT(yes)
357  ],
358  [
359    AC_LINK_IFELSE(
360      [AC_LANG_PROGRAM(
361        [#define _ISOC99_SOURCE
362         #include <math.h>],
363        [if (fpclassify(0.0)) {return 0;}]
364       )],
365      [
366        AC_DEFINE(_ISOC99_SOURCE, [1], [Define to 1 for fpclassify])
367        AC_DEFINE(HAVE_FPCLASSIFY, [1], [use fpclassify with _ISOC99_SOURCE])
368        AC_MSG_RESULT(yes)
369      ],
370      [
371        AC_MSG_RESULT(no)
372      ])
373  ])
374
375m4_include(build/ac_macros/check_headers.m4)
376m4_include(build/ac_macros/check_functions.m4)
377
378AC_SEARCH_LIBS(backtrace, execinfo,
379               [AC_DEFINE(HAVE_BACKTRACE, [1],
380                          [Define to 1 if you have the `backtrace' function.])])
381AC_SEARCH_LIBS(clock_gettime, rt,
382               [AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [use clock_gettime])])
383AC_SYS_LARGEFILE
384AC_TYPE_OFF_T
385AC_TYPE_SIZE_T
386AC_CHECK_SIZEOF(off_t)
387
388# MAP_HUGETLB
389AC_ARG_ENABLE(map-hugetlb,
390  [AS_HELP_STRING([--enable-map-hugetlb],
391                  [use MAP_HUGETLB. [default=no]])],
392  ,
393  [enable_map_hugetlb="no"])
394if test "x$enable_map_hugetlb" != "xno"; then
395  AC_MSG_CHECKING([for MAP_HUGETLB])
396  AC_COMPILE_IFELSE(
397    [AC_LANG_PROGRAM(
398       [
399#ifdef HAVE_SYS_MMAN_H
400#  include <sys/mman.h>
401#endif /* HAVE_SYS_MMAN_H */
402       ],
403       [MAP_HUGETLB;]
404     )],
405    [
406     AC_DEFINE(USE_MAP_HUGETLB, [1], [use MAP_HUGETLB])
407     AC_MSG_RESULT(yes)
408    ],
409    [
410     AC_MSG_RESULT(no)
411     AC_MSG_ERROR("MAP_HUGETLB isn't available.")
412    ]
413  )
414fi
415
416# log path
417AC_ARG_WITH(log_path,
418  [AS_HELP_STRING([--with-log-path=PATH],
419    [specify groonga log path.])],
420  grn_log_path="$withval",
421  grn_log_path="\$(localstatedir)/log/\$(PACKAGE_NAME)/\$(PACKAGE_NAME).log")
422AC_SUBST(grn_log_path)
423
424# default encoding
425AC_ARG_WITH(default_encoding,
426  [AS_HELP_STRING([--with-default-encoding=ENCODING],
427    [specify groonga default encoding(euc_jp/sjis/utf8/latin1/koi8r/none)])],
428  GRN_DEFAULT_ENCODING="$withval",
429  GRN_DEFAULT_ENCODING="utf8")
430AC_DEFINE_UNQUOTED(GRN_DEFAULT_ENCODING, "$GRN_DEFAULT_ENCODING", "specified default encoding")
431
432# default match escalation threshold
433AC_ARG_WITH(match_escalation_threshold,
434  [AS_HELP_STRING([--with-match-escalation-threshold=NUMBER],
435    [specify groonga default match escalation threshold])],
436  GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD="$withval",
437  GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD="0")
438AC_DEFINE_UNQUOTED(GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD, $GRN_DEFAULT_MATCH_ESCALATION_THRESHOLD, "specified match escalation threshold")
439
440# default DB key management algorithm
441AC_ARG_WITH(default_db_key,
442  [AS_HELP_STRING([--with-default-db-key=ALGORITHM],
443    [specify groonga default DB key (pat/dat/auto)])],
444  GRN_DEFAULT_DB_KEY="$withval",
445  GRN_DEFAULT_DB_KEY="auto")
446AC_DEFINE_UNQUOTED(GRN_DEFAULT_DB_KEY, "$GRN_DEFAULT_DB_KEY",
447                   "specified default DB key management algorithm")
448
449# DANGER!!!: stack size
450GRN_STACK_SIZE=1024
451AC_ARG_WITH(stack_size,
452  [AS_HELP_STRING([--with-stack-size=SIZE],
453    [DANGER!!!
454     This option specifies stack size. (default=$GRN_STACK_SIZE)
455     Normally, you should not use this option.])],
456  GRN_STACK_SIZE="$withval")
457AC_DEFINE_UNQUOTED(GRN_STACK_SIZE, [$GRN_STACK_SIZE], [stack size])
458
459# lock timeout
460GRN_LOCK_TIMEOUT=900000
461AC_ARG_WITH(lock_timeout,
462  [AS_HELP_STRING([--with-lock-timeout=N],
463    [This option specifies how many times Groonga tries to acquire a lock.
464     Each try waits --with-lock-wait-time nanoseconds to acquire a lock.
465     It means that Groonga gives up after
466     (--with-lock-wait-time * --with-lock-timeout) nanoseconds.
467     (default=$GRN_LOCK_TIMEOUT)])],
468  GRN_LOCK_TIMEOUT="$withval")
469AC_DEFINE_UNQUOTED(GRN_LOCK_TIMEOUT,
470                   [$GRN_LOCK_TIMEOUT],
471                   [lock timeout])
472
473# lock wait time
474GRN_LOCK_WAIT_TIME_NANOSECOND=1000000
475AC_ARG_WITH(lock_wait_time,
476  [AS_HELP_STRING([--with-lock-wait-time=NANOSECONDS],
477    [This option specifies wait time in nanosecond to acquire a lock.
478     (default=$GRN_LOCK_WAIT_TIME_NANOSECOND)])],
479  GRN_LOCK_WAIT_TIME_NANOSECOND="$withval")
480AC_DEFINE_UNQUOTED(GRN_LOCK_WAIT_TIME_NANOSECOND,
481                   [$GRN_LOCK_WAIT_TIME_NANOSECOND],
482                   [lock wait time in nanosecond])
483
484if test "$os_win32" != "yes"; then
485  AC_CHECK_HEADERS(pthread.h)
486  AC_SEARCH_LIBS(pthread_create, pthread,
487                 [],
488                 [AC_MSG_ERROR("No libpthread found")])
489  AC_CHECK_FUNCS(pthread_mutexattr_setpshared)
490  AC_CHECK_FUNCS(pthread_condattr_setpshared)
491fi
492AC_SEARCH_LIBS(gethostbyname, nsl)
493AC_SEARCH_LIBS(socket, socket)
494AC_SEARCH_LIBS(dlopen, dl)
495
496# nfkc
497AC_ARG_ENABLE(nfkc,
498  [AS_HELP_STRING([--enable-nfkc],
499    [use nfkc based utf8 normalization. [default=yes]])],,
500  [enable_nfkc="yes"])
501if test "x$enable_nfkc" = "xyes"; then
502  AC_DEFINE(GRN_WITH_NFKC, [1], [compile with nfkc.c])
503fi
504
505# coverage
506m4_ifdef([AC_CHECK_COVERAGE], [AC_CHECK_COVERAGE])
507GENHTML_OPTIONS="--title 'groonga Code Coverage'"
508
509# microyield
510AC_MSG_CHECKING([whether enable uyield])
511AC_ARG_ENABLE(uyield,
512  [AS_HELP_STRING([--enable-uyield],
513    [build for detecting race conditions. [default=no]])],
514  ,
515  [enable_uyield="no"])
516AC_MSG_RESULT($enable_uyield)
517
518## malloc
519force_enable_dynamic_malloc_change="no"
520
521# exact-alloc-count
522AC_MSG_CHECKING([whether enable exact-alloc-count])
523AC_ARG_ENABLE(exact-alloc-count,
524  [AS_HELP_STRING([--enable-exact-alloc-count],
525    [atomic counting for memory alloc count. [default=yes]])],,
526  [enable_exact_alloc_count="yes"])
527if test "x$enable_exact_alloc_count" != "xno"; then
528  AC_DEFINE(USE_EXACT_ALLOC_COUNT, [1], [alloc_count with atomic])
529fi
530AC_MSG_RESULT($enable_exact_alloc_count)
531
532# failmalloc
533AC_MSG_CHECKING([whether enable fmalloc])
534AC_ARG_ENABLE(fmalloc,
535  [AS_HELP_STRING([--enable-fmalloc],
536    [make memory allocation failed in specified condition for debug. [default=no]])],
537  ,
538  [enable_fmalloc="no"])
539if test "x$enable_fmalloc" != "xno"; then
540  force_enable_dynamic_malloc_change="yes"
541  AC_DEFINE(USE_FAIL_MALLOC, [1], [use fmalloc])
542fi
543AC_MSG_RESULT($enable_fmalloc)
544
545# abort
546AC_MSG_CHECKING([whether enable abort])
547AC_ARG_ENABLE(abort,
548  [AS_HELP_STRING([--enable-abort],
549    [enable query abortion. [default=no]])],
550  ,
551  [enable_abort="no"])
552if test "x$enable_abort" != "xno"; then
553  force_enable_dynamic_malloc_change="yes"
554  AC_DEFINE(USE_QUERY_ABORT, [1], [use abort])
555fi
556AC_MSG_RESULT($enable_abort)
557
558# dynamic malloc change
559AC_MSG_CHECKING([whether allow dynamic memory allocation change])
560AC_ARG_ENABLE(dynamic-malloc-change,
561  [AS_HELP_STRING([--enable-dynamic-malloc-change],
562    [allow dynamic memory allocation change for testing. [default=no]])],
563  ,
564  [enable_dynamic_malloc_change="no"])
565if test "x$enable_dynamic_malloc_change" != "xyes" -a \
566     "x$force_enable_dynamic_malloc_change" = "xyes"; then
567  enable_dynamic_malloc_change="yes"
568  AC_MSG_RESULT([$enable_dynamic_malloc_change (force)])
569else
570  AC_MSG_RESULT([$enable_dynamic_malloc_change])
571fi
572
573if test "x$enable_dynamic_malloc_change" = "xyes"; then
574  AC_DEFINE(USE_DYNAMIC_MALLOC_CHANGE, [1],
575            [Define to 1 if you enable dynamic malloc change])
576fi
577
578# memory debug
579AC_MSG_CHECKING([whether debug memory management])
580AC_ARG_ENABLE(memory-debug,
581  [AS_HELP_STRING([--enable-memory-debug],
582    [debug memory management. [default=no]])],
583  ,
584  [enable_memory_debug="no"])
585AC_MSG_RESULT([$enable_memory_debug])
586
587if test "x$enable_memory_debug" = "xyes"; then
588  AC_DEFINE(USE_MEMORY_DEBUG, [1],
589            [Define to 1 if you enable debuging memory management])
590fi
591
592# epoll/kqueue/poll/select check
593AC_CHECK_HEADER(sys/epoll.h, [
594  AC_CHECK_FUNC(epoll_create, [
595    AC_TRY_RUN([
596#include <sys/epoll.h>
597int main(int argc, char **argv) { return (epoll_create(16) < 0); }
598    ],
599    [
600      have_epoll="yes"
601      AC_DEFINE(USE_EPOLL, [1], [use epoll])
602    ]
603    )
604  ])
605])
606
607if test "x$have_epoll" != "xyes"; then
608  AC_CHECK_HEADER(sys/event.h, [
609    AC_CHECK_FUNC(kevent, [
610      have_kqueue="yes"
611      AC_DEFINE(USE_KQUEUE, [1], [use kqueue])
612    ])
613  ])
614  if test "x$have_kqueue" != "xyes"; then
615    AC_CHECK_HEADER(poll.h, [
616      AC_CHECK_FUNC(poll, [
617        have_poll="yes"
618        AC_DEFINE(USE_POLL, [1], [use poll])
619      ])
620    ])
621    if test "x$have_poll" != "xyes"; then
622      if test "$os_win32" = "yes"; then
623        AC_CHECK_HEADER(winsock2.h, [have_select="yes"])
624      else
625        AC_CHECK_FUNC(select, [
626          have_select="yes"
627          AC_CHECK_HEADERS(sys/select.h)
628        ])
629      fi
630      if test "x$have_select" = "xyes"; then
631        AC_DEFINE(USE_SELECT, [1], [use select])
632      else
633        AC_MSG_ERROR([epoll/kqueue/poll/select is missing.])
634      fi
635    fi
636  fi
637fi
638
639# check MSG_MORE defined
640AC_MSG_CHECKING([whether MSG_MORE defined])
641AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
642#include <sys/types.h>
643#include <sys/socket.h>
644
645int main(int argc, char **argv)
646{
647  return MSG_MORE;
648}
649    ])],
650    [
651      AC_MSG_RESULT(yes)
652      AC_DEFINE(USE_MSG_MORE, [1], [use MSG_MORE])
653    ],
654    [
655      AC_MSG_RESULT(no)
656    ])
657
658# check MSG_NOSIGNAL defined
659AC_MSG_CHECKING([whether MSG_NOSIGNAL defined])
660AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
661#include <sys/types.h>
662#include <sys/socket.h>
663
664int main(int argc, char **argv)
665{
666  return MSG_NOSIGNAL;
667}
668    ])],
669    [
670      AC_MSG_RESULT(yes)
671      AC_DEFINE(USE_MSG_NOSIGNAL, [1], [use MSG_NOSIGNAL])
672    ],
673    [
674      AC_MSG_RESULT(no)
675    ])
676
677# MinGW
678if test "$os_win32" = "yes"; then
679  WINDOWS_LDFLAGS="-mwindows"
680  WINDOWS_LIBS="-ladvapi32 -lws2_32"
681else
682  WINDOWS_LDFLAGS=
683  WINDOWS_LIBS=
684fi
685AC_SUBST(WINDOWS_LDFLAGS)
686AC_SUBST(WINDOWS_LIBS)
687
688# groonga binary path
689GROONGA="${ac_pwd}/src/groonga"
690AC_SUBST(GROONGA)
691
692# groonga-benchmark binary path
693GROONGA_BENCHMARK="${ac_pwd}/src/groonga-benchmark"
694AC_SUBST(GROONGA_BENCHMARK)
695
696# groonga-suggest-create-dataset binary path
697GROONGA_SUGGEST_CREATE_DATASET="${ac_pwd}/src/suggest/groonga-suggest-create-dataset"
698AC_SUBST(GROONGA_SUGGEST_CREATE_DATASET)
699
700# groonga-mruby binary path
701GROONGA_MRUBY="${ac_pwd}/src/groonga-mruby"
702AC_SUBST(GROONGA_MRUBY)
703
704# check Cutter with GLib support if available
705REQUIRED_MINIMUM_CUTTER_VERSION=1.1.6
706REQUIRED_MINIMUM_CPPCUTTER_VERSION=1.2.0
707m4_ifdef([AC_CHECK_GCUTTER],
708         [AC_CHECK_GCUTTER(>= $REQUIRED_MINIMUM_CUTTER_VERSION)],
709         [cutter_use_cutter="no"])
710m4_ifdef([AC_CHECK_CPPCUTTER],
711         [AC_CHECK_CPPCUTTER(>= $REQUIRED_MINIMUM_CPPCUTTER_VERSION)],
712         [cutter_use_cppcutter="no"])
713
714AM_CONDITIONAL([WITH_CUTTER], [test "$cutter_use_cutter" = "yes"])
715AM_CONDITIONAL([WITH_CPPCUTTER], [test "$cutter_use_cppcutter" = "yes"])
716if test "$cutter_use_cutter" = "yes"; then
717  AC_DEFINE(GRN_WITH_CUTTER, 1, [Define to 1 if you use Cutter])
718fi
719
720# check for benchmark
721AC_ARG_ENABLE(benchmark,
722  [AS_HELP_STRING([--disable-benchmark],
723    [don't build benchmark programs.])],,
724  [enable_benchmark="yes"])
725if test "x$enable_benchmark" = "xno"; then
726  benchmark_available="no"
727else
728  REQUIRED_GLIB_VERSION=2.14.0
729  m4_ifdef([AM_PATH_GLIB_2_0],
730           [AM_PATH_GLIB_2_0($REQUIRED_GLIB_VERSION,
731                             [benchmark_available="yes"],
732                             [benchmark_available="no"],
733                             [gobject gthread])],
734           [benchmark_available="no"])
735  AC_MSG_CHECKING(for benchmark availablity)
736  AC_MSG_RESULT($ac_benchmark_available)
737fi
738if test "$benchmark_available" = "yes"; then
739  AC_DEFINE(GRN_WITH_BENCHMARK, 1, [Define to 1 if benchamrk is available])
740fi
741AM_CONDITIONAL([WITH_BENCHMARK], [test "$benchmark_available" = "yes"])
742
743# check Ruby for HTTP test
744ac_cv_ruby_available="no"
745AC_ARG_WITH([ruby],
746            AS_HELP_STRING([--with-ruby=PATH],
747                           [Ruby interpreter path (default: no)]),
748            [RUBY="$withval"],
749            [RUBY="no"])
750
751if test "x$RUBY" = "xno"; then
752  RUBY=
753else
754  if test "x$RUBY" = "xyes"; then
755    AC_PATH_PROGS(RUBY,
756                  [ dnl
757                    ruby2.3 ruby23 dnl
758                    ruby2.2 ruby22 dnl
759                    ruby2.1 ruby21 dnl
760                    ruby dnl
761                  ],
762                  ruby-not-found)
763    if test "$RUBY" != "ruby-not-found"; then
764      ruby_version="`$RUBY --version`"
765      if echo "$ruby_version" | grep -q -- 'ruby \(2\.\)'; then
766        ac_cv_ruby_available="yes"
767      else
768        AC_MSG_WARN([$RUBY isn't Ruby 2.0 or later ($ruby_version)])
769      fi
770    fi
771  else
772    ruby_not_found_warning_message="$RUBY is not found."
773    case "$RUBY" in
774    /*)
775      AC_CHECK_FILE([$RUBY],
776                    [ac_cv_ruby_available="yes"],
777                    [AC_MSG_WARN([$ruby_not_found_warning_message])
778                     RUBY="$RUBY-not-found"])
779      ;;
780    *)
781      ruby_not_found="$RUBY-not-found"
782      AC_PATH_PROGS(RUBY, "$RUBY", "$ruby_not_found")
783      if test "$RUBY" = "$ruby_not_found"; then
784        AC_MSG_WARN([$ruby_not_found_warning_message])
785      else
786        ac_cv_ruby_available="yes"
787      fi
788      ;;
789    esac
790  fi
791fi
792AC_SUBST(RUBY)
793AM_CONDITIONAL([WITH_RUBY], [test "$ac_cv_ruby_available" = "yes"])
794
795AM_CONDITIONAL([WITH_UNIT_TEST],
796               [test "$cutter_use_cutter" = "yes" -o \
797                     "$ac_cv_ruby_available" = "yes"])
798
799AM_CONDITIONAL([WITH_COMMAND_TEST],
800               [test "$ac_cv_ruby_available" = "yes"])
801
802# check Lemon for generating .c and .h files from .y file
803lemon_available="no"
804AC_ARG_WITH([lemon],
805            AS_HELP_STRING([--with-lemon=PATH],
806                           [Lemon path (default: auto)]),
807            [LEMON="$withval"],
808            [: ${LEMON:=auto}])
809
810if test "$LEMON" = "no"; then
811  LEMON=
812else
813  if test "$LEMON" = "auto"; then
814    AC_PATH_PROGS(LEMON, [lemon], none)
815    if test "$LEMON" != "none"; then
816      lemon_available="yes"
817    fi
818  elif test "$LEMON" = "yes"; then
819    AC_PATH_PROGS(LEMON, [lemon], none)
820    if test "$LEMON" = "none"; then
821      AC_MSG_WARN([lemon is not found. Disable .y compilation.])
822    else
823      lemon_available="yes"
824    fi
825  else
826    AC_CHECK_FILE([$LEMON],
827                  [lemon_available="yes"],
828                  [AC_MSG_WARN([$LEMON is not found. Disable .y compilation.])])
829  fi
830fi
831AC_SUBST(LEMON)
832AM_CONDITIONAL([WITH_LEMON], [test "$lemon_available" = "yes"])
833
834# libedit
835AC_ARG_ENABLE(libedit,
836  [AS_HELP_STRING([--disable-libedit],
837    [use libedit for console. [default=auto-detect]])],
838  [enable_libedit="$enableval"],
839  [enable_libedit="auto"])
840if test "x$enable_libedit" != "xno"; then
841  m4_ifdef([PKG_CHECK_MODULES], [
842    PKG_CHECK_MODULES([LIBEDIT], [libedit >= 3.0],
843      [LIBS_SAVE="$LIBS"
844       LDFLAGS_SAVE="$LDFLAGS"
845       LDFLAGS="$LIBEDIT_LIBS $LDFLAGS"
846       AC_SEARCH_LIBS(el_wline, edit,
847                      [libedit_available=yes],
848                      [libedit_available=no])
849       LIBS="$LIBS_SAVE"
850       LDFLAGS="$LDFLAGS_SAVE"],
851      [libedit_available=no])
852    ],
853    [libedit_available=no])
854  if test "x$libedit_available" = "xyes"; then
855    AC_DEFINE(GRN_WITH_LIBEDIT, [1], [Use libedit with multibyte support.])
856  else
857    if test "x$enable_editline" = "xyes"; then
858      AC_MSG_ERROR("No libedit found")
859    fi
860  fi
861fi
862
863# zlib
864AC_ARG_WITH(zlib,
865  [AS_HELP_STRING([--with-zlib],
866    [Support data compression by zlib. [default=auto]])],
867  [with_zlib="$withval"],
868  [with_zlib="auto"])
869GRN_WITH_ZLIB=no
870if test "x$with_zlib" != "xno"; then
871  # TODO: Support custom zlib include and lib directory by --with-zlib.
872  AC_SEARCH_LIBS(compress, z,
873                 [
874                   GRN_WITH_ZLIB=yes
875                   AC_DEFINE(GRN_WITH_ZLIB, [1],
876                             [Support data compression by zlib.])
877                 ],
878                 [
879                   if test "x$with_zlib" != "xauto"; then
880                     AC_MSG_ERROR("No libz found")
881                   fi
882                 ])
883fi
884AC_SUBST(GRN_WITH_ZLIB)
885
886# LZ4
887AC_ARG_WITH(lz4,
888  [AS_HELP_STRING([--with-lz4],
889    [Support data compression by LZ4. [default=auto]])],
890  [with_lz4="$withval"],
891  [with_lz4="auto"])
892if test "x$with_lz4" != "xno"; then
893  m4_ifdef([PKG_CHECK_MODULES], [
894    PKG_CHECK_MODULES([LIBLZ4],
895                      [liblz4],
896                      [GRN_WITH_LZ4=yes],
897                      [GRN_WITH_LZ4=no])
898  ],
899  [GRN_WITH_LZ4=no])
900  if test "$GRN_WITH_LZ4" = "yes"; then
901    AC_DEFINE(GRN_WITH_LZ4, [1],
902              [Support data compression by LZ4.])
903  else
904    if test "x$with_lz4" != "xauto"; then
905      AC_MSG_ERROR("No liblz4 found")
906    fi
907  fi
908fi
909
910# Zstandard
911AC_ARG_WITH(zstd,
912  [AS_HELP_STRING([--with-zstd],
913    [Support data compression by Zstandard. [default=auto]])],
914  [with_zstd="$withval"],
915  [with_zstd="auto"])
916if test "x$with_zstd" != "xno"; then
917  m4_ifdef([PKG_CHECK_MODULES], [
918    PKG_CHECK_MODULES([LIBZSTD],
919                      [libzstd],
920                      [GRN_WITH_ZSTD=yes],
921                      [GRN_WITH_ZSTD=no])
922  ],
923  [GRN_WITH_ZSTD=no])
924  if test "$GRN_WITH_ZSTD" = "yes"; then
925    AC_DEFINE(GRN_WITH_ZSTD, [1],
926              [Support data compression by Zstandard.])
927  else
928    if test "x$with_zstd" != "xauto"; then
929      AC_MSG_ERROR("No libzstd found")
930    fi
931  fi
932fi
933
934# jemalloc
935AC_ARG_WITH(jemalloc,
936  [AS_HELP_STRING([--with-jemalloc],
937    [Use jemalloc for memory allocation. [default=no]])],
938  [with_jemalloc="$withval"],
939  [with_jemalloc="no"])
940jemalloc_available="no"
941if test "x$with_jemalloc" != "xno"; then
942  if test "x$with_jemalloc" != "xyes"; then
943    LDFLAGS="-L$with_jemalloc $LDFLAGS"
944  fi
945  AC_SEARCH_LIBS(malloc_conf, jemalloc,
946                 [jemalloc_available="yes"],
947                 [AC_MSG_ERROR("No libjemalloc found")])
948fi
949
950# Apache Arrow
951AC_ARG_ENABLE(arrow,
952  [AS_HELP_STRING([--disable-arrow],
953    [enable Apache Arrow support. [default=auto-detect]])],
954  [enable_arrow="$enableval"],
955  [enable_arrow="auto"])
956if test "x$enable_arrow" != "xno"; then
957  m4_ifdef([PKG_CHECK_MODULES], [
958    PKG_CHECK_MODULES([ARROW],
959                      [arrow >= 0.5.0],
960                      [arrow_available=yes],
961                      [arrow_available=no])
962  ],
963  [arrow_available=no])
964  if test "x$arrow_available" = "xyes"; then
965    AC_DEFINE(GRN_WITH_ARROW, [1], [Enable Apache Arrow support.])
966  else
967    if test "x$enable_arrow" = "xyes"; then
968      AC_MSG_ERROR("No Apache Arrow found")
969    fi
970  fi
971fi
972AM_CONDITIONAL([GRN_WITH_ARROW], [test "$arrow_available" = "yes"])
973
974# MeCab
975# NOTE: MUST be checked last
976
977BUNDLED_MECAB_VERSION=m4_include([bundled_mecab_version])
978AC_SUBST(BUNDLED_MECAB_VERSION)
979BUNDLED_MECAB_NAIST_JDIC_VERSION=m4_include([bundled_mecab_naist_jdic_version])
980AC_SUBST(BUNDLED_MECAB_NAIST_JDIC_VERSION)
981
982AC_ARG_WITH(mecab,
983  [AS_HELP_STRING([--with-mecab],
984    [use MeCab for morphological analysis. [default=yes]])],
985  [with_mecab="$withval"],
986  [with_mecab="yes"])
987AC_MSG_CHECKING([whether enable MeCab])
988AC_MSG_RESULT($with_mecab)
989if test "x$with_mecab" = "xyes"; then
990  # mecab-config
991  AC_ARG_WITH(mecab-config,
992    [AS_HELP_STRING([--with-mecab-config=PATH],
993      [set mecab-config location. [default=auto-detect]])],
994    [if test "$cross_compiling" = "yes"; then
995       MECAB_CONFIG="$withval"
996     else
997       AC_CHECK_FILE("$withval", MECAB_CONFIG="$withval", MECAB_CONFIG=no)
998     fi],
999    [AC_PATH_PROG(MECAB_CONFIG, mecab-config, no)])
1000  if test "x$MECAB_CONFIG" = "xno"; then
1001    with_mecab="no"
1002  else
1003    MECAB_CPPFLAGS="-I`$MECAB_CONFIG --inc-dir`"
1004    MECAB_LDFLAGS="-L`$MECAB_CONFIG --libs-only-L`"
1005    _SAVE_LIBS="$LIBS"
1006    _SAVE_LDFLAGS="$LDFLAGS"
1007    LDFLAGS="$LDFLAGS $MECAB_LDFLAGS"
1008    AC_SEARCH_LIBS(mecab_new,
1009                   mecab,
1010                   [MECAB_LIBS="-lmecab $PTHREAD_LIBS"],
1011                   [AC_MSG_ERROR("No libmecab found")],
1012                   $PTHREAD_LIBS)
1013    LDFLAGS="$_SAVE_LDFLAGS"
1014    LIBS="$_SAVE_LIBS"
1015    _SAVE_CPPFLAGS="$CPPFLAGS"
1016    CPPFLAGS="$CPPFLAGS $MECAB_CPPFLAGS"
1017    AC_CHECK_HEADER(mecab.h, , [AC_MSG_ERROR("No mecab.h found")])
1018    AC_CHECK_TYPE([mecab_dictionary_info_t],
1019                  [AC_DEFINE([HAVE_MECAB_DICTIONARY_INFO_T],
1020                             [1],
1021                             [Define to 1 if MeCab has the type `mecab_dictionary_info_t'.])],
1022                  [],
1023                  [[#include <mecab.h>]])
1024    CPPFLAGS="$_SAVE_CPPFLAGS"
1025    AC_SUBST(MECAB_CPPFLAGS)
1026    AC_SUBST(MECAB_LDFLAGS)
1027    AC_SUBST(MECAB_LIBS)
1028  fi
1029fi
1030if test "x$with_mecab" = "xyes"; then
1031  AC_DEFINE(GRN_WITH_MECAB, [1], [use MeCab])
1032fi
1033AM_CONDITIONAL(WITH_MECAB, test "x$with_mecab" = "xyes")
1034
1035# KyTea
1036REQUIRED_MINIMUM_KYTEA_VERSION=0.4.2
1037AC_ARG_WITH(kytea,
1038  [AS_HELP_STRING([--with-kytea],
1039    [use KyTea for morphological analysis. [default=auto]])],
1040  [with_kytea="$withval"],
1041  [with_kytea="auto"])
1042AC_MSG_CHECKING([whether enable KyTea])
1043AC_MSG_RESULT($with_kytea)
1044if test "x$with_kytea" != "xno"; then
1045  m4_ifdef([PKG_CHECK_MODULES], [
1046    PKG_CHECK_MODULES([KYTEA],
1047                      [kytea >= $REQUIRED_MINIMUM_KYTEA_VERSION],
1048                      [kytea_exists=yes],
1049                      [kytea_exists=no])
1050    ],
1051    [kytea_exists=no])
1052  if test "$kytea_exists" = "no" -a "x$with_kytea" = "xyes"; then
1053    AC_MSG_ERROR("No KyTea found.")
1054  fi
1055  with_kytea="$kytea_exists"
1056fi
1057if test "x$with_kytea" = "xyes"; then
1058  AC_DEFINE(GRN_WITH_KYTEA, [1], [use KyTea])
1059fi
1060AM_CONDITIONAL(WITH_KYTEA, test "x$with_kytea" = "xyes")
1061
1062# libstemmer
1063AC_ARG_WITH(libstemmer,
1064  [AS_HELP_STRING([--with-libstemmer],
1065    [use libstemmer for stemming. [default=auto]])],
1066  [with_libstemmer="$withval"],
1067  [with_libstemmer="auto"])
1068AC_ARG_WITH(libstemmer-include,
1069  [AS_HELP_STRING([--with-libstemmer-include],
1070    [path to libstemmer.h. [default=auto]])])
1071AC_ARG_WITH(libstemmer-lib,
1072  [AS_HELP_STRING([--with-libstemmer-lib],
1073    [path to libstemmer.so. [default=auto]])])
1074AC_MSG_CHECKING([whether enable libstemmer])
1075AC_MSG_RESULT($with_libstemmer)
1076if test "x$with_libstemmer" != "xno"; then
1077  LIBSTEMMER_CFLAGS=""
1078  LIBSTEMMER_LDFLAGS=""
1079  LIBSTEMMER_LIBS=""
1080
1081  CFLAGS_save="${CFLAGS}"
1082  LDFLAGS_save="${LDFLAGS}"
1083  if test "x$with_libstemmer" != "xauto"; then
1084    if test -z "${with_libstemmer_include}"; then
1085      with_libstemmer_include="${with_libstemmer}/include"
1086    fi
1087    LIBSTEMMER_CFLAGS="-I${with_libstemmer_include}"
1088    if test -z "${with_libstemmer_lib}"; then
1089      with_libstemmer_lib="${with_libstemmer}/lib"
1090    fi
1091    LIBSTEMMER_LDFLAGS="-L${with_libstemmer_lib}"
1092    CFLAGS="${CFLAGS} ${LIBSTEMMER_CFLAGS}"
1093    LDFLAGS="${LDFLAGS} ${LIBSTEMMER_LDFLAGS}"
1094  fi
1095  AC_CHECK_HEADERS(libstemmer.h,
1096                   [libstemmer_exists=yes],
1097                   [libstemmer_exists=no])
1098  if test "$libstemmer_exists" = "yes"; then
1099    AC_CHECK_LIB(stemmer, sb_stemmer_list,
1100                 [LIBSTEMMER_LIBS="-lstemmer"],
1101                 [libstemmer_exists=no])
1102  fi
1103  CFLAGS="${CFLAGS_save}"
1104  LDFLAGS="${LDFLAGS_save}"
1105
1106  if test "$libstemmer_exists" = "no" -a "x$with_libstemmer" != "xauto"; then
1107    AC_MSG_ERROR("No libstemmer found at ${with_libstemmer_include} and ${with_libstemmer_lib}.")
1108  fi
1109  with_libstemmer="$libstemmer_exists"
1110fi
1111if test "x$with_libstemmer" = "xyes"; then
1112  AC_SUBST(LIBSTEMMER_CFLAGS)
1113  AC_SUBST(LIBSTEMMER_LDFLAGS)
1114  AC_SUBST(LIBSTEMMER_LIBS)
1115  AC_DEFINE(GRN_WITH_LIBSTEMMER, [1], [use libstemmer])
1116fi
1117AM_CONDITIONAL(WITH_LIBSTEMMER, test "x$with_libstemmer" = "xyes")
1118
1119# futex check
1120AC_ARG_ENABLE(futex,
1121  [AS_HELP_STRING([--enable-futex],
1122    [use futex. [default=no]])],
1123  ,
1124  [enable_futex="no"])
1125if test "x$enable_futex" != "xno"; then
1126  AC_CHECK_HEADERS(linux/futex.h sys/syscall.h, [
1127    AC_DEFINE(USE_FUTEX, [1], [use futex])
1128  ], [
1129    AC_MSG_ERROR("linux/futex.h or sys/syscall.h not found")
1130  ])
1131fi
1132AC_MSG_CHECKING([whether enable futex])
1133AC_MSG_RESULT($enable_futex)
1134
1135# ZeroMQ
1136AC_ARG_ENABLE(zeromq,
1137  [AS_HELP_STRING([--disable-zeromq],
1138    [Disable ZeroMQ used for suggestion. [default=auto-detect]])],
1139  [enable_zeromq="$enableval"],
1140  [enable_zeromq="auto"])
1141if test "x$enable_zeromq" != "xno"; then
1142  m4_ifdef([PKG_CHECK_MODULES], [
1143    PKG_CHECK_MODULES([LIBZMQ],
1144                      [libzmq],
1145                      [zeromq_available=yes],
1146                      [zeromq_available=no])
1147    ],
1148    [zeromq_available=no])
1149  if test "x$zeromq_available" = "xyes"; then
1150    AC_DEFINE(GRN_WITH_ZEROMQ, [1], [Define to 1 if ZeroMQ is available.])
1151  else
1152    if test "x$enable_zeromq" = "xyes"; then
1153      AC_MSG_ERROR("No ZeroMQ found")
1154    fi
1155  fi
1156fi
1157
1158# libevent
1159AC_ARG_WITH(libevent,
1160  [AS_HELP_STRING([--without-libevent],
1161    [Disable libevent used for suggestion. [default=auto]])],
1162  [with_libevent="$withval"],
1163  [with_libevent="auto"])
1164
1165# workaround for bundled groonga in MariaDB.
1166if test "x$with_libevent" = "xbundled"; then
1167  with_libevent=no
1168fi
1169
1170if test "x$with_libevent" != "xno"; then
1171  if test "x$with_libevent" = "xyes" -o "x$with_libevent" = "xauto"; then
1172    libevent_cflags=""
1173    libevent_ldflags="-levent"
1174  else
1175    libevent_include_dir="$with_libevent/include"
1176    libevent_lib_dir="$with_libevent/lib"
1177    if ! test -d "$libevent_include_dir" -a -d "$libevent_lib_dir"; then
1178      AC_MSG_ERROR("No libevent found in $with_libevent.")
1179    fi
1180    libevent_cflags="-I$libevent_include_dir"
1181    libevent_ldflags="-L$libevent_lib_dir -levent"
1182  fi
1183
1184  _SAVE_CFLAGS="$CFLAGS"
1185  _SAVE_LDFLAGS="$LDFLAGS"
1186  _SAVE_LIBS="$LIBS"
1187  CFLAGS="$CFLAGS $libevent_cflags"
1188  LDFLAGS="$LDFLAGS $libevent_ldflags"
1189  AC_SEARCH_LIBS(event_init, event,
1190                 [libevent_available=yes],
1191                 [libevent_available=no])
1192  CFLAGS="$_SAVE_CFLAGS"
1193  LDFLAGS="$_SAVE_LDFLAGS"
1194  LIBS="$_SAVE_LIBS"
1195  if test "$libevent_available" = "yes"; then
1196    AC_DEFINE(GRN_WITH_LIBEVENT, [1], [Define to 1 if libevent is available.])
1197    LIBEVENT_CFLAGS="$libevent_cflags"
1198    LIBEVENT_LIBS="$libevent_ldflags"
1199  else
1200    if test "$enable_option_checking" != "no" -a "x$with_libevent" = "xyes"; then
1201      AC_MSG_ERROR("No libevent found")
1202    fi
1203  fi
1204fi
1205AC_SUBST(LIBEVENT_CFLAGS)
1206AC_SUBST(LIBEVENT_LIBS)
1207
1208# MessagePack
1209BUNDLED_MESSAGE_PACK_VERSION=m4_include([bundled_message_pack_version])
1210AC_SUBST(BUNDLED_MESSAGE_PACK_VERSION)
1211
1212AC_ARG_ENABLE(message-pack,
1213  [AS_HELP_STRING([--disable-message-pack],
1214    [Disable MessagePack support. [default=auto-detect]])],
1215  [enable_message_pack="$enableval"],
1216  [enable_message_pack="auto"])
1217if test "x$enable_message_pack" != "xno"; then
1218  m4_ifdef([PKG_CHECK_MODULES], [
1219    PKG_CHECK_MODULES([MESSAGE_PACK], [msgpack],
1220      [message_pack_available=yes],
1221      [message_pack_available=no])
1222    ],
1223    [message_pack_vailable=no])
1224
1225  if test "$message_pack_available" = "no"; then
1226    AC_ARG_WITH(message-pack,
1227      [AS_HELP_STRING([--with-message-pack],
1228        [Specify prefix where MessagePack is installed. [default=/usr]])],
1229      [with_message_pack="$withval"],
1230      [with_message_pack="/usr"])
1231    _SAVE_CFLAGS="$CFLAGS"
1232    _SAVE_LDFLAGS="$LDFLAGS"
1233    _SAVE_LIBS="$LIBS"
1234    CFLAGS="$CFLAGS -I$with_message_pack/include"
1235    LDFLAGS="$LDFLAGS -L$with_message_pack/lib"
1236    AC_SEARCH_LIBS(msgpack_version, msgpack,
1237                   [message_pack_available=yes],
1238                   [message_pack_available=no])
1239    CFLAGS="$_SAVE_CFLAGS"
1240    LDFLAGS="$_SAVE_LDFLAGS"
1241    LIBS="$_SAVE_LIBS"
1242
1243    if test "x$message_pack_available" = "xyes"; then
1244      MESSAGE_PACK_CFLAGS="-I$with_message_pack/include"
1245      MESSAGE_PACK_LIBS="-L$with_message_pack/lib -lmsgpackc"
1246    fi
1247  fi
1248
1249  if test "x$message_pack_available" = "xyes"; then
1250    AC_DEFINE(GRN_WITH_MESSAGE_PACK, [1],
1251              [Define to 1 if MessagePack is available.])
1252  else
1253    if test "x$enable_message_pack" = "xyes"; then
1254      AC_MSG_ERROR("No MessagePack found")
1255    fi
1256  fi
1257fi
1258AC_SUBST(MESSAGE_PACK_CFLAGS)
1259AC_SUBST(MESSAGE_PACK_LIBS)
1260
1261AM_CONDITIONAL([ENABLE_SUGGEST_LEARNER],
1262               [test "$zeromq_available" = "yes" -a \
1263                     "$libevent_available" = "yes" -a \
1264                     "$message_pack_available" = "yes"])
1265
1266# Check built-in atomic
1267case "$host" in
1268  i*86*|x86_64*)
1269    ;;
1270  *)
1271    AC_MSG_CHECKING([for platform which requires libatomic])
1272    AC_CHECK_LIB(atomic, __atomic_store_8, [ATOMIC_LIBS="-latomic"])
1273    AC_SUBST(ATOMIC_LIBS)
1274    ;;
1275esac
1276
1277# Document
1278AC_MSG_CHECKING([whether enable document])
1279AC_ARG_ENABLE(document,
1280  [AS_HELP_STRING([--enable-document],
1281    [enable document generation by Sphinx. [default=auto]])],
1282  [enable_document="$enableval"],
1283  [enable_document="auto"])
1284AC_MSG_RESULT($enable_document)
1285
1286document_available=no
1287document_buildable=no
1288have_built_document=no
1289if test x"$enable_document" != x"no"; then
1290  if test -f "$srcdir/doc/build-stamp"; then
1291    document_available=yes
1292    have_built_document=yes
1293  fi
1294
1295  if test x"$enable_document" = x"yes"; then
1296    AC_PATH_PROG(SPHINX_BUILD, sphinx-build, [])
1297    if test -n "$SPHINX_BUILD"; then
1298      sphinx_build_version=`"$SPHINX_BUILD" --version`
1299      if ! echo "$sphinx_build_version" | grep -q ' 1\.[[3-6]]'; then
1300        AC_MSG_ERROR([
1301sphinx-build is old: $sphinx_build_version
1302Sphinx 1.3 or later is required.])
1303      fi
1304      document_available=yes
1305      document_buildable=yes
1306    else
1307      AC_MSG_ERROR([
1308No sphinx-build found.
1309Install it and try again.
1310
1311How to install sphinx-build:
1312
1313For Debian GNU/Linux based system like Ubuntu:
1314  % sudo apt-get install -y python-sphinx
1315
1316For Red Hat based system like CentOS:
1317  % sudo yum install -y python-pip
1318  % sudo pip install sphinx
1319
1320For OS X with Homebrew:
1321  % brew install python
1322  % brew install gettext
1323  % export PATH="`brew --prefix gettext`/bin:\$PATH"
1324  % pip install sphinx])
1325    fi
1326    AC_SUBST(SPHINX_BUILD)
1327  fi
1328fi
1329
1330# Check for misc.
1331AC_ARG_WITH([cutter-source-path],
1332            AS_HELP_STRING([--with-cutter-source-path=PATH],
1333                           [Specify Cutter source path for
1334                            groonga's release manager.]),
1335                           [CUTTER_SOURCE_PATH="$withval"])
1336case "$CUTTER_SOURCE_PATH" in
1337  ""|/*)
1338    : # do nothing
1339    ;;
1340  *)
1341    CUTTER_SOURCE_PATH="\$(top_builddir)/${CUTTER_SOURCE_PATH}"
1342    ;;
1343esac
1344AC_SUBST(CUTTER_SOURCE_PATH)
1345
1346AM_CONDITIONAL([DOCUMENT_AVAILABLE],
1347               [test "${document_available}" = "yes"])
1348AC_MSG_CHECKING([whether document available])
1349AC_MSG_RESULT($document_available)
1350
1351AM_CONDITIONAL([DOCUMENT_BUILDABLE],
1352               [test "${document_buildable}" = "yes"])
1353AC_MSG_CHECKING([whether document buildable])
1354AC_MSG_RESULT($document_buildable)
1355
1356AM_CONDITIONAL([HAVE_BUILT_DOCUMENT],
1357               [test "${have_built_document}" = "yes"])
1358AC_MSG_CHECKING([whether having built document])
1359AC_MSG_RESULT($have_built_document)
1360
1361DOCUMENT_VERSION=groonga_version
1362DOCUMENT_VERSION_FULL="$GRN_VERSION"
1363AC_SUBST(DOCUMENT_VERSION)
1364AC_SUBST(DOCUMENT_VERSION_FULL)
1365
1366# Munin plugins
1367AC_MSG_CHECKING([whether install munin plugins])
1368AC_ARG_WITH(munin-plugins,
1369  [AS_HELP_STRING([--with-munin-plugins],
1370    [install Munin plugins. [default=no]])],
1371  [install_munin_plugins="$withval"],
1372  [install_munin_plugins="no"])
1373AC_MSG_RESULT($install_munin_plugins)
1374
1375AM_CONDITIONAL([INSTALL_MUNIN_PLUGINS],
1376               [test "${install_munin_plugins}" = "yes"])
1377
1378# platform
1379AC_MSG_CHECKING([whether package platform])
1380AC_ARG_WITH(package-platform,
1381  [AS_HELP_STRING([--with-package-platform=PLATFORM],
1382    [install package platform related files. [default=no]
1383     (supported package platforms: centos, centos5, centos6, centos7, fedora)])],
1384  [package_platform="$withval"],
1385  [package_platform="no"])
1386if test "$package_platform" = "centos"; then
1387  distribution=$(cut -d " " -f 1 /etc/redhat-release | tr "A-Z" "a-z")
1388  if grep -q Linux /etc/redhat-release; then
1389    distribution_version=$(cut -d " " -f 4 /etc/redhat-release)
1390  else
1391    distribution_version=$(cut -d " " -f 3 /etc/redhat-release)
1392  fi
1393  distribution_version=$(echo ${distribution_version} | sed -e 's/\..*$//g')
1394  package_platform="${package_platform}${distribution_version}"
1395fi
1396AC_MSG_RESULT($package_platform)
1397
1398AM_CONDITIONAL([CENTOS_PLATFORM],
1399               [test "${package_platform}" != "no"])
1400AM_CONDITIONAL([CENTOS_INIT_PLATFORM],
1401               [test "${package_platform}" = "centos5" ||
1402                test "${package_platform}" = "centos6"])
1403AM_CONDITIONAL([CENTOS_SYSTEMD_PLATFORM],
1404               [test "${package_platform}" = "centos7" ||
1405                test "${package_platform}" = "fedora"])
1406
1407# plugins check
1408relative_pluginsdir_base="\$(PACKAGE)/plugins"
1409AC_SUBST(relative_pluginsdir_base)
1410expanded_relative_pluginsdir_base="${PACKAGE}/plugins"
1411AC_SUBST(expanded_relative_pluginsdir_base)
1412
1413relative_pluginsdir="lib/\$(relative_pluginsdir_base)"
1414AC_SUBST(relative_pluginsdir)
1415
1416pluginsdir="\${libdir}/\$(relative_pluginsdir_base)"
1417AC_SUBST(pluginsdir)
1418expanded_pluginsdir="\${libdir}/${expanded_relative_pluginsdir_base}"
1419AC_SUBST(expanded_pluginsdir)
1420
1421tokenizer_pluginsdir="\${pluginsdir}/tokenizers"
1422AC_SUBST(tokenizer_pluginsdir)
1423
1424query_expander_pluginsdir="\${pluginsdir}/query_expanders"
1425AC_SUBST(query_expander_pluginsdir)
1426
1427suggest_pluginsdir="\${pluginsdir}/suggest"
1428AC_SUBST(suggest_pluginsdir)
1429
1430ruby_pluginsdir="\${pluginsdir}/ruby"
1431AC_SUBST(ruby_pluginsdir)
1432
1433token_filter_pluginsdir="\${pluginsdir}/token_filters"
1434AC_SUBST(token_filter_pluginsdir)
1435
1436sharding_pluginsdir="\${pluginsdir}/sharding"
1437AC_SUBST(sharding_pluginsdir)
1438
1439function_pluginsdir="\${pluginsdir}/functions"
1440AC_SUBST(function_pluginsdir)
1441
1442expression_rewriter_pluginsdir="\${pluginsdir}/expression_rewriters"
1443AC_SUBST(expression_rewriter_pluginsdir)
1444
1445AC_MSG_CHECKING(for the suffix of plugin shared libraries)
1446shrext_cmds=$(./libtool --config | grep '^shrext_cmds=')
1447eval $shrext_cmds
1448module=yes eval suffix="$shrext_cmds"
1449AC_MSG_RESULT($suffix)
1450if test -z "$suffix"; then
1451  AC_MSG_ERROR([can't detect plugin suffix])
1452fi
1453AC_DEFINE_UNQUOTED(GRN_PLUGIN_SUFFIX, ["$suffix"], "plugin suffix")
1454
1455# for query expanders
1456GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE_BASE="synonyms.tsv"
1457GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE="etc/${PACKAGE}/${GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE_BASE}"
1458AC_DEFINE_UNQUOTED(GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE,
1459                   ["$GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE"],
1460                   "The relative synonyms file for TSV query expander")
1461GRN_QUERY_EXPANDER_TSV_SYNONYMS_PATH="`
1462  eval echo ${sysconfdir}/${PACKAGE}/${GRN_QUERY_EXPANDER_TSV_RELATIVE_SYNONYMS_FILE_BASE}
1463`"
1464AC_DEFINE_UNQUOTED(GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE,
1465                   ["$GRN_QUERY_EXPANDER_TSV_SYNONYMS_PATH"],
1466                   "The default synonyms file for TSV query expander")
1467
1468# for examples
1469examplesdir="\$(pkgdatadir)/examples"
1470AC_SUBST(examplesdir)
1471
1472examples_dictionarydir="\$(examplesdir)/dictionary"
1473AC_SUBST(examples_dictionarydir)
1474
1475# for ruby scripts
1476relative_ruby_scriptsdir_base="\$(PACKAGE)/scripts/ruby"
1477AC_SUBST(relative_ruby_scriptsdir_base)
1478relative_ruby_scriptsdir="lib/\$(relative_ruby_scriptsdir_base)"
1479AC_SUBST(relative_ruby_scriptsdir)
1480ruby_scriptsdir="\${libdir}/\$(relative_ruby_scriptsdir_base)"
1481AC_SUBST(ruby_scriptsdir)
1482
1483# for document root
1484GRN_DEFAULT_DOCUMENT_ROOT_BASE="html/admin"
1485GRN_DEFAULT_DOCUMENT_ROOT="\${pkgdatadir}/\${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
1486GRN_EXPANDED_DEFAULT_DOCUMENT_ROOT="\${datadir}/${PACKAGE}/${GRN_DEFAULT_DOCUMENT_ROOT_BASE}"
1487GRN_DEFAULT_RELATIVE_DOCUMENT_ROOT="share/\$(PACKAGE)/\$(GRN_DEFAULT_DOCUMENT_ROOT_BASE)"
1488AC_SUBST(GRN_DEFAULT_DOCUMENT_ROOT_BASE)
1489AC_SUBST(GRN_DEFAULT_DOCUMENT_ROOT)
1490AC_SUBST(GRN_EXPANDED_DEFAULT_DOCUMENT_ROOT)
1491AC_SUBST(GRN_DEFAULT_RELATIVE_DOCUMENT_ROOT)
1492
1493# flags for compile groonga
1494GRN_CFLAGS=""
1495AC_SUBST(GRN_CFLAGS)
1496GRN_DEFS=""
1497GRN_DEFS="$GRN_DEFS -DGRN_DLL_FILENAME=L\\\"\"\$(GRN_DLL_FILENAME)\"\\\""
1498GRN_DEFS="$GRN_DEFS -DGRN_PLUGINS_DIR=\\\"\"\$(pluginsdir)\"\\\""
1499GRN_DEFS="$GRN_DEFS -DGRN_RELATIVE_PLUGINS_DIR=\\\"\"\$(relative_pluginsdir)\"\\\""
1500GRN_DEFS="$GRN_DEFS -DGRN_RUBY_SCRIPTS_DIR=\\\"\"\$(ruby_scriptsdir)\"\\\""
1501GRN_DEFS="$GRN_DEFS -DGRN_RELATIVE_RUBY_SCRIPTS_DIR=\\\"\"\$(relative_ruby_scriptsdir)\"\\\""
1502GRN_DEFS="$GRN_DEFS -DGRN_LOG_PATH=\\\"\"\$(grn_log_path)\"\\\""
1503GRN_DEFS="$GRN_DEFS -DGRN_DEFAULT_DOCUMENT_ROOT=\\\"\"\$(GRN_DEFAULT_DOCUMENT_ROOT)\"\\\""
1504GRN_DEFS="$GRN_DEFS -DGRN_DEFAULT_RELATIVE_DOCUMENT_ROOT=\\\"\"\$(GRN_DEFAULT_RELATIVE_DOCUMENT_ROOT)\"\\\""
1505AC_SUBST(GRN_DEFS)
1506CFLAGS="$CFLAGS $OPT_CFLAGS "
1507LIBS="$LIBS $WINDOWS_LIBS"
1508AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS, "$ac_configure_args", "specified configure options")
1509
1510# For groonga.org
1511AC_ARG_WITH(groonga-org-path,
1512            [AS_HELP_STRING([--with-groonga-org-path=PATH],
1513              [specify a path of the groonga.org repository to update groonga.org.])],
1514            [GROONGA_ORG_PATH="$withval"],
1515            [GROONGA_ORG_PATH=""])
1516AC_SUBST(GROONGA_ORG_PATH)
1517
1518# groonga-httpd
1519NGINX_VERSION=m4_include([nginx_version])
1520AC_SUBST(NGINX_VERSION)
1521
1522# groonga-httpd binary path
1523GROONGA_HTTPD="${ac_pwd}/vendor/nginx-${NGINX_VERSION}/objs/nginx"
1524AC_SUBST(GROONGA_HTTPD)
1525
1526AC_ARG_ENABLE(groonga_httpd,
1527  [AS_HELP_STRING([--enable-groonga-httpd],
1528    [enable nginx used for groonga-httpd. [default=yes]])],
1529  [enable_groonga_httpd="$enableval"],
1530  [enable_groonga_httpd="yes"])
1531if test "x$enable_groonga_httpd" != "xno"; then
1532  enable_groonga_httpd="yes"
1533  AC_CONFIG_SUBDIRS([src/httpd])
1534else
1535  enable_groonga_httpd="no"
1536fi
1537AM_CONDITIONAL(WITH_GROONGA_HTTPD, test "$enable_groonga_httpd" = "yes")
1538
1539GROONGA_HTTPD_PID_PATH="`
1540  test \"$prefix\" = NONE && prefix=/usr/local
1541  eval echo ${localstatedir}/run/groonga/groonga-httpd.pid
1542`"
1543AC_SUBST(GROONGA_HTTPD_PID_PATH)
1544
1545# mruby
1546AC_ARG_ENABLE(mruby,
1547  [AS_HELP_STRING([--enable-mruby],
1548    [enable mruby. [default=no]])],
1549  [enable_mruby="$enableval"],
1550  [enable_mruby="no"])
1551
1552AC_MSG_CHECKING([whether enable mruby])
1553if test "x$enable_mruby" != "xyes"; then
1554  enable_mruby="no"
1555fi
1556AC_MSG_RESULT($enable_mruby)
1557
1558if test "$enable_mruby" = "yes"; then
1559  if test ! -f "$srcdir/vendor/mruby/mruby_build.timestamp" -a \
1560          "$ac_cv_ruby_available" != "yes"; then
1561    AC_MSG_ERROR(--enable-mruby requires --with-ruby)
1562  fi
1563  AC_DEFINE(GRN_WITH_MRUBY, [1], [Define to 1 if mruby is enabled.])
1564  MRUBY_CFLAGS="-I\$(top_srcdir)/vendor/mruby-source/include"
1565  GRN_WITH_MRUBY="yes"
1566else
1567  MRUBY_CFLAGS=""
1568fi
1569AC_SUBST(GRN_WITH_MRUBY)
1570AC_SUBST(MRUBY_CFLAGS)
1571AM_CONDITIONAL(WITH_MRUBY, test "$enable_mruby" = "yes")
1572
1573MRUBY_CPPFLAGS="-DMRB_INT64"
1574AC_SUBST(MRUBY_CPPFLAGS)
1575
1576# This option is used in vendor/onigmo/configure
1577AC_ARG_ENABLE(shared-onigmo,
1578  [AS_HELP_STRING([--enable-shared-onigmo],
1579    [use Onigmo as shared library instead of static library. [default=no]])],
1580  [enable_shared_onigmo="$enableval"],
1581  [enable_shared_onigmo="no"])
1582AM_CONDITIONAL(WITH_SHARED_ONIGMO, test "$enable_shared_onigmo" = "yes")
1583
1584AC_ARG_WITH(onigmo,
1585  [AS_HELP_STRING([--without-onigmo],
1586    [Don't Use Onigmo. [default=bundled]])],
1587  [with_onigmo="$withval"],
1588  [with_onigmo="bundled"])
1589if test "x$with_onigmo" != "xno"; then
1590  GRN_WITH_ONIGMO="yes"
1591  if test "x$with_onigmo" != "xbundled"; then
1592    m4_ifdef([PKG_CHECK_MODULES], [
1593      PKG_CHECK_MODULES([ONIGMO], [onigmo],
1594        [have_onigmo=yes],
1595        [have_onigmo=no])
1596      ],
1597      [have_onigmo=no])
1598  fi
1599  if test "x$with_onigmo" = "xsystem" -a "$have_onigmo" = "no"; then
1600    AC_MSG_ERROR("No Onigmo found")
1601  fi
1602  if test "x$with_onigmo" = "xbundled" -o "$have_onigmo" = "no"; then
1603    AC_CONFIG_SUBDIRS([vendor/onigmo])
1604    ONIGMO_CFLAGS="-I\$(top_srcdir)/vendor/onigmo-source"
1605    ONIGMO_LIBS="\$(top_builddir)/vendor/onigmo-source/libonigmo.la"
1606  fi
1607  AC_DEFINE(GRN_WITH_ONIGMO, [1], [Use Onigmo.])
1608else
1609  GRN_WITH_ONIGMO="no"
1610fi
1611AC_SUBST(GRN_WITH_ONIGMO)
1612AC_SUBST(ONIGMO_CFLAGS)
1613AC_SUBST(ONIGMO_LIBS)
1614AM_CONDITIONAL(WITH_BUNDLED_ONIGMO, test "$with_onigmo" != "no" -a "x$have_onigmo" != "xyes")
1615
1616# PCRE
1617GRN_WITH_PCRE=no
1618AC_ARG_WITH(pcre,
1619  [AS_HELP_STRING([--without-pcre],
1620    [Don't use PCRE for groonga-httpd. [default=auto-detect]])],
1621  [with_pcre="$withval"],
1622  [with_pcre="auto"])
1623if test "x$with_pcre" != "xno"; then
1624  m4_ifdef([PKG_CHECK_MODULES], [
1625    PKG_CHECK_MODULES([PCRE], [libpcre],
1626      [_PKG_CONFIG(PCRE_LIBS_ONLY_L, [libs-only-L], [libpcre])
1627       PCRE_LIBS_ONLY_L="$pkg_cv_PCRE_LIBS_ONLY_L"
1628       GRN_WITH_PCRE=yes],
1629      [GRN_WITH_PCRE=no])
1630    ],
1631    [GRN_WITH_PCRE=no])
1632  if test "x$with_pcre" = "xyes" -a "$GRN_WITH_PCRE" != "yes"; then
1633    AC_MSG_ERROR("No PCRE found")
1634  fi
1635fi
1636AC_SUBST(GRN_WITH_PCRE)
1637AC_SUBST(PCRE_CFLAGS)
1638AC_SUBST(PCRE_LIBS_ONLY_L)
1639
1640# SSL
1641GRN_WITH_SSL=no
1642AC_ARG_WITH(ssl,
1643  [AS_HELP_STRING([--without-ssl],
1644    [Don't use SSL module for groonga-httpd. [default=auto-detect]])],
1645  [with_ssl="$withval"],
1646  [with_ssl="auto"])
1647if test "x$with_ssl" != "xno"; then
1648  m4_ifdef([PKG_CHECK_MODULES], [
1649    PKG_CHECK_MODULES([SSL], [libssl],
1650      [_PKG_CONFIG(SSL_LIBS_ONLY_L, [libs-only-L], [libssl])
1651       SSL_LIBS_ONLY_L="$pkg_cv_SSL_LIBS_ONLY_L"
1652       GRN_WITH_SSL=yes],
1653      [GRN_WITH_SSL=no])
1654    ],
1655    [GRN_WITH_SSL=no])
1656  if test "x$with_ssl" = "xyes" -a "$GRN_WITH_SSL" != "yes"; then
1657    AC_MSG_ERROR("No SSL found")
1658  fi
1659fi
1660AC_SUBST(GRN_WITH_SSL)
1661AC_SUBST(SSL_CFLAGS)
1662AC_SUBST(SSL_LIBS_ONLY_L)
1663
1664# For package
1665AC_ARG_WITH(rsync-path,
1666            [AS_HELP_STRING([--with-rsync-path=PATH],
1667            [specify rsync path to upload groonga packages.])],
1668            [RSYNC_PATH="$withval"],
1669            [RSYNC_PATH="packages@packages.groonga.org:public"])
1670AC_SUBST(RSYNC_PATH)
1671
1672AC_ARG_WITH(launchpad-ppa,
1673            [AS_HELP_STRING([--with-launchpad-ppa=PPA],
1674            [specify Launchpad Personal Package Archive. [default=groonga-ppa]])],
1675            [LAUNCHPAD_PPA="$withval"],
1676            [LAUNCHPAD_PPA="groonga-ppa"])
1677AC_SUBST(LAUNCHPAD_PPA)
1678
1679AC_ARG_WITH(launchpad-uploader-pgp-key,
1680            [AS_HELP_STRING([--with-launchpad-uploader-pgp-key=KEY],
1681            [specify PGP key UID to upload Groonga packages to Launchpad.])],
1682            [LAUNCHPAD_UPLOADER_PGP_KEY="$withval"],
1683            [LAUNCHPAD_UPLOADER_PGP_KEY=""])
1684AC_SUBST(LAUNCHPAD_UPLOADER_PGP_KEY)
1685
1686GPG_UID=m4_include(gpg_uid)
1687AC_SUBST(GPG_UID)
1688
1689pkgsysconfdir="\${sysconfdir}/$PACKAGE_NAME"
1690AC_SUBST(pkgsysconfdir)
1691
1692GRN_CONFIG_PATH="`
1693  test \"$prefix\" = NONE && prefix=/usr/local
1694  eval echo ${sysconfdir}/groonga/groonga.conf
1695`"
1696AC_DEFINE_UNQUOTED(GRN_CONFIG_PATH, ["$GRN_CONFIG_PATH"],
1697  [Default command line option configuration file.])
1698
1699GROONGA_HTTPD_DOCUMENT_ROOT="`
1700  test \"$prefix\" = NONE && prefix=/usr/local
1701  eval eval eval echo ${GRN_EXPANDED_DEFAULT_DOCUMENT_ROOT}
1702`"
1703AC_SUBST(GROONGA_HTTPD_DOCUMENT_ROOT)
1704
1705GROONGA_HTTPD_DEFAULT_DATABASE_PATH="`
1706  test \"$prefix\" = NONE && prefix=/usr/local
1707  eval eval eval echo ${localstatedir}/lib/${PACKAGE}/db/db
1708`"
1709AC_SUBST(GROONGA_HTTPD_DEFAULT_DATABASE_PATH)
1710
1711AC_OUTPUT([
1712  lib/metadata.rc
1713  packages/rpm/centos/groonga.spec
1714  packages/apt/debian/groonga-keyring.postrm
1715  packages/apt/env.sh
1716  packages/yum/env.sh
1717  groonga.pc
1718  groonga-arrow.pc
1719  config.sh
1720  groonga-httpd-conf.sh
1721  data/groonga-httpd.conf
1722  data/logrotate.d/centos/groonga-httpd
1723  data/scripts/groonga-httpd-restart
1724  data/systemd/centos/groonga-httpd.service
1725  ])
1726
1727echo "$PACKAGE_NAME $PACKAGE_VERSION configuration:"
1728echo "-----------------------"
1729echo "  Compiler:              ${CC}"
1730echo "  CFLAGS:                ${CFLAGS}"
1731echo "  CXXFLAGS:              ${CXXFLAGS}"
1732echo "  Libraries:             ${LIBS}"
1733echo "  Stack size:            ${GRN_STACK_SIZE}"
1734echo "  Document:              ${document_available}"
1735echo "    buildable:           ${document_buildable}"
1736echo "    built:               ${have_built_document}"
1737echo "  Munin plugins:         ${install_munin_plugins}"
1738echo "  Package platform:      ${package_platform}"
1739echo
1740echo "Paths:"
1741echo "  Install path prefix:   ${prefix}"
1742echo "  Configuration file:    ${GRN_CONFIG_PATH}"
1743echo
1744
1745echo "Tokenizers:"
1746echo "  MeCab:                 $with_mecab"
1747if test "x$with_mecab" = "xyes"; then
1748  echo "    CPPFLAGS:            $MECAB_CPPFLAGS"
1749  echo "    LDFLAGS:             $MECAB_LDFLAGS"
1750  echo "    LIBS:                $MECAB_LIBS"
1751fi
1752echo "  KyTea:                 $with_kytea"
1753if test "x$with_kytea" = "xyes"; then
1754  echo "    CFLAGS:              $KYTEA_CFLAGS"
1755  echo "    LIBS:                $KYTEA_LIBS"
1756fi
1757echo
1758
1759echo "Token filters:"
1760echo "  libstemmer:            $with_libstemmer"
1761if test "x$with_libstemmer" = "xyes"; then
1762  echo "    CFLAGS:              $LIBSTEMMER_CFLAGS"
1763  echo "    LIBS:                $LIBSTEMMER_LIBS"
1764fi
1765echo
1766
1767echo "Libraries:"
1768echo "  ZeroMQ:                $zeromq_available"
1769if test "x$zeromq_available" = "xyes"; then
1770  echo "    CFLAGS:              ${LIBZMQ_CFLAGS}"
1771  echo "    LIBS:                ${LIBZMQ_LIBS}"
1772fi
1773echo "  libevent:              $libevent_available"
1774if test "x$libevent_available" = "xyes"; then
1775  echo "    CFLAGS:              ${LIBEVENT_CFLAGS}"
1776  echo "    LIBS:                ${LIBEVENT_LIBS}"
1777fi
1778echo "  MessagePack:           $message_pack_available"
1779if test "x$message_pack_available" = "xyes"; then
1780  echo "    CFLAGS:              ${MESSAGE_PACK_CFLAGS}"
1781  echo "    LIBS:                ${MESSAGE_PACK_LIBS}"
1782fi
1783echo "  mruby:                 $enable_mruby"
1784echo "  jemalloc:              $jemalloc_available"
1785echo
1786
1787echo "groonga-httpd:"
1788echo "  enable:                $enable_groonga_httpd"
1789if test "$enable_groonga_httpd" = "yes"; then
1790  echo "  default database path: $GROONGA_HTTPD_DEFAULT_DATABASE_PATH"
1791  echo "  PCRE:                  $GRN_WITH_PCRE"
1792  if test "$GRN_WITH_PCRE" = "yes"; then
1793    echo "    CFLAGS:              $PCRE_CFLAGS"
1794    echo "    LIBS only -L:        $PCRE_LIBS_ONLY_L"
1795  fi
1796  echo "   SSL:                  $GRN_WITH_SSL"
1797  if test "$GRN_WITH_SSL" = "yes"; then
1798    echo "    CFLAGS:              $SSL_CFLAGS"
1799    echo "    LIBS only -L:        $SSL_LIBS_ONLY_L"
1800  fi
1801fi
1802echo
1803
1804echo "Tools:"
1805echo "  Sphinx:                ${SPHINX_BUILD}"
1806echo "  lemon:                 ${LEMON}"
1807echo "  Ruby:                  ${RUBY}"
1808echo "  Cutter:                ${CUTTER}"
1809echo
1810
1811echo "For packages:"
1812echo "  rsync path:            ${RSYNC_PATH}"
1813echo "  Launchpad PGP key:     ${LAUNCHPAD_UPLOADER_PGP_KEY}"
1814echo "  GPG UID:               ${GPG_UID}"
1815echo
1816
1817echo "Now type 'make' to build $PACKAGE_NAME $PACKAGE_VERSION!"
1818