11b533267SBrad FitzpatrickAC_PREREQ(2.52) 2923a335bSDustin Sallingsm4_include([version.m4]) 3a0a70329SDustin Sallingsm4_include([m4/c99-backport.m4]) 46b65e45aSJohan BergströmAC_INIT([memcached], [VERSION_NUMBER], [[email protected]]) 56b65e45aSJohan BergströmAC_CANONICAL_HOST 66b65e45aSJohan BergströmAC_CONFIG_SRCDIR([memcached.c]) 76b65e45aSJohan BergströmAM_INIT_AUTOMAKE([foreign]) 86b65e45aSJohan BergströmAM_CONFIG_HEADER([config.h]) 91b533267SBrad Fitzpatrick 101b533267SBrad FitzpatrickAC_PROG_CC 11dfc5130eSDustin Sallings 12dfc5130eSDustin Sallingsdnl ********************************************************************** 13dfc5130eSDustin Sallingsdnl DETECT_ICC ([ACTION-IF-YES], [ACTION-IF-NO]) 14dfc5130eSDustin Sallingsdnl 15dfc5130eSDustin Sallingsdnl check if this is the Intel ICC compiler, and if so run the ACTION-IF-YES 16dfc5130eSDustin Sallingsdnl sets the $ICC variable to "yes" or "no" 17dfc5130eSDustin Sallingsdnl ********************************************************************** 18dfc5130eSDustin SallingsAC_DEFUN([DETECT_ICC], 19dfc5130eSDustin Sallings[ 20dfc5130eSDustin Sallings ICC="no" 21dfc5130eSDustin Sallings AC_MSG_CHECKING([for icc in use]) 22dfc5130eSDustin Sallings if test "$GCC" = "yes"; then 23dfc5130eSDustin Sallings dnl check if this is icc acting as gcc in disguise 24dfc5130eSDustin Sallings AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER], 25725c26fbSDustin Sallings AC_MSG_RESULT([no]) 266ddbbfd0STrond Norbye [$2], 27dfc5130eSDustin Sallings AC_MSG_RESULT([yes]) 28dfc5130eSDustin Sallings [$1] 29725c26fbSDustin Sallings ICC="yes") 306ddbbfd0STrond Norbye else 316ddbbfd0STrond Norbye AC_MSG_RESULT([no]) 326ddbbfd0STrond Norbye [$2] 33dfc5130eSDustin Sallings fi 34dfc5130eSDustin Sallings]) 35dfc5130eSDustin Sallings 36725c26fbSDustin SallingsDETECT_ICC([], []) 37725c26fbSDustin Sallings 389a052169STrond Norbyednl ********************************************************************** 39145bcfd0SEric McConvillednl DETECT_CLANG ([ACTION-IF-YES], [ACTION-IF-NO]) 40145bcfd0SEric McConvillednl 41145bcfd0SEric McConvillednl check if compiler is clang, and if so run the ACTION-IF-YES sets the 42145bcfd0SEric McConvillednl $CLANG variable to "yes" or "no" 43145bcfd0SEric McConvillednl ********************************************************************** 44145bcfd0SEric McConvilleAC_DEFUN([DETECT_CLANG], 45145bcfd0SEric McConville[ 46145bcfd0SEric McConville AC_MSG_CHECKING([for clang in use]) 47145bcfd0SEric McConville AC_COMPILE_IFELSE( 48145bcfd0SEric McConville [AC_LANG_PROGRAM([], [[ 49145bcfd0SEric McConville #ifndef __clang__ 50145bcfd0SEric McConville not clang 51145bcfd0SEric McConville #endif 52145bcfd0SEric McConville ]])], 53145bcfd0SEric McConville [CLANG=yes], [CLANG=no]) 54145bcfd0SEric McConville AC_MSG_RESULT([$CLANG]) 55145bcfd0SEric McConville AS_IF([test "$CLANG" = "yes"],[$1],[$2]) 56145bcfd0SEric McConville]) 57145bcfd0SEric McConvilleDETECT_CLANG([],[]) 58145bcfd0SEric McConville 59145bcfd0SEric McConvillednl ********************************************************************** 609a052169STrond Norbyednl DETECT_SUNCC ([ACTION-IF-YES], [ACTION-IF-NO]) 619a052169STrond Norbyednl 629a052169STrond Norbyednl check if this is the Sun Studio compiler, and if so run the ACTION-IF-YES 639a052169STrond Norbyednl sets the $SUNCC variable to "yes" or "no" 649a052169STrond Norbyednl ********************************************************************** 659a052169STrond NorbyeAC_DEFUN([DETECT_SUNCC], 669a052169STrond Norbye[ 6721762900STrond Norbye AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) 6821762900STrond Norbye AS_IF(test "x$SUNCC" = "xyes", [$1], [$2]) 6921762900STrond Norbye 709a052169STrond Norbye]) 719a052169STrond Norbye 729a052169STrond NorbyeDETECT_SUNCC([CFLAGS="-mt $CFLAGS"], []) 73ad275883STrond NorbyeAS_IF([test "$ICC" = "yes" -o "$GCC" = "yes"], 74145bcfd0SEric McConville[ 75145bcfd0SEric McConville AS_IF(test "$CLANG" = "no",[CFLAGS="$CFLAGS -pthread"]) 76145bcfd0SEric McConville]) 779a052169STrond Norbye 786ea8f57bSDustin Sallingsif test "$ICC" = "no"; then 79725c26fbSDustin Sallings AC_PROG_CC_C99 80725c26fbSDustin Sallingsfi 81dfc5130eSDustin Sallings 829d99ab66SPaul LindnerAM_PROG_CC_C_O 831b533267SBrad FitzpatrickAC_PROG_INSTALL 841b533267SBrad Fitzpatrick 8548abfcccSDustin SallingsAC_ARG_ENABLE(sasl, 8648abfcccSDustin Sallings [AS_HELP_STRING([--enable-sasl],[Enable SASL authentication])]) 8748abfcccSDustin Sallings 887a221d95STrond NorbyeAC_ARG_ENABLE(sasl_pwdb, 897a221d95STrond Norbye [AS_HELP_STRING([--enable-sasl-pwdb],[Enable plaintext password db])]) 907a221d95STrond Norbye 917a221d95STrond NorbyeAS_IF([test "x$enable_sasl_pwdb" = "xyes"], 927a221d95STrond Norbye [enable_sasl=yes ]) 937a221d95STrond Norbye 947a221d95STrond Norbye 95145bcfd0SEric McConville 967a221d95STrond Norbyednl ********************************************************************** 977a221d95STrond Norbyednl DETECT_SASL_CB_GETCONF 987a221d95STrond Norbyednl 997a221d95STrond Norbyednl check if we can use SASL_CB_GETCONF 1007a221d95STrond Norbyednl ********************************************************************** 1017a221d95STrond NorbyeAC_DEFUN([AC_C_DETECT_SASL_CB_GETCONF], 1027a221d95STrond Norbye[ 1037a221d95STrond Norbye AC_CACHE_CHECK([for SASL_CB_GETCONF], 1047a221d95STrond Norbye [ac_cv_c_sasl_cb_getconf], 1057a221d95STrond Norbye [AC_TRY_COMPILE( 1067a221d95STrond Norbye [ 1077a221d95STrond Norbye#include <sasl/sasl.h> 1087a221d95STrond Norbye ], [ 1097a221d95STrond Norbyeunsigned long val = SASL_CB_GETCONF; 1107a221d95STrond Norbye ], 1117a221d95STrond Norbye [ ac_cv_c_sasl_cb_getconf=yes ], 1127a221d95STrond Norbye [ ac_cv_c_sasl_cb_getconf=no ]) 1137a221d95STrond Norbye ]) 1147a221d95STrond Norbye AS_IF([test "$ac_cv_c_sasl_cb_getconf" = "yes"], 1157a221d95STrond Norbye [AC_DEFINE([HAVE_SASL_CB_GETCONF], 1, 1167a221d95STrond Norbye [Set to nonzero if your SASL implementation supports SASL_CB_GETCONF])]) 1177a221d95STrond Norbye]) 1187a221d95STrond Norbye 11948abfcccSDustin SallingsAC_CHECK_HEADERS([sasl/sasl.h]) 12048abfcccSDustin Sallingsif test "x$enable_sasl" = "xyes"; then 1217a221d95STrond Norbye AC_C_DETECT_SASL_CB_GETCONF 12248abfcccSDustin Sallings AC_DEFINE([ENABLE_SASL],1,[Set to nonzero if you want to include SASL]) 1237a221d95STrond Norbye AC_SEARCH_LIBS([sasl_server_init], [sasl2 sasl], [], 12448abfcccSDustin Sallings [ 12548abfcccSDustin Sallings AC_MSG_ERROR([Failed to locate the library containing sasl_server_init]) 12648abfcccSDustin Sallings ]) 1277a221d95STrond Norbye 1287a221d95STrond Norbye AS_IF([test "x$enable_sasl_pwdb" = "xyes"], 1297a221d95STrond Norbye [AC_DEFINE([ENABLE_SASL_PWDB], 1, 1307a221d95STrond Norbye [Set to nonzero if you want to enable a SASL pwdb])]) 13148abfcccSDustin Sallingsfi 13248abfcccSDustin Sallings 13368957214STrond NorbyeAC_ARG_ENABLE(dtrace, 13468957214STrond Norbye [AS_HELP_STRING([--enable-dtrace],[Enable dtrace probes])]) 1354f847025SDustin Sallingsif test "x$enable_dtrace" = "xyes"; then 13668957214STrond Norbye AC_PATH_PROG([DTRACE], [dtrace], "no", [/usr/sbin:$PATH]) 13768957214STrond Norbye if test "x$DTRACE" != "xno"; then 13868957214STrond Norbye AC_DEFINE([ENABLE_DTRACE],1,[Set to nonzero if you want to include DTRACE]) 1397c23e79fSTrond Norbye build_dtrace=yes 140e440813dSTrond Norbye # DTrace on MacOSX does not use -G option 14140c8848bSTrond Norbye $DTRACE -G -o conftest.$$ -s memcached_dtrace.d 2>/dev/zero 142e440813dSTrond Norbye if test $? -eq 0 143e440813dSTrond Norbye then 1447c23e79fSTrond Norbye dtrace_instrument_obj=yes 145e440813dSTrond Norbye rm conftest.$$ 146e440813dSTrond Norbye fi 1474f5e1853STrond Norbye 1484f5e1853STrond Norbye if test "`which tr`" = "/usr/ucb/tr"; then 1494f5e1853STrond Norbye AC_MSG_ERROR([Please remove /usr/ucb from your path. See man standards for more info]) 1504f5e1853STrond Norbye fi 15168957214STrond Norbye else 15268957214STrond Norbye AC_MSG_ERROR([Need dtrace binary and OS support.]) 15368957214STrond Norbye fi 15468957214STrond Norbyefi 155e440813dSTrond Norbye 1567c23e79fSTrond NorbyeAM_CONDITIONAL([BUILD_DTRACE],[test "$build_dtrace" = "yes"]) 1577c23e79fSTrond NorbyeAM_CONDITIONAL([DTRACE_INSTRUMENT_OBJ],[test "$dtrace_instrument_obj" = "yes"]) 15848abfcccSDustin SallingsAM_CONDITIONAL([ENABLE_SASL],[test "$enable_sasl" = "yes"]) 1597c23e79fSTrond Norbye 16068957214STrond NorbyeAC_SUBST(DTRACE) 16168957214STrond NorbyeAC_SUBST(DTRACEFLAGS) 16248abfcccSDustin SallingsAC_SUBST(ENABLE_SASL) 1632a381c8aSDustin SallingsAC_SUBST(PROFILER_LDFLAGS) 16468957214STrond Norbye 1659a052169STrond NorbyeAC_ARG_ENABLE(coverage, 1669a052169STrond Norbye [AS_HELP_STRING([--disable-coverage],[Disable code coverage])]) 1679a052169STrond Norbye 1689a052169STrond Norbyeif test "x$enable_coverage" != "xno"; then 169145bcfd0SEric McConville if test "$GCC" = "yes" -a "$ICC" != "yes" -a "$CLANG" != "yes" 1700d560476SVictor Kirkebo then 171b416a193STrond Norbye CFLAGS="$CFLAGS -pthread" 1720d560476SVictor Kirkebo AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) 1730d560476SVictor Kirkebo if test "x$PROFILER" != "xno"; then 1749ff5b444STrond Norbye # Issue 97: The existense of gcov doesn't mean we have -lgcov 1759ff5b444STrond Norbye AC_CHECK_LIB(gcov, main, 1769ff5b444STrond Norbye [ 1770d560476SVictor Kirkebo PROFILER_FLAGS="-fprofile-arcs -ftest-coverage" 1782a381c8aSDustin Sallings PROFILER_LDFLAGS="-lgcov" 1799ff5b444STrond Norbye ], [ 1809ff5b444STrond Norbye PROFILER_FLAGS= 1819ff5b444STrond Norbye PROFILER_LDFLAGS= 1829ff5b444STrond Norbye ]) 1830d560476SVictor Kirkebo fi 1849a052169STrond Norbye elif test "$SUNCC" = "yes" 1859a052169STrond Norbye then 1860d560476SVictor Kirkebo AC_PATH_PROG([PROFILER], [tcov], "no", [$PATH]) 1870d560476SVictor Kirkebo if test "x$PROFILER" != "xno"; then 1880d560476SVictor Kirkebo PROFILER_FLAGS=-xprofile=tcov 1890d560476SVictor Kirkebo fi 190145bcfd0SEric McConville elif test "x$CLANG" != "xno" 191145bcfd0SEric McConville then 192145bcfd0SEric McConville AC_PATH_PROG([PROFILER], [gcov], "no", [$PATH]) 193145bcfd0SEric McConville if test "x$PROFILER" != "xno" 194145bcfd0SEric McConville then 195145bcfd0SEric McConville PROFILER_FLAGS="-fprofile-arcs -ftest-coverage" 196145bcfd0SEric McConville PROFILER_LDFLAGS= 197145bcfd0SEric McConville fi 1980d560476SVictor Kirkebo fi 1999a052169STrond Norbyefi 2000d560476SVictor KirkeboAC_SUBST(PROFILER_FLAGS) 2010d560476SVictor Kirkebo 2020d560476SVictor Kirkebo 2039281de40STrond NorbyeAC_ARG_ENABLE(64bit, 204b2e7e909SRicky Zhou [AS_HELP_STRING([--enable-64bit],[build 64bit version])]) 2054f847025SDustin Sallingsif test "x$enable_64bit" = "xyes" 2069281de40STrond Norbyethen 2079281de40STrond Norbye org_cflags=$CFLAGS 2089281de40STrond Norbye CFLAGS=-m64 2099281de40STrond Norbye AC_RUN_IFELSE( 2109281de40STrond Norbye [AC_LANG_PROGRAM([], [dnl 2119281de40STrond Norbyereturn sizeof(void*) == 8 ? 0 : 1; 2129281de40STrond Norbye ]) 2139281de40STrond Norbye ],[ 2149281de40STrond Norbye CFLAGS="-m64 $org_cflags" 2159281de40STrond Norbye ],[ 2169281de40STrond Norbye AC_MSG_ERROR([Don't know how to build a 64-bit object.]) 2179281de40STrond Norbye ]) 2189281de40STrond Norbyefi 2199281de40STrond Norbye 220f5111cc6STrond Norbye# Issue 213: Search for clock_gettime to help people linking 221f5111cc6STrond Norbye# with a static version of libevent 222f5111cc6STrond NorbyeAC_SEARCH_LIBS(clock_gettime, rt) 22356d95469STrond Norbye# Issue 214: Search for the network libraries _before_ searching 22456d95469STrond Norbye# for libevent (to help people linking with static libevent) 22556d95469STrond NorbyeAC_SEARCH_LIBS(socket, socket) 22656d95469STrond NorbyeAC_SEARCH_LIBS(gethostbyname, nsl) 227f5111cc6STrond Norbye 2281f11bf02SBrad Fitzpatricktrylibeventdir="" 2298405f723SEvan MartinAC_ARG_WITH(libevent, 2301f11bf02SBrad Fitzpatrick [ --with-libevent=PATH Specify path to libevent installation ], 2311f11bf02SBrad Fitzpatrick [ 2321f11bf02SBrad Fitzpatrick if test "x$withval" != "xno" ; then 2331f11bf02SBrad Fitzpatrick trylibeventdir=$withval 2348405f723SEvan Martin fi 2351f11bf02SBrad Fitzpatrick ] 2361f11bf02SBrad Fitzpatrick) 2371f11bf02SBrad Fitzpatrick 2381f11bf02SBrad Fitzpatrickdnl ------------------------------------------------------ 2391f11bf02SBrad Fitzpatrickdnl libevent detection. swiped from Tor. modified a bit. 2408405f723SEvan Martin 2418405f723SEvan MartinLIBEVENT_URL=http://www.monkey.org/~provos/libevent/ 2421f11bf02SBrad Fitzpatrick 2431f11bf02SBrad FitzpatrickAC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [ 2441f11bf02SBrad Fitzpatrick saved_LIBS="$LIBS" 2451f11bf02SBrad Fitzpatrick saved_LDFLAGS="$LDFLAGS" 2461f11bf02SBrad Fitzpatrick saved_CPPFLAGS="$CPPFLAGS" 2471f11bf02SBrad Fitzpatrick le_found=no 2481f11bf02SBrad Fitzpatrick for ledir in $trylibeventdir "" $prefix /usr/local ; do 2491f11bf02SBrad Fitzpatrick LDFLAGS="$saved_LDFLAGS" 25056d95469STrond Norbye LIBS="-levent $saved_LIBS" 2511f11bf02SBrad Fitzpatrick 2521f11bf02SBrad Fitzpatrick # Skip the directory if it isn't there. 2531f11bf02SBrad Fitzpatrick if test ! -z "$ledir" -a ! -d "$ledir" ; then 2541f11bf02SBrad Fitzpatrick continue; 2551f11bf02SBrad Fitzpatrick fi 2561f11bf02SBrad Fitzpatrick if test ! -z "$ledir" ; then 2571f11bf02SBrad Fitzpatrick if test -d "$ledir/lib" ; then 2581f11bf02SBrad Fitzpatrick LDFLAGS="-L$ledir/lib $LDFLAGS" 2591f11bf02SBrad Fitzpatrick else 2601f11bf02SBrad Fitzpatrick LDFLAGS="-L$ledir $LDFLAGS" 2611f11bf02SBrad Fitzpatrick fi 2621f11bf02SBrad Fitzpatrick if test -d "$ledir/include" ; then 2631f11bf02SBrad Fitzpatrick CPPFLAGS="-I$ledir/include $CPPFLAGS" 2641f11bf02SBrad Fitzpatrick else 2651f11bf02SBrad Fitzpatrick CPPFLAGS="-I$ledir $CPPFLAGS" 2661f11bf02SBrad Fitzpatrick fi 2671f11bf02SBrad Fitzpatrick fi 2681f11bf02SBrad Fitzpatrick # Can I compile and link it? 2691f11bf02SBrad Fitzpatrick AC_TRY_LINK([#include <sys/time.h> 2701f11bf02SBrad Fitzpatrick#include <sys/types.h> 2711f11bf02SBrad Fitzpatrick#include <event.h>], [ event_init(); ], 2721f11bf02SBrad Fitzpatrick [ libevent_linked=yes ], [ libevent_linked=no ]) 2731f11bf02SBrad Fitzpatrick if test $libevent_linked = yes; then 2741f11bf02SBrad Fitzpatrick if test ! -z "$ledir" ; then 2751f11bf02SBrad Fitzpatrick ac_cv_libevent_dir=$ledir 2763eb59952STrond Norbye _myos=`echo $target_os | cut -f 1 -d .` 2773eb59952STrond Norbye AS_IF(test "$SUNCC" = "yes" -o "x$_myos" = "xsolaris2", 2783eb59952STrond Norbye [saved_LDFLAGS="$saved_LDFLAGS -Wl,-R$ledir/lib"], 2793eb59952STrond Norbye [AS_IF(test "$GCC" = "yes", 2809d871c0eSTrond Norbye [saved_LDFLAGS="$saved_LDFLAGS -Wl,-rpath,$ledir/lib"])]) 2811f11bf02SBrad Fitzpatrick else 2821f11bf02SBrad Fitzpatrick ac_cv_libevent_dir="(system)" 2831f11bf02SBrad Fitzpatrick fi 2841f11bf02SBrad Fitzpatrick le_found=yes 2851f11bf02SBrad Fitzpatrick break 2861f11bf02SBrad Fitzpatrick fi 2871f11bf02SBrad Fitzpatrick done 2881f11bf02SBrad Fitzpatrick LIBS="$saved_LIBS" 2891f11bf02SBrad Fitzpatrick LDFLAGS="$saved_LDFLAGS" 2901f11bf02SBrad Fitzpatrick CPPFLAGS="$saved_CPPFLAGS" 2911f11bf02SBrad Fitzpatrick if test $le_found = no ; then 2921f11bf02SBrad Fitzpatrick AC_MSG_ERROR([libevent is required. You can get it from $LIBEVENT_URL 2931f11bf02SBrad Fitzpatrick 2941f11bf02SBrad Fitzpatrick If it's already installed, specify its path using --with-libevent=/dir/ 2951f11bf02SBrad Fitzpatrick]) 2961f11bf02SBrad Fitzpatrick fi 2971f11bf02SBrad Fitzpatrick]) 29856d95469STrond NorbyeLIBS="-levent $LIBS" 2991f11bf02SBrad Fitzpatrickif test $ac_cv_libevent_dir != "(system)"; then 3001f11bf02SBrad Fitzpatrick if test -d "$ac_cv_libevent_dir/lib" ; then 3011f11bf02SBrad Fitzpatrick LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS" 3021f11bf02SBrad Fitzpatrick le_libdir="$ac_cv_libevent_dir/lib" 3031f11bf02SBrad Fitzpatrick else 3041f11bf02SBrad Fitzpatrick LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS" 3051f11bf02SBrad Fitzpatrick le_libdir="$ac_cv_libevent_dir" 3061f11bf02SBrad Fitzpatrick fi 3071f11bf02SBrad Fitzpatrick if test -d "$ac_cv_libevent_dir/include" ; then 3081f11bf02SBrad Fitzpatrick CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS" 3091f11bf02SBrad Fitzpatrick else 3101f11bf02SBrad Fitzpatrick CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS" 3111f11bf02SBrad Fitzpatrick fi 3121f11bf02SBrad Fitzpatrickfi 3131f11bf02SBrad Fitzpatrick 3141f11bf02SBrad Fitzpatrickdnl ---------------------------------------------------------------------------- 3158405f723SEvan Martin 316ed69f308STrond NorbyeAC_SEARCH_LIBS(umem_cache_create, umem) 31773628d3eSTrond NorbyeAC_SEARCH_LIBS(gethugepagesizes, hugetlbfs) 31848abfcccSDustin Sallings 31977dde9f9SPaul LindnerAC_HEADER_STDBOOL 32024869322STrond NorbyeAH_BOTTOM([#if HAVE_STDBOOL_H 32124869322STrond Norbye#include <stdbool.h> 32224869322STrond Norbye#else 32324869322STrond Norbye#define bool char 32424869322STrond Norbye#define false 0 32524869322STrond Norbye#define true 1 32624869322STrond Norbye#endif ]) 32724869322STrond Norbye 32824869322STrond NorbyeAC_CHECK_HEADERS([inttypes.h]) 32924869322STrond NorbyeAH_BOTTOM([#ifdef HAVE_INTTYPES_H 33024869322STrond Norbye#include <inttypes.h> 33124869322STrond Norbye#endif 33224869322STrond Norbye]) 33324869322STrond Norbye 33424869322STrond Norbyednl ********************************************************************** 335dece7f87SDustin Sallingsdnl Figure out if this system has the stupid sasl_callback_ft 336dece7f87SDustin Sallingsdnl ********************************************************************** 337dece7f87SDustin Sallings 338dece7f87SDustin SallingsAC_DEFUN([AC_HAVE_SASL_CALLBACK_FT], 339dece7f87SDustin Sallings[AC_CACHE_CHECK(for sasl_callback_ft, ac_cv_has_sasl_callback_ft, 340dece7f87SDustin Sallings[ 341dece7f87SDustin Sallings AC_TRY_COMPILE([ 342dece7f87SDustin Sallings #ifdef HAVE_SASL_SASL_H 343dece7f87SDustin Sallings #include <sasl/sasl.h> 344dece7f87SDustin Sallings #include <sasl/saslplug.h> 345dece7f87SDustin Sallings #endif 346dece7f87SDustin Sallings ],[ 347dece7f87SDustin Sallings sasl_callback_ft a_callback; 348dece7f87SDustin Sallings ],[ 349dece7f87SDustin Sallings ac_cv_has_sasl_callback_ft=yes 350dece7f87SDustin Sallings ],[ 351dece7f87SDustin Sallings ac_cv_has_sasl_callback_ft=no 352dece7f87SDustin Sallings ]) 353dece7f87SDustin Sallings]) 354dece7f87SDustin Sallingsif test $ac_cv_has_sasl_callback_ft = yes; then 355dece7f87SDustin Sallings AC_DEFINE(HAVE_SASL_CALLBACK_FT, 1, [we have sasl_callback_ft]) 356dece7f87SDustin Sallingsfi 357dece7f87SDustin Sallings]) 358dece7f87SDustin Sallings 359dece7f87SDustin SallingsAC_HAVE_SASL_CALLBACK_FT 360dece7f87SDustin Sallings 361dece7f87SDustin Sallingsdnl ********************************************************************** 36224869322STrond Norbyednl DETECT_UINT64_SUPPORT 36324869322STrond Norbyednl 36424869322STrond Norbyednl check if we can use a uint64_t 36524869322STrond Norbyednl ********************************************************************** 36624869322STrond NorbyeAC_DEFUN([AC_C_DETECT_UINT64_SUPPORT], 36724869322STrond Norbye[ 36824869322STrond Norbye AC_CACHE_CHECK([for print macros for integers (C99 section 7.8.1)], 36924869322STrond Norbye [ac_cv_c_uint64_support], 37024869322STrond Norbye [AC_TRY_COMPILE( 37124869322STrond Norbye [ 37224869322STrond Norbye#ifdef HAVE_INTTYPES_H 37324869322STrond Norbye#include <inttypes.h> 37424869322STrond Norbye#endif 37524869322STrond Norbye#include <stdio.h> 37624869322STrond Norbye ], [ 37724869322STrond Norbye uint64_t val = 0; 37824869322STrond Norbye fprintf(stderr, "%" PRIu64 "\n", val); 37924869322STrond Norbye ], 38024869322STrond Norbye [ ac_cv_c_uint64_support=yes ], 38124869322STrond Norbye [ ac_cv_c_uint64_support=no ]) 38224869322STrond Norbye ]) 38324869322STrond Norbye]) 38424869322STrond Norbye 38524869322STrond NorbyeAC_C_DETECT_UINT64_SUPPORT 38624869322STrond NorbyeAS_IF([test "x$ac_cv_c_uint64_support" = "xno"], 38724869322STrond Norbye [AC_MSG_WARN([ 38824869322STrond Norbye 38924869322STrond NorbyeFailed to use print macros (PRIu) as defined in C99 section 7.8.1. 39024869322STrond Norbye 39124869322STrond Norbye])]) 39224869322STrond Norbye 39377dde9f9SPaul LindnerAC_C_CONST 394afb95eccSTrond Norbye 3958405f723SEvan Martindnl From licq: Copyright (c) 2000 Dirk Mueller 3968405f723SEvan Martindnl Check if the type socklen_t is defined anywhere 39729d0d2caSPaul LindnerAC_DEFUN([AC_C_SOCKLEN_T], 3988405f723SEvan Martin[AC_CACHE_CHECK(for socklen_t, ac_cv_c_socklen_t, 3998405f723SEvan Martin[ 4008405f723SEvan Martin AC_TRY_COMPILE([ 4018405f723SEvan Martin #include <sys/types.h> 4028405f723SEvan Martin #include <sys/socket.h> 4038405f723SEvan Martin ],[ 4048405f723SEvan Martin socklen_t foo; 4058405f723SEvan Martin ],[ 4068405f723SEvan Martin ac_cv_c_socklen_t=yes 4078405f723SEvan Martin ],[ 4088405f723SEvan Martin ac_cv_c_socklen_t=no 4098405f723SEvan Martin ]) 4108405f723SEvan Martin]) 4118405f723SEvan Martinif test $ac_cv_c_socklen_t = no; then 4128405f723SEvan Martin AC_DEFINE(socklen_t, int, [define to int if socklen_t not available]) 4138405f723SEvan Martinfi 4148405f723SEvan Martin]) 4158405f723SEvan Martin 4168405f723SEvan MartinAC_C_SOCKLEN_T 4178405f723SEvan Martin 41828a8165fSSteven Grimmdnl Check if we're a little-endian or a big-endian system, needed by hash code 41929d0d2caSPaul LindnerAC_DEFUN([AC_C_ENDIAN], 42028a8165fSSteven Grimm[AC_CACHE_CHECK(for endianness, ac_cv_c_endian, 42128a8165fSSteven Grimm[ 42228a8165fSSteven Grimm AC_RUN_IFELSE( 42328a8165fSSteven Grimm [AC_LANG_PROGRAM([], [dnl 42428a8165fSSteven Grimm long val = 1; 42528a8165fSSteven Grimm char *c = (char *) &val; 42628a8165fSSteven Grimm exit(*c == 1); 42728a8165fSSteven Grimm ]) 42828a8165fSSteven Grimm ],[ 42928a8165fSSteven Grimm ac_cv_c_endian=big 43028a8165fSSteven Grimm ],[ 43128a8165fSSteven Grimm ac_cv_c_endian=little 43228a8165fSSteven Grimm ]) 43328a8165fSSteven Grimm]) 43428a8165fSSteven Grimmif test $ac_cv_c_endian = big; then 43528a8165fSSteven Grimm AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian]) 43628a8165fSSteven Grimmfi 43728a8165fSSteven Grimmif test $ac_cv_c_endian = little; then 43828a8165fSSteven Grimm AC_DEFINE(ENDIAN_LITTLE, 1, [machine is littleendian]) 43928a8165fSSteven Grimmfi 44028a8165fSSteven Grimm]) 44128a8165fSSteven Grimm 44228a8165fSSteven GrimmAC_C_ENDIAN 44328a8165fSSteven Grimm 4449791b779STrond NorbyeAC_DEFUN([AC_C_HTONLL], 4459791b779STrond Norbye[ 4469791b779STrond Norbye AC_MSG_CHECKING([for htonll]) 4479791b779STrond Norbye have_htoll="no" 44821762900STrond Norbye AC_TRY_LINK([ 4499791b779STrond Norbye#include <sys/types.h> 4509791b779STrond Norbye#include <netinet/in.h> 45124869322STrond Norbye#ifdef HAVE_INTTYPES_H 45224869322STrond Norbye#include <inttypes.h> */ 45324869322STrond Norbye#endif 4549791b779STrond Norbye ], [ 4559791b779STrond Norbye return htonll(0); 4569791b779STrond Norbye ], [ 4579791b779STrond Norbye have_htoll="yes" 4589791b779STrond Norbye AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll]) 45921762900STrond Norbye ], [ 46021762900STrond Norbye have_htoll="no" 4619791b779STrond Norbye ]) 4629791b779STrond Norbye 4639791b779STrond Norbye AC_MSG_RESULT([$have_htoll]) 4649791b779STrond Norbye]) 4659791b779STrond Norbye 4669791b779STrond NorbyeAC_C_HTONLL 4679791b779STrond Norbye 468a9dcd9acSToru Maesakadnl Check whether the user's system supports pthread 4690cb75e3dSTomash BrechkoAC_SEARCH_LIBS(pthread_create, pthread) 4704f847025SDustin Sallingsif test "x$ac_cv_search_pthread_create" = "xno"; then 47156b8339eSSteven Grimm AC_MSG_ERROR([Can't enable threads without the POSIX thread library.]) 4720cb75e3dSTomash Brechkofi 47356b8339eSSteven Grimm 474a8e605d9SBrion VibberAC_CHECK_FUNCS(mlockall) 475a6b35b44STrond NorbyeAC_CHECK_FUNCS(getpagesizes) 476a6b35b44STrond NorbyeAC_CHECK_FUNCS(memcntl) 477ee0c3d5aSTrond NorbyeAC_CHECK_FUNCS(sigignore) 478569decdbSdormandoAC_CHECK_FUNCS(clock_gettime) 4796d02111bSSimon LiuAC_CHECK_FUNCS([accept4], [AC_DEFINE(HAVE_ACCEPT4, 1, [Define to 1 if support accept4])]) 480a8e605d9SBrion Vibber 4815268604aSTrond NorbyeAC_DEFUN([AC_C_ALIGNMENT], 4825268604aSTrond Norbye[AC_CACHE_CHECK(for alignment, ac_cv_c_alignment, 4835268604aSTrond Norbye[ 4845268604aSTrond Norbye AC_RUN_IFELSE( 4855268604aSTrond Norbye [AC_LANG_PROGRAM([ 4865268604aSTrond Norbye#include <stdlib.h> 4875268604aSTrond Norbye#include <inttypes.h> 4885268604aSTrond Norbye ], [ 4895268604aSTrond Norbye char *buf = malloc(32); 490ba7fdc5bSPaul Lindner 4915268604aSTrond Norbye uint64_t *ptr = (uint64_t*)(buf+2); 492ba7fdc5bSPaul Lindner // catch sigbus, etc. 4935268604aSTrond Norbye *ptr = 0x1; 494ba7fdc5bSPaul Lindner 495ba7fdc5bSPaul Lindner // catch unaligned word access (ARM cpus) 4962fa661a7SDagobert Michelsen#ifdef ENDIAN_BIG 497f19571abSEric McConville#define ALIGNMENT 0x02030405 4982fa661a7SDagobert Michelsen#else 499f19571abSEric McConville#define ALIGNMENT 0x05040302 5002fa661a7SDagobert Michelsen#endif 501f19571abSEric McConville *(buf + 0) = 1; 502f19571abSEric McConville *(buf + 1) = 2; 503f19571abSEric McConville *(buf + 2) = 3; 504f19571abSEric McConville *(buf + 3) = 4; 505f19571abSEric McConville *(buf + 4) = 5; 506f19571abSEric McConville int* i = (int*)(buf+1); 507f19571abSEric McConville return (ALIGNMENT == *i) ? 0 : 1; 5085268604aSTrond Norbye ]) 5095268604aSTrond Norbye ],[ 5105268604aSTrond Norbye ac_cv_c_alignment=none 5115268604aSTrond Norbye ],[ 512ca51c3d4SMat Hostetter ac_cv_c_alignment=need 51321762900STrond Norbye ],[ 51421762900STrond Norbye ac_cv_c_alignment=need 5155268604aSTrond Norbye ]) 5165268604aSTrond Norbye]) 517ca51c3d4SMat Hostetterif test $ac_cv_c_alignment = need; then 5185268604aSTrond Norbye AC_DEFINE(NEED_ALIGN, 1, [Machine need alignment]) 5195268604aSTrond Norbyefi 5205268604aSTrond Norbye]) 5215268604aSTrond Norbye 5225268604aSTrond NorbyeAC_C_ALIGNMENT 5235268604aSTrond Norbye 524de1f30c5Sdormandodnl Check for our specific usage of GCC atomics. 525de1f30c5Sdormandodnl These were added in 4.1.2, but 32bit OS's may lack shorts and 4.1.2 526de1f30c5Sdormandodnl lacks testable defines. 527de1f30c5Sdormandohave_gcc_atomics=no 528de1f30c5SdormandoAC_MSG_CHECKING(for GCC atomics) 529de1f30c5SdormandoAC_TRY_LINK([],[ 530de1f30c5Sdormando unsigned short a; 531de1f30c5Sdormando unsigned short b; 532de1f30c5Sdormando b = __sync_add_and_fetch(&a, 1); 533de1f30c5Sdormando b = __sync_sub_and_fetch(&a, 2); 534de1f30c5Sdormando ],[have_gcc_atomics=yes 535de1f30c5Sdormando AC_DEFINE(HAVE_GCC_ATOMICS, 1, [GCC Atomics available])]) 536de1f30c5SdormandoAC_MSG_RESULT($have_gcc_atomics) 537de1f30c5Sdormando 538*60e98600Sdormandodnl Check for usage of 64bit atomics 539*60e98600Sdormandodnl 32bit systems shouldn't have these. 540*60e98600Sdormandohave_gcc_64atomics=no 541*60e98600SdormandoAC_MSG_CHECKING(for GCC 64bit atomics) 542*60e98600SdormandoAC_TRY_LINK([],[ 543*60e98600Sdormando uint64_t a; 544*60e98600Sdormando uint64_t b; 545*60e98600Sdormando b = __sync_add_and_fetch(&a, 1); 546*60e98600Sdormando b = __sync_sub_and_fetch(&a, 2); 547*60e98600Sdormando ],[have_gcc_64atomics=yes 548*60e98600Sdormando AC_DEFINE(HAVE_GCC_64ATOMICS, 1, [GCC 64bit Atomics available])]) 549*60e98600SdormandoAC_MSG_RESULT($have_gcc_64atomics) 550*60e98600Sdormando 55169aa5427STrond Norbyednl Check for the requirements for running memcached with less privileges 55269aa5427STrond Norbyednl than the default privilege set. On Solaris we need setppriv and priv.h 55369aa5427STrond Norbyednl If you want to add support for other platforms you should check for 55469aa5427STrond Norbyednl your requirements, define HAVE_DROP_PRIVILEGES, and make sure you add 55569aa5427STrond Norbyednl the source file containing the implementation into memcached_SOURCE 55669aa5427STrond Norbyednl in Makefile.am 55769aa5427STrond NorbyeAC_CHECK_FUNCS(setppriv, [ 55869aa5427STrond Norbye AC_CHECK_HEADER(priv.h, [ 55969aa5427STrond Norbye AC_DEFINE([HAVE_DROP_PRIVILEGES], 1, 56069aa5427STrond Norbye [Define this if you have an implementation of drop_privileges()]) 56169aa5427STrond Norbye build_solaris_privs=yes 56269aa5427STrond Norbye ], []) 56369aa5427STrond Norbye],[]) 56469aa5427STrond Norbye 56569aa5427STrond NorbyeAM_CONDITIONAL([BUILD_SOLARIS_PRIVS],[test "$build_solaris_privs" = "yes"]) 56669aa5427STrond Norbye 5674c86fa59STrond NorbyeAC_CHECK_HEADER(umem.h, [ 5684c86fa59STrond Norbye AC_DEFINE([HAVE_UMEM_H], 1, 5694c86fa59STrond Norbye [Define this if you have umem.h]) 5704c86fa59STrond Norbye build_cache=no 5714c86fa59STrond Norbye], [build_cache=yes]) 5724c86fa59STrond Norbye 5734c86fa59STrond NorbyeAM_CONDITIONAL([BUILD_CACHE], [test "x$build_cache" = "xyes"]) 5744c86fa59STrond Norbye 57520c62383SDustin SallingsAC_ARG_ENABLE(docs, 57620c62383SDustin Sallings [AS_HELP_STRING([--disable-docs],[Disable documentation generation])]) 57720c62383SDustin Sallings 578f181a24dSTrond NorbyeAC_PATH_PROG([XML2RFC], [xml2rfc], "no") 579f181a24dSTrond NorbyeAC_PATH_PROG([XSLTPROC], [xsltproc], "no") 58020c62383SDustin Sallings 58120c62383SDustin SallingsAM_CONDITIONAL([BUILD_SPECIFICATIONS], 58220c62383SDustin Sallings [test "x$enable_docs" != "xno" -a "x$XML2RFC" != "xno" -a "x$XSLTPROC" != "xno"]) 58320c62383SDustin Sallings 584f181a24dSTrond Norbye 585df1b7e42STrond Norbyednl Let the compiler be a bit more picky. Please note that you cannot 586df1b7e42STrond Norbyednl specify these flags to the compiler before AC_CHECK_FUNCS, because 587df1b7e42STrond Norbyednl the test program will generate a compilation warning and hence fail 588df1b7e42STrond Norbyednl to detect the function ;-) 589dfc5130eSDustin Sallingsif test "$ICC" = "yes" 590dfc5130eSDustin Sallingsthen 591dfc5130eSDustin Sallings dnl ICC trying to be gcc. 5928e328be3SDustin Sallings CFLAGS="$CFLAGS -diag-disable 187 -Wall -Werror" 593ee0c3d5aSTrond Norbye AC_DEFINE([_GNU_SOURCE],[1],[find sigignore on Linux]) 594dfc5130eSDustin Sallingselif test "$GCC" = "yes" 595df1b7e42STrond Norbyethen 596d747f593SDustin Sallings GCC_VERSION=`$CC -dumpversion` 597da3d85a5SDustin Sallings CFLAGS="$CFLAGS -Wall -Werror -pedantic -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls" 59812ae7678SDustin Sallings case $GCC_VERSION in 59912ae7678SDustin Sallings 4.4.*) 60012ae7678SDustin Sallings CFLAGS="$CFLAGS -fno-strict-aliasing" 60112ae7678SDustin Sallings ;; 60212ae7678SDustin Sallings esac 603ee0c3d5aSTrond Norbye AC_DEFINE([_GNU_SOURCE],[1],[find sigignore on Linux]) 6049a052169STrond Norbyeelif test "$SUNCC" = "yes" 605df1b7e42STrond Norbyethen 606df1b7e42STrond Norbye CFLAGS="$CFLAGS -errfmt=error -errwarn -errshort=tags" 607df1b7e42STrond Norbyefi 608df1b7e42STrond Norbye 609b585e734SDavid PhillipsAC_CONFIG_FILES(Makefile doc/Makefile) 6101b533267SBrad FitzpatrickAC_OUTPUT 611