summaryrefslogtreecommitdiff
path: root/storage/mroonga/configure.ac
blob: 48312a44c8c56e87d06741db0693864ccc6d9845 (plain)
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
AC_PREREQ(2.59)

m4_define([mrn_version_major],  m4_include(version_major))
m4_define([mrn_version_minor],  m4_include(version_minor))
m4_define([mrn_version_micro],  m4_include(version_micro))
m4_define([mrn_version],        m4_include(version))
m4_define([mrn_version_in_hex], m4_include(version_in_hex))
m4_define([mrn_plugin_version], m4_include(plugin_version))

AC_INIT([mroonga], [mrn_version], [groonga-talk@lists.sourceforge.net])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE([tar-pax foreign subdir-objects])

MRN_VERSION=mrn_version
MRN_VERSION_MAJOR=mrn_version_major
MRN_VERSION_MINOR=mrn_version_minor
MRN_VERSION_MICRO=mrn_version_micro
MRN_VERSION_IN_HEX=mrn_version_in_hex
MRN_PLUGIN_VERSION=mrn_plugin_version
AC_SUBST([MRN_VERSION])
AC_SUBST([MRN_VERSION_MAJOR])
AC_SUBST([MRN_VERSION_MINOR])
AC_SUBST([MRN_VERSION_MICRO])
AC_SUBST([MRN_VERSION_IN_HEX])
AC_SUBST([MRN_PLUGIN_VERSION])

MRN_PACKAGE_STRING="$PACKAGE_STRING"
AC_SUBST([MRN_PACKAGE_STRING])

MRN_BUNDLED=FALSE
AC_SUBST([MRN_BUNDLED])

AC_C_BIGENDIAN
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_LIBTOOL
m4_ifdef([LT_OUTPUT], [LT_OUTPUT])

AC_DEFUN([CHECK_CFLAG], [
  AC_MSG_CHECKING([if gcc supports $1])
  old_CFLAGS=$CFLAGS
  flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
  CFLAGS="$CFLAGS $flag -Werror"
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
    [check_cflag=yes],
    [check_cflag=no])
  CFLAGS="$old_CFLAGS"
  if test "x$check_cflag" = "xyes"; then
    CFLAGS="$CFLAGS $1"
  fi
  AC_MSG_RESULT([$check_cflag])
])

AC_DEFUN([CHECK_CXXFLAG], [
  AC_MSG_CHECKING([if g++ supports $1])
  old_CXXFLAGS=$CXXFLAGS
  flag=`echo '$1' | sed -e 's,^-Wno-,-W,'`
  CXXFLAGS="$CXXFLAGS $flag -Werror"
  AC_LANG_PUSH([C++])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
    [check_cxxflag=yes],
    [check_cxxflag=no])
  AC_LANG_POP([C++])
  CXXFLAGS="$old_CXXFLAGS"
  if test "x$check_cxxflag" = "xyes"; then
    CXXFLAGS="$CXXFLAGS $1"
  fi
  AC_MSG_RESULT([$check_cxxflag])
])

AC_DEFUN([CHECK_BUILD_FLAG], [
  CHECK_CFLAG([$1])
  CHECK_CXXFLAG([$1])
])

if test "$GCC" = "yes"; then
  CHECK_BUILD_FLAG([-Wall])
  CHECK_BUILD_FLAG([-Wextra])
  CHECK_BUILD_FLAG([-Wno-unused-parameter])
  CHECK_BUILD_FLAG([-Wno-strict-aliasing])
  # REMOVEME: workaround for MySQL/MariaDB 5.5.22 :<
  # They use deprecated MYSQL::generate_name style in class definition.
  CHECK_BUILD_FLAG([-Wno-deprecated])
fi

