"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.9/configure.ac" (21 Nov 2020, 24349 Bytes) of package /linux/www/memcached-1.6.9.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 1.6.8_vs_1.6.9.

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