"Fossies" - the Fresh Open Source Software Archive

Member "memcached-1.6.15/configure.ac" (21 Feb 2022, 25161 Bytes) of package /linux/www/memcached-1.6.15.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 last Fossies "Diffs" side-by-side code changes report for "configure.ac": 1.6.12_vs_1.6.13.

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