1AC_INIT([senna],1.1.5,[senna@razil.jp]) 2AM_CONFIG_HEADER(config.h) 3 4AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) 5 6AC_PROG_CC 7AC_PROG_CXX 8AM_PROG_CC_C_O 9AC_DEFUN([CHECK_CFLAG], [ 10 old_CFLAGS=$CFLAGS 11 CFLAGS="$CFLAGS $1 -Werror" 12 AC_COMPILE_IFELSE([[ 13#include <stdio.h> 14int main(int argc, char **argv) 15{ 16 printf("test cflags, argc:%d argv[0]:%s", argc, argv[0]); 17 return 0; 18} 19 ]], 20 [check_cflag=yes], 21 [check_cflag=no]) 22 CFLAGS="$old_CFLAGS" 23 if test "x$check_cflag" = "xyes"; then 24 CFLAGS="$CFLAGS $1" 25 fi 26]) 27if test "$GCC" = "yes"; then 28 CHECK_CFLAG([-Wall]) 29 CHECK_CFLAG([-Wextra]) 30 if test "x$check_cflag" = "xno"; then 31 CHECK_CFLAG([-W]) 32 fi 33 CHECK_CFLAG([-Wno-unused-parameter]) 34 CHECK_CFLAG([-Wno-sign-compare]) 35 CHECK_CFLAG([-Wno-pointer-sign]) 36 CHECK_CFLAG([-Wno-missing-field-initializers]) 37 38 CHECK_CFLAG([-Wformat=2]) 39 CHECK_CFLAG([-Wstrict-aliasing=2]) 40 CHECK_CFLAG([-Wdisabled-optimization]) 41 CHECK_CFLAG([-Wfloat-equal]) 42 CHECK_CFLAG([-Wpointer-arith]) 43 CHECK_CFLAG([-Wdeclaration-after-statement]) 44 CHECK_CFLAG([-Wbad-function-cast]) 45 CHECK_CFLAG([-Wcast-align]) 46 CHECK_CFLAG([-Wredundant-decls]) 47# CHECK_CFLAG([-Wunsafe-loop-optimizations]) 48# CHECK_CFLAG([-Wunreachable-code]) 49# CHECK_CFLAG([-Wswitch-enum]) 50# CHECK_CFLAG([-Wshadow]) 51# CHECK_CFLAG([-Wconversion]) 52# CHECK_CFLAG([-Wwrite-strings]) 53 CHECK_CFLAG([-Winline]) 54 CHECK_CFLAG([--param max-inline-insns-single=12000]) 55 CHECK_CFLAG([--param large-function-growth=28000]) 56 CHECK_CFLAG([--param inline-unit-growth=400]) 57fi 58AM_PROG_LIBTOOL 59AC_CONFIG_FILES([Makefile test/Makefile test/unit/Makefile test/ql/Makefile src/Makefile lib/Makefile bindings/mysql/myisenna/Makefile]) 60AC_CHECK_HEADERS(sys/mman.h sys/time.h sys/param.h sys/types.h pthread.h sys/resource.h) 61AC_CHECK_HEADERS(netdb.h sys/wait.h sys/socket.h netinet/in.h netinet/tcp.h) 62AC_CHECK_HEADERS(ucontext.h signal.h errno.h) 63AC_CHECK_FUNCS(localtime_r) 64AC_SYS_LARGEFILE 65AC_TYPE_OFF_T 66AC_TYPE_SIZE_T 67AC_CHECK_SIZEOF(off_t) 68 69# will deprecated 70AC_ARG_WITH(sennahome, 71 [AC_HELP_STRING([--with-sennahome=DIR], 72 [specify Senna home directory(will deprecated)])], 73 SENNA_HOME="$withval", 74 SENNA_HOME="/var/senna") 75AC_DEFINE_UNQUOTED(SENNA_HOME, "$SENNA_HOME", "specified home directory") 76 77# log directory 78AC_ARG_WITH(log, 79 [AC_HELP_STRING([--with-log=PATH], 80 [specify Senna log path.])], 81 SENNA_LOG_PATH="$withval", 82 SENNA_LOG_PATH="$SENNA_HOME/log/senna.log") 83AC_DEFINE_UNQUOTED(SENNA_LOG_PATH, "$SENNA_LOG_PATH", "specified log directory") 84 85# default encoding 86AC_ARG_WITH(encoding, 87 [AC_HELP_STRING([--with-encoding=ENCODING], 88 [specify Senna default encoding(euc/sjis/utf8/latin1/koi8r/none)])], 89 SENNA_DEFAULT_ENCODING="$withval", 90 SENNA_DEFAULT_ENCODING="euc_jp") 91AC_DEFINE_UNQUOTED(SENNA_DEFAULT_ENCODING, "$SENNA_DEFAULT_ENCODING", "specified default encoding") 92 93# default initial_n_segments 94AC_ARG_WITH(initial_n_segments, 95 [AC_HELP_STRING([--with-initial-n-segments=NUMBER], 96 [specify Senna default initial_n_segments])], 97 SENNA_DEFAULT_INITIAL_N_SEGMENTS="$withval", 98 SENNA_DEFAULT_INITIAL_N_SEGMENTS="512") 99AC_DEFINE_UNQUOTED(SENNA_DEFAULT_INITIAL_N_SEGMENTS, $SENNA_DEFAULT_INITIAL_N_SEGMENTS, "specified default initial_n_segments") 100 101# default query escalation threshold 102AC_ARG_WITH(query_escalation_threshold, 103 [AC_HELP_STRING([--with-query-escalation-threshold=NUMBER], 104 [specify Senna default query escalation threshold])], 105 SENNA_DEFAULT_QUERY_ESCALATION_THRESHOLD="$withval", 106 SENNA_DEFAULT_QUERY_ESCALATION_THRESHOLD="0") 107AC_DEFINE_UNQUOTED(SENNA_DEFAULT_QUERY_ESCALATION_THRESHOLD, $SENNA_DEFAULT_QUERY_ESCALATION_THRESHOLD, "specified query escalation threshold") 108 109AC_CHECK_LIB(m, log, [M_LIBS="-lm"], [AC_MSG_ERROR("No libm found")]) 110AC_CHECK_LIB(pthread, pthread_mutex_init, [PTHREAD_LIBS="-lpthread"], [AC_MSG_ERROR("No libpthread found")]) 111 112# aio 113AC_ARG_ENABLE(aio, 114 [AC_HELP_STRING([--enable-aio], 115 [use aio/dio based cache. [default=no]])],, 116 [enable_aio="no"]) 117if test "x$enable_aio" != "xno"; then 118 AC_CHECK_LIB(rt, nanosleep, [], [AC_MSG_ERROR("No librt found")]) 119 AC_DEFINE(USE_AIO, [1], [use AIO/DIO]) 120fi 121 122# nfkc 123AC_ARG_ENABLE(nfkc, 124 [AC_HELP_STRING([--enable-nfkc], 125 [use nfkc based utf8 normalization. [default=yes]])],, 126 [enable_nfkc="yes"]) 127if test "x$enable_nfkc" != "xyes"; then 128 AC_DEFINE(NO_NFKC, [1], [compile without nfkc.c]) 129fi 130 131# gcov 132AC_ARG_ENABLE(gcov, 133 [AC_HELP_STRING([--enable-gcov], 134 [use gcov for coverage analysis. [default=no]])],, 135 [enable_gcov="no"]) 136if test "x$enable_gcov" = "xno"; then 137 OPT_CFLAGS="" 138else 139 OPT_CFLAGS="-O0" 140 GCOV_CFLAGS="-fprofile-arcs -ftest-coverage" 141 AC_CHECK_LIB(gcov, __gcov_init, [], [AC_MSG_ERROR("No libgcov found")]) 142 GCOV_LIBS="-lgcov" 143 AC_SUBST(GCOV_LIBS) 144 145 AC_PATH_PROG(LCOV, lcov, no) 146 if test "x$LCOV" = "xno"; then 147 AC_MSG_ERROR([lcov is missing.]) 148 fi 149 150 AC_PATH_PROG(GENHTML, genhtml, no) 151 if test "x$GENHTML" = "xno"; then 152 AC_MSG_ERROR([genhtml is missing.]) 153 fi 154 AC_SUBST(GCOV_CFLAGS) 155 AC_SUBST(LCOV) 156 AC_SUBST(GENHTML) 157fi 158AM_CONDITIONAL(GCOV_ENABLED, test "x$enable_gcov" = "xyes") 159 160# failmalloc 161AC_ARG_ENABLE(fmalloc, 162 [AC_HELP_STRING([--enable-fmalloc], 163 [make memory allocation failed in specified condition for debug. [default=no]])],, 164 [enable_fail_malloc="no"]) 165if test "x$enable_fail_malloc" != "xno"; then 166 AC_DEFINE(USE_FAIL_MALLOC, [1], [use fmalloc]) 167fi 168 169# abort 170AC_MSG_CHECKING([whether enable abort]) 171AC_ARG_ENABLE(abort, 172 [AC_HELP_STRING([--enable-abort], 173 [enable query abortion. [default=no]])], 174 , 175 [enable_abort="no"]) 176if test "x$enable_abort" != "xno"; then 177 force_enable_dynamic_malloc_change="yes" 178 AC_DEFINE(USE_QUERY_ABORT, [1], [use abort]) 179fi 180AC_MSG_RESULT($enable_abort) 181 182# libmyisenna 183AC_ARG_WITH(mysqlsrc, 184 [AC_HELP_STRING([--with-mysqlsrc=DIR], 185 [specify MySQL source dictionary.])], 186 MYSQL_SRCDIR="$withval") 187AC_SUBST(MYSQL_SRCDIR) 188 189# epoll/poll/select check 190AC_CHECK_HEADER(sys/epoll.h, [ 191 AC_CHECK_FUNC(epoll_create, [ 192 AC_TRY_RUN([ 193#include <sys/epoll.h> 194int main(int argc, char **argv) { return (epoll_create(16) < 0); } 195 ], 196 [ 197 have_epoll="yes" 198 AC_DEFINE(USE_EPOLL, [1], [use epoll]) 199 ] 200 ) 201 ]) 202]) 203 204if test "x$have_epoll" != "xyes"; then 205 AC_CHECK_HEADER(sys/poll.h, [ 206 AC_CHECK_FUNC(poll, [ 207 have_poll="yes" 208 AC_DEFINE(USE_POLL, [1], [use poll]) 209 ]) 210 ]) 211 if test "x$have_poll" != "xyes"; then 212 AC_CHECK_FUNC(select, [ 213 have_select="yes" 214 AC_CHECK_HEADERS(sys/select.h) 215 AC_DEFINE(USE_SELECT, [1], [use select]) 216 ],[ 217 AC_MSG_ERROR([epoll/poll/select is missing.]) 218 ]) 219 fi 220fi 221 222# check MSG_NOSIGNAL defined 223AC_MSG_CHECKING([whether MSG_NOSIGNAL defined]) 224AC_COMPILE_IFELSE([[ 225#include <sys/types.h> 226#include <sys/socket.h> 227 228#if __FreeBSD__ >= 2 && __FreeBSD_version >= 600020 229#ifndef MSG_NOSIGNAL 230#define MSG_NOSIGNAL 0x20000 231#endif 232#endif 233 234int main(int argc, char **argv) 235{ 236 return MSG_NOSIGNAL; 237} 238 ]], 239 [ 240 AC_MSG_RESULT(yes) 241 AC_DEFINE(USE_MSG_NOSIGNAL, [1], [use MSG_SIGNAL]) 242 ], 243 [ 244 AC_MSG_RESULT(no) 245 ]) 246 247# check Cutter with GLib support if available 248m4_ifdef([AC_CHECK_GCUTTER], [ 249AC_CHECK_GCUTTER 250 251if test "$ac_cv_use_cutter" != "no"; then 252 PKG_CHECK_MODULES(LIBCUTTER, libcutter, [], [ac_cv_use_cutter=no]) 253 AC_SUBST(LIBCUTTER_CFLAGS) 254 AC_SUBST(LIBCUTTER_LIBS) 255fi 256], 257[ac_cv_use_cutter="no"]) 258 259AM_CONDITIONAL([WITH_CUTTER], [test "$ac_cv_use_cutter" != "no"]) 260if test "$ac_cv_use_cutter" != "no"; then 261 AC_DEFINE(WITH_CUTTER, 1, [Define to 1 if you use Cutter]) 262fi 263 264# zlib 265AC_ARG_WITH(zlib, 266 [AC_HELP_STRING([--with-zlib], 267 [use zlib for data compression. [default=no]])], 268 [with_zlib="$withval"], 269 [with_zlib="no"]) 270if test "x$with_zlib" = "xno"; then 271 AC_DEFINE(NO_ZLIB, [1], [without zlib]) 272else 273 AC_CHECK_LIB(z, compress, [ZLIB_LIBS="-lz"], [AC_MSG_ERROR("No libz found")]) 274fi 275 276# lzo 277AC_ARG_WITH(lzo, 278 [AC_HELP_STRING([--with-lzo], 279 [use lzo for data compression. [default=no]])], 280 [with_lzo="$withval"], 281 [with_lzo="no"]) 282if test "x$with_lzo" = "xno"; then 283 AC_DEFINE(NO_LZO, [1], [without lzo]) 284else 285 AC_CHECK_LIB(lzo2, lzo1_compress, [LZO_LIBS="-llzo2"], [AC_MSG_ERROR("No liblzo2 found")]) 286fi 287 288# mecab 289# NOTE: MUST be checked last 290AC_ARG_WITH(mecab, 291 [AC_HELP_STRING([--with-mecab], 292 [use mecab for morphological analysis. [default=yes]])], 293 [with_mecab="$withval"], 294 [with_mecab="yes"]) 295if test "x$with_mecab" = "xno"; then 296 AC_DEFINE(NO_MECAB, [1], [without MeCab]) 297else 298 # mecab-config 299 AC_ARG_WITH(mecab-config, 300 [AC_HELP_STRING([--with-mecab-config=PATH], 301 [set mecab-config location. [search path]])], 302 [AC_CHECK_FILE("$withval", MECAB_CONFIG="$withval", MECAB_CONFIG=no)], 303 [AC_PATH_PROG(MECAB_CONFIG, mecab-config, no)]) 304 if test "x$MECAB_CONFIG" = "xno"; then 305 AC_MSG_ERROR([mecab-config is missing.]) 306 fi 307 308 MECAB_CFLAGS="-I`$MECAB_CONFIG --inc-dir`" 309 LDFLAGS="$LDFLAGS -L`$MECAB_CONFIG --libs-only-L`" 310 AC_CHECK_LIB(mecab, mecab_new, [], [AC_MSG_ERROR("No libmecab found")]) 311 AC_CHECK_LIB(mecab, mecab_dictionary_info, 312 [AC_DEFINE(USE_MECAB_DICINFO, [1], [check mecab encodings])], []) 313 CPPFLAGS="$CPPFLAGS $MECAB_CFLAGS" 314 AC_CHECK_HEADER(mecab.h, , [AC_MSG_ERROR("No mecab.h found")]) 315fi 316 317# flags for compile senna 318CFLAGS="$CFLAGS $MECAB_CFLAGS $OPT_CFLAGS $GCOV_CFLAGS" 319LIBS="$LIBS $ZLIB_LIBS $LZO_LIBS $PTHREAD_LIBS $M_LIBS" 320AC_DEFINE_UNQUOTED(CONFIGURE_OPTIONS, "$ac_configure_args", "specified configure options") 321 322# flags for senna-cfg 323SENNA_LIBDIR='-L${libdir}' 324SENNA_INCLUDEDIR="-I${includedir}/senna" 325SENNA_CFLAGS="$GCOV_CFLAGS" 326SENNA_LIBS="-lsenna $GCOV_LIBS $ZLIB_LIBS $LZO_LIBS $PTHREAD_LIBS $M_LIBS" 327 328AC_SUBST(SENNA_LIBDIR) 329AC_SUBST(SENNA_INCLUDEDIR) 330AC_SUBST(SENNA_CFLAGS) 331AC_SUBST(SENNA_LIBS) 332 333AC_OUTPUT([ 334 senna-cfg 335 senna.spec 336 senna.pc 337 vcc/config.h 338 ], 339 chmod +x senna-cfg) 340 341echo " 342$PACKAGE_NAME $PACKAGE_VERSION configuration: 343----------------------- 344 Compiler: ${CC} 345 CFLAGS: ${CFLAGS} 346 Libraries: ${LIBS} 347 348 Install path prefix: ${prefix} 349 350Now type 'make' to build $PACKAGE_NAME $PACKAGE_VERSION! 351" 352