1AC_PREREQ(2.52) 2m4_include([version.m4]) 3m4_include([m4/c99-backport.m4]) 4AC_INIT([memcached], [VERSION_NUMBER], [[email protected]]) 5AC_CANONICAL_HOST 6AC_CONFIG_SRCDIR([memcached.c]) 7AM_INIT_AUTOMAKE([foreign]) 8AM_CONFIG_HEADER([config.h]) 9 10AC_PROG_CC 11 12is_darwin=no 13 14case "${host_os}" in 15 darwin*) 16 is_darwin=yes 17 ;; 18esac 19 20AM_CONDITIONAL([DARWIN], [test "$is_darwin" = "yes"]) 21 22dnl ********************************************************************** 23dnl DETECT_ICC ([ACTION-IF-YES], [ACTION-IF-NO]) 24dnl 25dnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES 26dnl sets the $ICC variable to "yes" or "no" 27dnl ********************************************************************** 28AC_DEFUN([DETECT_ICC], 29[ 30 ICC="no" 31 AC_MSG_CHECKING([for icc in use]) 32 if test "$GCC" = "yes"; then 33 dnl check if this is icc acting as gcc in disguise 34 AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], 35 AC_MSG_RESULT([no]) 36 [$2], 37 AC_MSG_RESULT([yes]) 38 [$1] 39 ICC="yes") 40 else 41 AC_MSG_RESULT([no]) 42 [$2] 43 fi 44]) 45 46DETECT_ICC([], []) 47 48dnl ********************************************************************** 49dnl DETECT_CLANG ([ACTION-IF-YES], [ACTION-IF-NO]) 50dnl 51dnl check if compiler is clang, and if so run the ACTION-IF-YES sets the 52dnl $CLANG variable to "yes" or "no" 53dnl ********************************************************************** 54AC_DEFUN([DETECT_CLANG], 55[ 56 AC_MSG_CHECKING([for clang in use]) 57 AC_COMPILE_IFELSE( 58 [AC_LANG_PROGRAM([], [[ 59 #ifndef __clang__ 60 not clang 61 #endif 62 ]])], 63 [CLANG=yes], [CLANG=no]) 64 AC_MSG_RESULT([$CLANG]) 65 AS_IF([test "$CLANG" = "yes"],[$1],[$2]) 66]) 67DETECT_CLANG([],[]) 68 69dnl ********************************************************************** 70dnl DETECT_SUNCC ([ACTION-IF-YES], [ACTION-IF-NO]) 71dnl 72dnl check if this is the Sun Studio compiler, and if so run the ACTION-IF-YES 73dnl sets the $SUNCC variable to "yes" or "no" 74dnl ********************************************************************** 75AC_DEFUN([DETECT_SUNCC], 76[ 77 AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) 78 AS_IF(test "x$SUNCC" = "xyes", [$1], [$2]) 79 80]) 81 82DETECT_SUNCC([CFLAGS="-mt $CFLAGS"], []) 83AS_IF([test "$ICC" = "yes" -o "$GCC" = "yes"], 84[ 85 AS_IF(test "$CLANG" = "no",[CFLAGS="$CFLAGS -pthread"]) 86]) 87 88dnl clang will error .arch_extension crc32 assembler directives to allow 89dnl assembling crc instructions without this 90AS_IF(test "$CLANG" = "yes",[CFLAGS="$CFLAGS -Wno-language-extension-token"]) 91 92if test "$ICC" = "no"; then 93 AC_PROG_CC_C99 94fi 95 96AM_PROG_CC_C_O 97AC_PROG_INSTALL 98 99AC_ARG_ENABLE(extstore, 100 [AS_HELP_STRING([--disable-extstore], [Disable external storage (extstore)])]) 101 102AC_ARG_ENABLE(seccomp, 103 [AS_HELP_STRING([--enable-seccomp],[Enable seccomp restrictions EXPERIMENTAL])]) 104 105AC_ARG_ENABLE(sasl, 106 [AS_HELP_STRING([--enable-sasl],[Enable SASL authentication])]) 107 108AC_ARG_ENABLE(sasl_pwdb, 109 [AS_HELP_STRING([--enable-sasl-pwdb],[Enable plaintext password db])]) 110 111AS_IF([test "x$enable_sasl_pwdb" = "xyes"], 112 [enable_sasl=yes ]) 113 114AC_ARG_ENABLE(tls, 115 [AS_HELP_STRING([--enable-tls], [Enable Transport Layer Security EXPERIMENTAL ])]) 116 117 118AC_ARG_ENABLE(asan, 119 [AS_HELP_STRING([--enable-asan], [Compile with ASAN EXPERIMENTAL ])]) 120 121AC_ARG_ENABLE(static, 122 [AS_HELP_STRING([--enable-static], [Compile a statically linked binary])]) 123 124AC_ARG_ENABLE(unix_socket, 125 [AS_HELP_STRING([--disable-unix-socket], [Disable unix domain socket])]) 126 127AC_ARG_ENABLE(proxy, 128 [AS_HELP_STRING([--enable-proxy], [Enable proxy code EXPERIMENTAL])]) 129 130AC_ARG_ENABLE(proxy-uring, 131 [AS_HELP_STRING([--enable-proxy-uring], [Enable proxy io_uring code EXPERIMENTAL])]) 132 133AC_ARG_ENABLE(proxy-tls, 134 [AS_HELP_STRING([--enable-proxy-tls], [Enable proxy io_uring code EXPERIMENTAL])]) 135 136AC_ARG_ENABLE(werror, 137 [AS_HELP_STRING([--enable-werror], [Enable -Werror])]) 138 139AC_ARG_ENABLE(large-client-flags, 140 [AS_HELP_STRING([--enable-large-client-flags], [Change client flags from 32bit to 64bit EXPERIMENTAL])]) 141 142dnl ********************************************************************** 143dnl DETECT_SASL_CB_GETCONF 144dnl 145dnl check if we can use SASL_CB_GETCONF 146dnl ********************************************************************** 147AC_DEFUN([AC_C_DETECT_SASL_CB_GETCONF], 148[ 149 AC_CACHE_CHECK([for SASL_CB_GETCONF], 150 [ac_cv_c_sasl_cb_getconf], 151 [AC_TRY_COMPILE( 152 [ 153#include <sasl/sasl.h> 154 ], [ 155unsigned long val = SASL_CB_GETCONF; 156 ], 157 [ ac_cv_c_sasl_cb_getconf=yes ], 158 [ ac_cv_c_sasl_cb_getconf=no ]) 159 ]) 160 AS_IF([test "$ac_cv_c_sasl_cb_getconf" = "yes"], 161 [AC_DEFINE([HAVE_SASL_CB_GETCONF], 1, 162 [Set to nonzero if your SASL implementation supports SASL_CB_GETCONF])]) 163]) 164 165dnl ********************************************************************** 166dnl DETECT_SASL_CB_GETCONFPATH 167dnl 168dnl check if we can use SASL_CB_GETCONFPATH 169dnl ********************************************************************** 170AC_DEFUN([AC_C_DETECT_SASL_CB_GETCONFPATH], 171[ 172 AC_CACHE_CHECK([for SASL_CB_GETCONFPATH], 173 [ac_cv_c_sasl_cb_getconfpath], 174 [AC_TRY_COMPILE( 175 [ 176#include <sasl/sasl.h> 177 ], [ 178unsigned long val = SASL_CB_GETCONFPATH; 179 ], 180 [ ac_cv_c_sasl_cb_getconfpath=yes ], 181 [ ac_cv_c_sasl_cb_getconfpath=no ]) 182 ]) 183 AS_IF([test "$ac_cv_c_sasl_cb_getconfpath" = "yes"], 184 [AC_DEFINE([HAVE_SASL_CB_GETCONFPATH], 1, 185 [Set to nonzero if your SASL implementation supports SASL_CB_GETCONFPATH])]) 186]) 187 188AC_CHECK_HEADERS([sasl/sasl.h]) 189if test "x$enable_sasl" = "xyes"; then 190 AC_C_DETECT_SASL_CB_GETCONF 191 AC_C_DETECT_SASL_CB_GETCONFPATH 192 AC_DEFINE([ENABLE_SASL],1,[Set to nonzero if you want to include SASL]) 193 AC_SEARCH_LIBS([sasl_server_init], [sasl2 sasl], [], 194 [ 195 AC_MSG_ERROR([Failed to locate the library containing sasl_server_init]) 196 ]) 197 198 AS_IF([test "x$enable_sasl_pwdb" = "xyes"], 199 [AC_DEFINE([ENABLE_SASL_PWDB], 1, 200 [Set to nonzero if you want to enable a SASL pwdb])]) 201fi 202 203AC_ARG_ENABLE(dtrace, 204 [AS_HELP_STRING([--enable-dtrace],[Enable dtrace probes])]) 205if test "x$enable_dtrace" = "xyes"; then 206 AC_PATH_PROG([DTRACE], [dtrace], "no", [/usr/sbin:$PATH]) 207 if test "x$DTRACE" != "xno"; then 208 AC_DEFINE([ENABLE_DTRACE],1,[Set to nonzero if you want to include DTRACE]) 209 build_dtrace=yes 210 $DTRACE -h -o conftest.h -s memcached_dtrace.d 2>/dev/zero 211 if test $? -eq 0 212 then 213 dtrace_instrument_obj=yes 214 rm conftest.h 215 # on Mac probe id are generated with $ 216 if test "$is_darwin" = "yes"; then 217 CFLAGS="$CFLAGS -Wno-dollar-in-identifier-extension" 218 fi 219 fi 220 221 if test "`which tr`" = "/usr/ucb/tr"; then 222 AC_MSG_ERROR([Please remove /usr/ucb from your path. See man standards for more info]) 223 fi 224 else 225 AC_MSG_ERROR([Need dtrace binary and OS support.]) 226 fi 227fi 228 229if test "x$enable_extstore" != "xno"; then 230 AC_DEFINE([EXTSTORE],1,[Set to nonzero if you want to enable extstore]) 231fi 232 233if test "x$enable_tls" = "xyes"; then 234 AC_DEFINE([TLS],1,[Set to nonzero if you want to enable TLS]) 235fi 236 237if test "x$enable_asan" = "xyes"; then 238 AC_DEFINE([ASAN],1,[Set to nonzero if you want to compile using ASAN]) 239fi 240 241if test "x$enable_static" = "xyes"; then 242 AC_DEFINE([STATIC],1,[Set to nonzero if you want to compile a statically linked binary]) 243fi 244 245if test "x$enable_unix_socket" = "xno"; then 246 AC_DEFINE([DISABLE_UNIX_SOCKET],1,[Set to nonzero if you want to disable unix domain socket]) 247fi 248 249if test "x$enable_proxy" = "xyes"; then 250 AC_DEFINE([PROXY],1,[Set to nonzero if you want to enable proxy code]) 251 CPPFLAGS="-Ivendor/lua/src -Ivendor/liburing/src/include $CPPFLAGS" 252 dnl lua needs math lib. 253 LIBS="$LIBS -lm -ldl" 254fi 255 256if test "x$enable_proxy_uring" = "xyes"; then 257 AC_DEFINE([HAVE_LIBURING],1,[Set to nonzero if you want to enable proxy uring handling]) 258 CPPFLAGS="-Ivendor/liburing/src/include $CPPFLAGS" 259fi 260 261if test "x$enable_proxy_tls" = "xyes"; then 262 if test "x$enable_tls" != "xyes"; then 263 AC_MSG_ERROR([--enable-proxy-tls requires --enable-tls]) 264 else 265 AC_DEFINE([PROXY_TLS],1,[Set to nonzero if you want to enable proxy backend tls support]) 266 fi 267fi 268 269if test "x$enable_large_client_flags" = "xyes"; then 270 AC_DEFINE([LARGE_CLIENT_FLAGS],1,[Set to nonzero if you want 64bit client flags]) 271fi 272 273AM_CONDITIONAL([BUILD_DTRACE],[test "$build_dtrace" = "yes"]) 274AM_CONDITIONAL([DTRACE_INSTRUMENT_OBJ],[test "$dtrace_instrument_obj" = "yes"]) 275AM_CONDITIONAL([ENABLE_SASL],[test "$enable_sasl" = "yes"]) 276AM_CONDITIONAL([ENABLE_EXTSTORE],[test "$enable_extstore" != "no"]) 277AM_CONDITIONAL([ENABLE_ARM_CRC32],[test "$enable_arm_crc32" = "yes"]) 278AM_CONDITIONAL([ENABLE_TLS],[test "$enable_tls" = "yes"]) 279AM_CONDITIONAL([ENABLE_ASAN],[test "$enable_asan" = "yes"]) 280AM_CONDITIONAL([ENABLE_STATIC],[test "$enable_static" = "yes"]) 281AM_CONDITIONAL([DISABLE_UNIX_SOCKET],[test "$enable_unix_socket" = "no"]) 282AM_CONDITIONAL([ENABLE_PROXY],[test "$enable_proxy" = "yes"]) 283AM_CONDITIONAL([ENABLE_PROXY_URING],[test "$enable_proxy_uring" = "yes"]) 284AM_CONDITIONAL([ENABLE_PROXY_TLS],[test "$enable_proxy_tls" = "yes"]) 285AM_CONDITIONAL([LARGE_CLIENT_FLAGS],[test "$enable_large_client_flags" = "yes"]) 286 287 288AC_SUBST(DTRACE) 289AC_SUBST(DTRACEFLAGS) 290AC_SUBST(ENABLE_SASL) 291AC_SUBST(PROFILER_LDFLAGS) 292 293AC_ARG_ENABLE(coverage, 294 [AS_HELP_STRING([--disable-coverage],[Disable code coverage])]) 295 296if test "x$enable_coverage" != "xno"; then 297 if test "$GCC" = "yes" -a "$ICC" != "yes" -a "$CLANG" != "yes" 298 then 299 CFLAGS="$CFLAGS -pthread" 300 AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) 301 if test "x$PROFILER" != "xno"; then 302 # Issue 97: The existence of gcov doesn't mean we have -lgcov 303 AC_CHECK_LIB(gcov, main, 304 [ 305 PROFILER_FLAGS="-fprofile-arcs -ftest-coverage" 306 PROFILER_LDFLAGS="-lgcov" 307 ], [ 308 PROFILER_FLAGS= 309 PROFILER_LDFLAGS= 310 ]) 311 fi 312 elif test "$SUNCC" = "yes" 313 then 314 AC_PATH_PROG([PROFILER], [tcov], "no", [$PATH]) 315 if test "x$PROFILER" != "xno"; then 316 PROFILER_FLAGS=-xprofile=tcov 317 fi 318 elif test "x$CLANG" != "xno" 319 then 320 AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) 321 if test "x$PROFILER" != "xno" 322 then 323 PROFILER_FLAGS="-fprofile-arcs -ftest-coverage" 324 PROFILER_LDFLAGS= 325 fi 326 fi 327fi 328AC_SUBST(PROFILER_FLAGS) 329 330 331AC_ARG_ENABLE(64bit, 332 [AS_HELP_STRING([--enable-64bit],[build 64bit version])]) 333if test "x$enable_64bit" = "xyes" 334then 335 org_cflags=$CFLAGS 336 CFLAGS=-m64 337 AC_RUN_IFELSE( 338 [AC_LANG_PROGRAM([], [dnl 339return sizeof(void*) == 8 ? 0 : 1; 340 ]) 341 ],[ 342 CFLAGS="-m64 $org_cflags" 343 ],[ 344 AC_MSG_ERROR([Don't know how to build a 64-bit object.]) 345 ],[ 346 dnl cross compile 347 AC_MSG_WARN([Assuming no extra CFLAGS are required for cross-compiling 64bit version.]) 348 ]) 349fi 350 351dnl Check if data pointer is 64bit or not 352AC_CHECK_SIZEOF([void *]) 353 354# Issue 213: Search for clock_gettime to help people linking 355# with a static version of libevent 356AC_SEARCH_LIBS(clock_gettime, rt) 357# Issue 214: Search for the network libraries _before_ searching 358# for libevent (to help people linking with static libevent) 359AC_SEARCH_LIBS(socket, socket) 360AC_SEARCH_LIBS(gethostbyname, nsl) 361 362trylibeventdir="" 363AC_ARG_WITH(libevent, 364 [ --with-libevent=PATH Specify path to libevent installation ], 365 [ 366 if test "x$withval" != "xno" ; then 367 trylibeventdir=$withval 368 fi 369 ] 370) 371 372dnl ------------------------------------------------------ 373dnl libevent detection. swiped from Tor. modified a bit. 374 375LIBEVENT_URL=https://www.monkey.org/~provos/libevent/ 376 377AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [ 378 saved_LIBS="$LIBS" 379 saved_LDFLAGS="$LDFLAGS" 380 saved_CPPFLAGS="$CPPFLAGS" 381 le_found=no 382 for ledir in $trylibeventdir "" $prefix /usr/local ; do 383 LDFLAGS="$saved_LDFLAGS" 384 LIBS="-levent $saved_LIBS" 385 386 # Skip the directory if it isn't there. 387 if test ! -z "$ledir" -a ! -d "$ledir" ; then 388 continue; 389 fi 390 if test ! -z "$ledir" ; then 391 if test -d "$ledir/lib" ; then 392 LDFLAGS="-L$ledir/lib $LDFLAGS" 393 else 394 LDFLAGS="-L$ledir $LDFLAGS" 395 fi 396 if test -d "$ledir/include" ; then 397 CPPFLAGS="-I$ledir/include $CPPFLAGS" 398 else 399 CPPFLAGS="-I$ledir $CPPFLAGS" 400 fi 401 fi 402 # Can I compile and link it? 403 AC_TRY_LINK([#include <sys/time.h> 404#include <sys/types.h> 405#include <event.h>], [ event_init(); ], 406 [ libevent_linked=yes ], [ libevent_linked=no ]) 407 if test $libevent_linked = yes; then 408 if test ! -z "$ledir" ; then 409 ac_cv_libevent_dir=$ledir 410 _myos=`echo $target_os | cut -f 1 -d .` 411 AS_IF(test "$SUNCC" = "yes" -o "x$_myos" = "xsolaris2", 412 [saved_LDFLAGS="$saved_LDFLAGS -Wl,-R$ledir/lib"], 413 [AS_IF(test "$GCC" = "yes", 414 [saved_LDFLAGS="$saved_LDFLAGS -Wl,-rpath,$ledir/lib"])]) 415 else 416 ac_cv_libevent_dir="(system)" 417 fi 418 le_found=yes 419 break 420 fi 421 done 422 LIBS="$saved_LIBS" 423 LDFLAGS="$saved_LDFLAGS" 424 CPPFLAGS="$saved_CPPFLAGS" 425 if test $le_found = no ; then 426 AC_MSG_ERROR([libevent is required. You can get it from $LIBEVENT_URL 427 428 If it's already installed, specify its path using --with-libevent=/dir/ 429]) 430 fi 431]) 432LIBS="-levent $LIBS" 433if test $ac_cv_libevent_dir != "(system)"; then 434 if test -d "$ac_cv_libevent_dir/lib" ; then 435 LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS" 436 le_libdir="$ac_cv_libevent_dir/lib" 437 else 438 LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS" 439 le_libdir="$ac_cv_libevent_dir" 440 fi 441 if test -d "$ac_cv_libevent_dir/include" ; then 442 CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS" 443 else 444 CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS" 445 fi 446fi 447 448AC_RUN_IFELSE( 449 [AC_LANG_PROGRAM([ 450#include <event.h> 451 ], [dnl 452const char *ver = event_get_version(); 453return (ver != NULL && *ver != '1') ? 0 : 1; 454 ]) 455 ],[ 456 AC_DEFINE(HAVE_LIBEVENT_NEW, 1, [linked to libevent]) 457 ], 458 [ 459 AC_MSG_ERROR([libevent2 is required]) 460 ], 461 [] 462[]) 463 464trylibssldir="" 465AC_ARG_WITH(libssl, 466 [ --with-libssl=PATH Specify path to libssl installation ], 467 [ 468 if test "x$withval" != "xno" ; then 469 trylibssldir=$withval 470 fi 471 ] 472) 473 474dnl ---------------------------------------------------------------------------- 475dnl libssl detection. swiped from libevent. modified for openssl detection. 476 477PKG_PROG_PKG_CONFIG 478OPENSSL_URL=https://www.openssl.org/ 479if test "x$enable_tls" = "xyes"; then 480 PKG_CHECK_MODULES(OPENSSL, openssl, [LIBS="$LIBS $OPENSSL_LIBS" CFLAGS="$CFLAGS $OPENSSL_CFLAGS"], [ 481 AC_CACHE_CHECK([for libssl directory], ac_cv_libssl_dir, [ 482 saved_LIBS="$LIBS" 483 saved_LDFLAGS="$LDFLAGS" 484 saved_CPPFLAGS="$CPPFLAGS" 485 le_found=no 486 for ledir in $trylibssldir "" $prefix /usr/local ; do 487 LDFLAGS="$saved_LDFLAGS" 488 LIBS="-lssl -lcrypto $saved_LIBS" 489 490 # Skip the directory if it isn't there. 491 if test ! -z "$ledir" -a ! -d "$ledir" ; then 492 continue; 493 fi 494 if test ! -z "$ledir" ; then 495 if test -d "$ledir/lib" ; then 496 LDFLAGS="-L$ledir/lib $LDFLAGS" 497 else 498 LDFLAGS="-L$ledir $LDFLAGS" 499 fi 500 if test -d "$ledir/include" ; then 501 CPPFLAGS="-I$ledir/include $CPPFLAGS" 502 else 503 CPPFLAGS="-I$ledir $CPPFLAGS" 504 fi 505 fi 506 # Can I compile and link it? 507 AC_TRY_LINK([#include <sys/time.h> 508 #include <sys/types.h> 509 #include <assert.h> 510 #include <openssl/ssl.h>], [ SSL_CTX* ssl_ctx = SSL_CTX_new(TLS_server_method()); 511 assert(OPENSSL_VERSION_NUMBER >= 0x10101000L);], 512 [ libssl_linked=yes ], [ libssl_linked=no ]) 513 if test $libssl_linked = yes; then 514 if test ! -z "$ledir" ; then 515 ac_cv_libssl_dir=$ledir 516 _myos=`echo $target_os | cut -f 1 -d .` 517 AS_IF(test "$SUNCC" = "yes" -o "x$_myos" = "xsolaris2", 518 [saved_LDFLAGS="$saved_LDFLAGS -Wl,-R$ledir/lib"], 519 [AS_IF(test "$GCC" = "yes", 520 [saved_LDFLAGS="$saved_LDFLAGS -Wl,-rpath,$ledir/lib"])]) 521 else 522 ac_cv_libssl_dir="(system)" 523 fi 524 le_found=yes 525 break 526 fi 527 done 528 LIBS="$saved_LIBS" 529 LDFLAGS="$saved_LDFLAGS" 530 CPPFLAGS="$saved_CPPFLAGS" 531 if test $le_found = no ; then 532 AC_MSG_ERROR([libssl (at least version 1.1.0) is required. You can get it from $OPENSSL_URL 533 534 If it's already installed, specify its path using --with-libssl=/dir/ 535 ]) 536 fi 537 ]) 538 LIBS="-lssl -lcrypto $LIBS" 539 if test $ac_cv_libssl_dir != "(system)"; then 540 if test -d "$ac_cv_libssl_dir/lib" ; then 541 LDFLAGS="-L$ac_cv_libssl_dir/lib $LDFLAGS" 542 le_libdir="$ac_cv_libssl_dir/lib" 543 else 544 LDFLAGS="-L$ac_cv_libssl_dir $LDFLAGS" 545 le_libdir="$ac_cv_libssl_dir" 546 fi 547 if test -d "$ac_cv_libssl_dir/include" ; then 548 CPPFLAGS="-I$ac_cv_libssl_dir/include $CPPFLAGS" 549 else 550 CPPFLAGS="-I$ac_cv_libssl_dir $CPPFLAGS" 551 fi 552 fi 553 ]) 554fi 555 556if test "x$enable_static" = "xyes"; then 557 LIBS="$LIBS -ldl" 558 LDFLAGS="-static $LDFLAGS" 559fi 560 561dnl ---------------------------------------------------------------------------- 562 563AC_SEARCH_LIBS(gethugepagesizes, hugetlbfs) 564 565AC_HEADER_STDBOOL 566AH_BOTTOM([#if HAVE_STDBOOL_H 567#include <stdbool.h> 568#else 569#define bool char 570#define false 0 571#define true 1 572#endif ]) 573 574AC_CHECK_HEADERS([inttypes.h]) 575AH_BOTTOM([#ifdef HAVE_INTTYPES_H 576#include <inttypes.h> 577#endif 578]) 579AC_CHECK_HEADERS([sys/auxv.h]) 580 581dnl ********************************************************************** 582dnl Figure out if this system has the stupid sasl_callback_ft 583dnl ********************************************************************** 584 585AC_DEFUN([AC_HAVE_SASL_CALLBACK_FT], 586[AC_CACHE_CHECK(for sasl_callback_ft, ac_cv_has_sasl_callback_ft, 587[ 588 AC_TRY_COMPILE([ 589 #ifdef HAVE_SASL_SASL_H 590 #include <sasl/sasl.h> 591 #include <sasl/saslplug.h> 592 #endif 593 ],[ 594 sasl_callback_ft a_callback; 595 ],[ 596 ac_cv_has_sasl_callback_ft=yes 597 ],[ 598 ac_cv_has_sasl_callback_ft=no 599 ]) 600]) 601if test $ac_cv_has_sasl_callback_ft = yes; then 602 AC_DEFINE(HAVE_SASL_CALLBACK_FT, 1, [we have sasl_callback_ft]) 603fi 604]) 605 606AC_HAVE_SASL_CALLBACK_FT 607 608dnl ********************************************************************** 609dnl DETECT_UINT64_SUPPORT 610dnl 611dnl check if we can use a uint64_t 612dnl ********************************************************************** 613AC_DEFUN([AC_C_DETECT_UINT64_SUPPORT], 614[ 615 AC_CACHE_CHECK([for print macros for integers (C99 section 7.8.1)], 616 [ac_cv_c_uint64_support], 617 [AC_TRY_COMPILE( 618 [ 619#ifdef HAVE_INTTYPES_H 620#include <inttypes.h> 621#endif 622#include <stdio.h> 623 ], [ 624 uint64_t val = 0; 625 fprintf(stderr, "%" PRIu64 "\n", val); 626 ], 627 [ ac_cv_c_uint64_support=yes ], 628 [ ac_cv_c_uint64_support=no ]) 629 ]) 630]) 631 632AC_C_DETECT_UINT64_SUPPORT 633AS_IF([test "x$ac_cv_c_uint64_support" = "xno"], 634 [AC_MSG_WARN([ 635 636Failed to use print macros (PRIu) as defined in C99 section 7.8.1. 637 638])]) 639 640AC_C_CONST 641 642dnl From licq: Copyright (c) 2000 Dirk Mueller 643dnl Check if the type socklen_t is defined anywhere 644AC_DEFUN([AC_C_SOCKLEN_T], 645[AC_CACHE_CHECK(for socklen_t, ac_cv_c_socklen_t, 646[ 647 AC_TRY_COMPILE([ 648 #include <sys/types.h> 649 #include <sys/socket.h> 650 ],[ 651 socklen_t foo; 652 ],[ 653 ac_cv_c_socklen_t=yes 654 ],[ 655 ac_cv_c_socklen_t=no 656 ]) 657]) 658if test $ac_cv_c_socklen_t = no; then 659 AC_DEFINE(socklen_t, int, [define to int if socklen_t not available]) 660fi 661]) 662 663AC_C_SOCKLEN_T 664 665dnl Check if we're a little-endian or a big-endian system, needed by hash code 666AC_C_BIGENDIAN( 667 [AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian])], 668 [AC_DEFINE(ENDIAN_LITTLE, 1, [machine is littleendian])], 669 [AC_MSG_ERROR([Cannot detect endianness. Must pass ac_cv_c_bigendian={yes,no} to configure.])]) 670 671AC_DEFUN([AC_C_HTONLL], 672[ 673 AC_MSG_CHECKING([for htonll]) 674 have_htoll="no" 675 AC_TRY_LINK([ 676#include <sys/types.h> 677#include <netinet/in.h> 678#ifdef HAVE_INTTYPES_H 679#include <inttypes.h> */ 680#endif 681 ], [ 682 return htonll(0); 683 ], [ 684 have_htoll="yes" 685 AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll]) 686 ], [ 687 have_htoll="no" 688 ]) 689 690 AC_MSG_RESULT([$have_htoll]) 691]) 692 693AC_C_HTONLL 694 695dnl Check whether the user's system supports pthread 696AC_SEARCH_LIBS(pthread_create, pthread) 697if test "x$ac_cv_search_pthread_create" = "xno"; then 698 AC_MSG_ERROR([Can't enable threads without the POSIX thread library.]) 699fi 700 701AC_CHECK_FUNCS(mlockall) 702AC_CHECK_FUNCS(getpagesizes) 703AC_CHECK_FUNCS(sysconf) 704AC_CHECK_FUNCS(memcntl) 705AC_CHECK_FUNCS(clock_gettime) 706AC_CHECK_FUNCS(preadv) 707AC_CHECK_FUNCS(pread) 708AC_CHECK_FUNCS(eventfd) 709AC_CHECK_FUNCS([pthread_setname_np],[AC_DEFINE(HAVE_PTHREAD_SETNAME_NP, 1, [Define to 1 if support pthread_setname_np])]) 710AC_CHECK_FUNCS([accept4], [AC_DEFINE(HAVE_ACCEPT4, 1, [Define to 1 if support accept4])]) 711AC_CHECK_FUNCS([getopt_long], [AC_DEFINE(HAVE_GETOPT_LONG, 1, [Define to 1 if support getopt_long])]) 712 713dnl Need to disable opt for alignment check. GCC is too clever and turns this 714dnl into wide stores and no cmp under O2. 715AC_DEFUN([AC_C_ALIGNMENT], 716[AC_CACHE_CHECK(for alignment, ac_cv_c_alignment, 717[ 718 AC_RUN_IFELSE( 719 [AC_LANG_PROGRAM([ 720#include <stdlib.h> 721#include <inttypes.h> 722#pragma GCC optimize ("O0") 723 ], [ 724 char *buf = malloc(32); 725 726 uint64_t *ptr = (uint64_t*)(buf+2); 727 // catch sigbus, etc. 728 *ptr = 0x1; 729 730 // catch unaligned word access (ARM cpus) 731#ifdef ENDIAN_BIG 732#define ALIGNMENT 0x02030405 733#else 734#define ALIGNMENT 0x05040302 735#endif 736 *(buf + 0) = 1; 737 *(buf + 1) = 2; 738 *(buf + 2) = 3; 739 *(buf + 3) = 4; 740 *(buf + 4) = 5; 741 int* i = (int*)(buf+1); 742 return (ALIGNMENT == *i) ? 0 : 1; 743 ]) 744 ],[ 745 ac_cv_c_alignment=none 746 ],[ 747 ac_cv_c_alignment=need 748 ],[ 749 dnl cross compile 750 ac_cv_c_alignment=maybe 751 ]) 752]) 753AS_IF([test $ac_cv_c_alignment = need], 754 [AC_DEFINE(NEED_ALIGN, 1, [Machine need alignment])]) 755AS_IF([test $ac_cv_c_alignment = maybe], 756 [AC_MSG_WARN([Assuming aligned access is required when cross-compiling]) 757 AC_DEFINE(NEED_ALIGN, 1, [Machine need alignment])]) 758]) 759 760AC_C_ALIGNMENT 761 762dnl Check for our specific usage of GCC atomics. 763dnl These were added in 4.1.2, but 32bit OS's may lack shorts and 4.1.2 764dnl lacks testable defines. 765have_gcc_atomics=no 766AC_MSG_CHECKING(for GCC atomics) 767AC_TRY_LINK([],[ 768 unsigned short a; 769 unsigned short b; 770 b = __sync_add_and_fetch(&a, 1); 771 b = __sync_sub_and_fetch(&a, 2); 772 ],[have_gcc_atomics=yes 773 AC_DEFINE(HAVE_GCC_ATOMICS, 1, [GCC Atomics available])]) 774AC_MSG_RESULT($have_gcc_atomics) 775 776dnl Check for usage of 64bit atomics 777dnl 32bit systems shouldn't have these. 778have_gcc_64atomics=no 779AC_MSG_CHECKING(for GCC 64bit atomics) 780AC_TRY_LINK([#include <inttypes.h> 781 ],[ 782 uint64_t a; 783 uint64_t b; 784 b = __sync_add_and_fetch(&a, 1); 785 b = __sync_sub_and_fetch(&a, 2); 786 ],[have_gcc_64atomics=yes 787 AC_DEFINE(HAVE_GCC_64ATOMICS, 1, [GCC 64bit Atomics available])]) 788AC_MSG_RESULT($have_gcc_64atomics) 789 790dnl Check for the requirements for running memcached with less privileges 791dnl than the default privilege set. On Solaris we need setppriv and priv.h 792dnl If you want to add support for other platforms you should check for 793dnl your requirements, define HAVE_DROP_PRIVILEGES, and make sure you add 794dnl the source file containing the implementation into memcached_SOURCE 795dnl in Makefile.am 796AC_CHECK_FUNCS(setppriv, [ 797 AC_CHECK_HEADER(priv.h, [ 798 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 799 [Define this if you have an implementation of drop_privileges()]) 800 build_solaris_privs=yes 801 ], []) 802],[]) 803 804AS_IF([test "x$enable_seccomp" = "xyes" ], [ 805 AC_CHECK_LIB(seccomp, seccomp_rule_add, [ 806 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 807 [Define this if you have an implementation of drop_privileges()]) 808 build_linux_privs=yes 809 AC_DEFINE([HAVE_DROP_WORKER_PRIVILEGES], 1, 810 [Define this if you have an implementation of drop_worker_privileges()]) 811 build_linux_privs=yes 812 ], []) 813]) 814 815AC_CHECK_FUNCS(pledge, [ 816 AC_CHECK_HEADER(unistd.h, [ 817 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 818 [Define this if you have an implementation of drop_privileges()]) 819 build_openbsd_privs=yes 820 ], []) 821],[]) 822 823AC_CHECK_FUNCS(cap_enter, [ 824 AC_CHECK_HEADER(sys/capsicum.h, [ 825 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 826 [Define this if you have an implementation of drop_privileges()]) 827 build_freebsd_privs=yes 828 ], []) 829],[]) 830 831AC_CHECK_FUNCS(sandbox_init, [ 832 AC_CHECK_HEADER(sandbox.h, [ 833 AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 834 [Define this if you have an implementation of drop_privileges()]) 835 build_darwin_privs=yes 836 ], []) 837],[]) 838 839 840 841AM_CONDITIONAL([BUILD_SOLARIS_PRIVS],[test "$build_solaris_privs" = "yes"]) 842AM_CONDITIONAL([BUILD_LINUX_PRIVS],[test "$build_linux_privs" = "yes"]) 843AM_CONDITIONAL([BUILD_OPENBSD_PRIVS],[test "$build_openbsd_privs" = "yes"]) 844AM_CONDITIONAL([BUILD_FREEBSD_PRIVS],[test "$build_freebsd_privs" = "yes"]) 845AM_CONDITIONAL([BUILD_DARWIN_PRIVS],[test "$build_darwin_privs" = "yes"]) 846 847AC_ARG_ENABLE(docs, 848 [AS_HELP_STRING([--disable-docs],[Disable documentation generation])]) 849 850AC_PATH_PROG([XML2RFC], [xml2rfc], "no") 851AC_PATH_PROG([XSLTPROC], [xsltproc], "no") 852 853AM_CONDITIONAL([BUILD_SPECIFICATIONS], 854 [test "x$enable_docs" != "xno" -a "x$XML2RFC" != "xno" -a "x$XSLTPROC" != "xno"]) 855 856 857if test "x$enable_werror" = "xyes"; then 858 CFLAGS="$CFLAGS -Werror" 859fi 860 861dnl Let the compiler be a bit more picky. Please note that you cannot 862dnl specify these flags to the compiler before AC_CHECK_FUNCS, because 863dnl the test program will generate a compilation warning and hence fail 864dnl to detect the function ;-) 865if test "$ICC" = "yes" 866then 867 dnl ICC trying to be gcc. 868 CFLAGS="$CFLAGS -diag-disable 187 -Wall" 869 AC_DEFINE([_GNU_SOURCE],[1],[make sure IOV_MAX is defined]) 870elif test "$GCC" = "yes" 871then 872 GCC_VERSION=`$CC -dumpversion` 873 CFLAGS="$CFLAGS -Wall -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls" 874 if test "x$enable_asan" = "xyes"; then 875 CFLAGS="$CFLAGS -fsanitize=address" 876 fi 877 case $GCC_VERSION in 878 4.4.*) 879 CFLAGS="$CFLAGS -fno-strict-aliasing" 880 ;; 881 esac 882 AC_DEFINE([_GNU_SOURCE],[1],[make sure IOV_MAX is defined]) 883elif test "$SUNCC" = "yes" 884then 885 CFLAGS="$CFLAGS -errfmt=error -errwarn -errshort=tags" 886fi 887 888AC_CONFIG_FILES(Makefile doc/Makefile) 889AC_OUTPUT 890