AC_MSG_CHECKING(for the suffix of plugin shared libraries)
shrext_cmds=$(./libtool --config | grep '^shrext_cmds=')
eval $shrext_cmds
module=yes eval MRN_PLUGIN_SUFFIX="$shrext_cmds"
AC_MSG_RESULT($MRN_PLUGIN_SUFFIX)
if test -z "$MRN_PLUGIN_SUFFIX"; then
  AC_MSG_ERROR([can't detect plugin suffix])
fi
AC_SUBST(MRN_PLUGIN_SUFFIX)

AC_ARG_WITH(libmysqlservices-compat,
  [AS_HELP_STRING([--with-libmysqlservices-compat],
                  [Use libmysqlservices compatible library for missing libmysqlservices.a])
  ],
  [with_libmysqlservices_compat=$withval],
  [with_libmysqlservices_compat=no])
AM_CONDITIONAL([WITH_LIBMYSQLSERVICES_COMPAT], [test "${with_libmysqlservices_compat}" != "no"])

AC_DEFUN([CONFIG_OPTION_MYSQL],[
  AC_MSG_CHECKING([mysql source])

  ac_mysql_source_dir=
  AC_ARG_WITH([mysql-source],
    [AS_HELP_STRING([--with-mysql-source=PATH], [MySQL source directory PATH])],
    [
      ac_mysql_source_dir="$withval"
      if test -f "$ac_mysql_source_dir/sql/handler.h"; then
        case "$ac_mysql_source_dir" in
        /*)
            :
            ;;
        *)
            ac_mysql_source_dir="$ac_pwd/$ac_mysql_source_dir"
            ;;
        esac
        AC_MSG_RESULT([yes])
      else
        AC_MSG_ERROR([invalid MySQL source directory])
      fi
    ],
    [AC_MSG_ERROR([--with-mysql-source=PATH is required])]
  )
  MYSQL_SOURCE_DIR="$ac_mysql_source_dir"
  AC_SUBST(MYSQL_SOURCE_DIR)

  ac_mysql_build_dir=
  AC_ARG_WITH([mysql-build],
    [AS_HELP_STRING([--with-mysql-build=PATH], [MySQL build directory PATH])],
    [ac_mysql_build_dir="$withval"],
    [ac_mysql_build_dir="$ac_mysql_source_dir"]
  )
  case "$ac_mysql_build_dir" in
  /*)
      :
      ;;
  *)
      ac_mysql_build_dir="$ac_pwd/$ac_mysql_build_dir"
      ;;
  esac
  MYSQL_BUILD_DIR="$ac_mysql_build_dir"
  AC_SUBST(MYSQL_BUILD_DIR)

  AC_MSG_CHECKING([mysql_config])
  AC_ARG_WITH([mysql-config],
    [AS_HELP_STRING([--with-mysql-config=PATH],
                    [mysql_config PATH])],
    [ac_mysql_config="$withval"],
    [ac_mysql_config=])
  if test -z "$ac_mysql_config"; then
    AC_PATH_PROG(ac_mysql_config, mysql_config, mysql-config-not-found)
  fi
  if test "$ac_mysql_config" = "mysql-config-not-found"; then
    AC_MSG_ERROR([can't detect mysql_config. Please specify mysql_config path by --with-mysql-config=PATH.])
  fi
  AC_MSG_RESULT([$ac_mysql_config])

  plugindir="$($ac_mysql_config --plugindir)"
  if test $? -ne 0; then
    AC_MSG_ERROR([failed to run "$ac_mysql_config": $plugindir])
  fi
  AC_SUBST(plugindir)

  MYSQL_CFLAGS="$MYSQL_CFLAGS $($ac_mysql_config --cflags)"
  AC_SUBST(MYSQL_CFLAGS)

  MYSQL_INCLUDES=""
  MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_build_dir/include"
  MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/sql"
  MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir/include"
  if test -d "$ac_mysql_source_dir/pcre"; then
    mysql_regex_include_dir="$ac_mysql_source_dir/pcre"
  else
    mysql_regex_include_dir="$ac_mysql_source_dir/regex"
  fi
  MYSQL_INCLUDES="$MYSQL_INCLUDES -I$mysql_regex_include_dir"
  MYSQL_INCLUDES="$MYSQL_INCLUDES -I$ac_mysql_source_dir"
  MYSQL_INCLUDES="$MYSQL_INCLUDES $($ac_mysql_config --include)"
  AC_SUBST(MYSQL_INCLUDES)

  MYSQL_VERSION="$($ac_mysql_config --version)"
  AC_SUBST(MYSQL_VERSION)

  if test "${with_libmysqlservices_compat}" = "no"; then
    MYSQL_MAJOR_MINOR_VERSION=["$(echo $MYSQL_VERSION | sed -e 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*[a-z]*\)$/\1.\2/')"]
    case "$MYSQL_MAJOR_MINOR_VERSION" in
    5.1)
        MYSQL_LIBS=""
        ;;
    *)
        AC_MSG_CHECKING([for libmysqlservices.a directory])
        pkglibdir="$($ac_mysql_config --variable=pkglibdir)"
        mysql_build_libservices_dir="${MYSQL_BUILD_DIR}/libservices"
        if test -f "${mysql_build_libservices_dir}/libmysqlservices.a"; then
          mysql_services_lib_dir="${mysql_build_libservices_dir}"
        else
          if test -f "${pkglibdir}/libmysqlservices.a"; then
            mysql_services_lib_dir="${pkglibdir}"
          elif test -f "${pkglibdir}/mysql/libmysqlservices.a"; then
            mysql_services_lib_dir="${pkglibdir}/mysql"
          else
            AC_MSG_ERROR([libmysqlservices.a is not found in <${pkglibdir}/> and <${pkglibdir}/mysql/>])
          fi
        fi
        AC_MSG_RESULT([$mysql_services_lib_dir])
        MYSQL_LIBS="$MYSQL_LIBS -L\"$mysql_services_lib_dir\" -lmysqlservices"
        ;;
    esac
    AC_SUBST(MYSQL_LIBS)
  fi
])

m4_define([mrn_required_groonga_version], m4_include(required_groonga_version))
REQUIRED_GROONGA_VERSION=mrn_required_groonga_version
AC_SUBST(REQUIRED_GROONGA_VERSION)
AC_DEFUN([CONFIG_OPTION_GROONGA],[
  PKG_CHECK_MODULES(GROONGA, groonga >= ${REQUIRED_GROONGA_VERSION})
  _PKG_CONFIG(GROONGA_VERSION, variable=groonga_version, groonga)
  GROONGA_VERSION=$pkg_cv_GROONGA_VERSION
  AC_SUBST(GROONGA_VERSION)
])

m4_define([mrn_required_groonga_normalizer_mysql_version],
          m4_include(required_groonga_normalizer_mysql_version))
REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION=mrn_required_groonga_normalizer_mysql_version
AC_DEFUN([CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL], [
  AC_MSG_CHECKING([for groonga-normalizer-mysql])
  PKG_CHECK_EXISTS([groonga-normalizer-mysql >= ${REQUIRED_GROONGA_NORMALIZER_MYSQL_VERSION}],
                   [WITH_GROONGA_NORMALIZER_MYSQL=yes],
                   [WITH_GROONGA_NORMALIZER_MYSQL=no])
  AC_MSG_RESULT($WITH_GROONGA_NORMALIZER_MYSQL)
  if test "$WITH_GROONGA_NORMALIZER_MYSQL" = "yes"; then
    AC_DEFINE([WITH_GROONGA_NORMALIZER_MYSQL],
              [1],
              [Use MySQL normalizer plugin for groonga])
    _PKG_CONFIG(plugin_name, variable=plugin_name, groonga-normalizer-mysql)
    GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME=$pkg_cv_plugin_name
    AC_DEFINE_UNQUOTED([GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME],
                       "${GROONGA_NORMALIZER_MYSQL_PLUGIN_NAME}",
                       [Name of MySQL normalizer plugin for groonga])
  fi
])

AC_ARG_WITH(debug,
    [dnl
AS_HELP_STRING([--with-debug],
               [Add debug code])
AS_HELP_STRING([--with-debug=full],
               [Add debug code (adds memory checker, very slow)])dnl
    ],
    [with_debug=$withval],
    [with_debug=no])
if test "$with_debug" = "yes"
then
  # Medium debug.
  AC_DEFINE([DBUG_ON], [1], [Use libdbug])
  CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS -O0 -g3"
  CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS -O0 -g3"
elif test "$with_debug" = "full"
then
  # Full debug. Very slow in some cases
  AC_DEFINE([DBUG_ON], [1], [Use libdbug])
  CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS -O0 -g3"
  CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS -O0 -g3"
else
  # Optimized version. No debug
  AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug])
  CFLAGS="$OPTIMIZE_CFLAGS $CFLAGS"
  CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS"
fi

AC_ARG_WITH(valgrind,
  [AS_HELP_STRING([--with-valgrind], [Use valgrind. [default=no]])],
  [with_valgrind="$withval"],
  [with_valgrind="no"])
if test "$with_valgrind" != "no"; then
  CFLAGS="-DHAVE_valgrind $CFLAGS"
  CXXFLAGS="-DHAVE_valgrind $CXXFLAGS"
fi

CONFIG_OPTION_MYSQL
CONFIG_OPTION_GROONGA
CONFIG_OPTION_GROONGA_NORMALIZER_MYSQL

AC_ARG_WITH(default_parser,
    [AS_HELP_STRING([--with-default-parser=PARSER],
                    [specify the default fulltext parser like
                     --with-default-parser=TokenMecab.
                     (default: TokenBigram)])],
    [default_parser=$withval],
    [default_parser=no])
if test x"$default_parser" != x"no"; then
  AC_DEFINE_UNQUOTED(MRN_PARSER_DEFAULT,
		     "$default_parser",
		     "specified default fulltext parser")
  MRN_DEFAULT_PARSER=$default_parser
else
  MRN_DEFAULT_PARSER=TokenBigram
fi
AC_SUBST(MRN_DEFAULT_PARSER)

AC_ARG_ENABLE(fast_mutexes,
    [AS_HELP_STRING([--disable-fast-mutexes],
                    [Force disable fast mutex.
                     [default: use mysql_config output]])],
    [enable_fast_mutexes=$enableval],
    [enable_fast_mutexes=auto])
if test "$enable_fast_mutexes" = "no"; then
   AC_DEFINE(FORCE_FAST_MUTEX_DISABLED, [1],
             [Define to 1 if force fast mutexes disabled])
elif test "$enable_fast_mutexes" = "yes"; then
   AC_DEFINE(MY_PTHREAD_FASTMUTEX, [1],
             [Define to 1 if fast mutexes enabled])
fi

AC_ARG_ENABLE(dtrace,
    [AS_HELP_STRING([--enable-dtrace],
                    [Enable DTrace. [default: no]])],
    [enable_dtrace=$enableval],
    [enable_dtrace=no])
if test "$enable_dtrace" = "no"; then
   AC_DEFINE(DISABLE_DTRACE, [1], [Define to 1 if DTrace is disabled])
fi

# check Cutter with C++ support if available
REQUIRED_MINIMUM_CUTTER_VERSION=1.1.3
m4_ifdef([AC_CHECK_CPPCUTTER], [
AC_CHECK_CPPCUTTER(>= $REQUIRED_MINIMUM_CUTTER_VERSION)
],
[ac_cv_use_cutter="no"])
AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"])

# For mroonga.github.com
AC_ARG_WITH(mroonga-github-com-path,
            [AS_HELP_STRING([--with-mroonga-github-com-path=PATH],
            [specify mroonga.github.com path to update mroonga.github.com.])],
            [MROONGA_GITHUB_COM_PATH="$withval"],
            [MROONGA_GITHUB_COM_PATH=""])
AC_SUBST(MROONGA_GITHUB_COM_PATH)

# For package
AC_ARG_WITH(rsync-path,
            [AS_HELP_STRING([--with-rsync-path=PATH],
            [specify rsync path to upload mroonga packages.])],
            [RSYNC_PATH="$withval"],
            [RSYNC_PATH="packages@packages.groonga.org:public"])
AC_SUBST(RSYNC_PATH)

AC_ARG_WITH(launchpad-uploader-pgp-key,
            [AS_HELP_STRING([--with-launchpad-uploader-pgp-key=KEY],
            [specify PGP key UID to upload Groonga packages to Launchpad.])],
            [LAUNCHPAD_UPLOADER_PGP_KEY="$withval"],
            [LAUNCHPAD_UPLOADER_PGP_KEY=""])
AC_SUBST(LAUNCHPAD_UPLOADER_PGP_KEY)

GPG_UID=m4_include(gpg_uid)
AC_SUBST(GPG_UID)

# For update-version
AC_ARG_WITH(cutter-source-path,
            [AS_HELP_STRING([--with-cutter-source-path=PATH],
            [specify Cutter source path for mroonga's release manager.])],
            [CUTTER_SOURCE_PATH="$withval"])
case "$CUTTER_SOURCE_PATH" in
  ""|/*)
    : # do nothing
    ;;
  *)
    CUTTER_SOURCE_PATH="\$(top_builddir)/${CUTTER_SOURCE_PATH}"
    ;;
esac
AC_SUBST(CUTTER_SOURCE_PATH)


# Document
AC_MSG_CHECKING([whether enable document])
AC_ARG_ENABLE(document,
  [AS_HELP_STRING([--enable-document],
    [enable document generation by Sphinx. [default=auto]])],
  [enable_document="$enableval"],
  [enable_document="auto"])
AC_MSG_RESULT($enable_document)

document_available=no
document_buildable=no
have_built_document=no
if test x"$enable_document" != x"no"; then
  if test -f "$srcdir/doc/build-stamp"; then
    document_available=yes
    have_built_document=yes
  fi

  if test x"$enable_document" = x"yes"; then
    AC_PATH_PROG(SPHINX_BUILD, sphinx-build, [])
    if test -n "$SPHINX_BUILD"; then
      sphinx_build_version=`"$SPHINX_BUILD" --version`
      if ! echo "$sphinx_build_version" | grep -q ' 1\.[[23]]'; then
	AC_MSG_ERROR([
sphinx-build is old: $sphinx_build_version
Sphinx 1.2 or later is required.])
      fi
      document_available=yes
      document_buildable=yes
    else
      AC_MSG_ERROR([
No sphinx-build found.
Install it and try again.

How to install sphinx-build:

For Debian GNU/Linux based system like Ubuntu:
  % sudo apt-get install -y python-pip
  % sudo pip install sphinx

For Red Hat based system like CentOS:
  % sudo yum install -y python-pip
  % sudo pip install sphinx])
    fi
    AC_SUBST(SPHINX_BUILD)
  fi
fi

AM_CONDITIONAL([DOCUMENT_AVAILABLE],
               [test "${document_available}" = "yes"])
AC_MSG_CHECKING([whether document available])
AC_MSG_RESULT($document_available)

AM_CONDITIONAL([DOCUMENT_BUILDABLE],
               [test "${document_buildable}" = "yes"])
AC_MSG_CHECKING([whether document buildable])
AC_MSG_RESULT($document_buildable)

AM_CONDITIONAL([HAVE_BUILT_DOCUMENT],
               [test "${have_built_document}" = "yes"])
AC_MSG_CHECKING([whether having built document])
AC_MSG_RESULT($have_built_document)

DOCUMENT_VERSION=mrn_version
DOCUMENT_VERSION_FULL="$DOCUMENT_VERSION"
AC_SUBST(DOCUMENT_VERSION)
AC_SUBST(DOCUMENT_VERSION_FULL)

CFLAGS="$CFLAGS"
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti -felide-constructors"

AC_CONFIG_FILES([
  Makefile
  build/Makefile
  build/cmake_modules/Makefile
  lib/Makefile
  udf/Makefile
  test/Makefile
  test/unit/Makefile
  mysql-test/Makefile
  packages/Makefile
  packages/rpm/Makefile
  packages/rpm/centos/Makefile
  packages/rpm/fedora/Makefile
  packages/yum/Makefile
  packages/apt/Makefile
  packages/source/Makefile
  packages/ubuntu/Makefile
  packages/windows/Makefile
  tools/Makefile
  doc/Makefile
  doc/locale/Makefile
  doc/locale/en/Makefile
  doc/locale/en/LC_MESSAGES/Makefile
  doc/locale/ja/Makefile
  doc/locale/ja/LC_MESSAGES/Makefile
  data/Makefile
])
AC_OUTPUT([
  config.sh
  mrn_version.h
  mysql-test/mroonga/storage/information_schema/r/plugins.result
  mysql-test/mroonga/storage/variable/r/version.result
  packages/debian/control
  packages/apt/env.sh
  packages/rpm/centos/mysql55-mroonga.spec
  packages/rpm/centos/mysql56-community-mroonga.spec
  packages/rpm/centos/mariadb-mroonga.spec
  packages/rpm/fedora/mysql-mroonga.spec
  packages/rpm/fedora/mariadb-mroonga.spec
  packages/yum/env.sh
  data/install.sql
])