| 1 | AC_PREREQ(2.52) |
|---|
| 2 | AC_INIT(memcached, 1.2.4, brad@danga.com) |
|---|
| 3 | AC_CANONICAL_SYSTEM |
|---|
| 4 | AC_CONFIG_SRCDIR(memcached.c) |
|---|
| 5 | AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) |
|---|
| 6 | AM_CONFIG_HEADER(config.h) |
|---|
| 7 | |
|---|
| 8 | AC_PROG_CC |
|---|
| 9 | AM_PROG_CC_C_O |
|---|
| 10 | AC_PROG_INSTALL |
|---|
| 11 | |
|---|
| 12 | AC_ARG_ENABLE(64bit, |
|---|
| 13 | [AS_HELP_STRING([--enable-64bit],[build 64bit verison])]) |
|---|
| 14 | if test "x$enable_64bit" == "xyes" |
|---|
| 15 | then |
|---|
| 16 | org_cflags=$CFLAGS |
|---|
| 17 | CFLAGS=-m64 |
|---|
| 18 | AC_RUN_IFELSE( |
|---|
| 19 | [AC_LANG_PROGRAM([], [dnl |
|---|
| 20 | return sizeof(void*) == 8 ? 0 : 1; |
|---|
| 21 | ]) |
|---|
| 22 | ],[ |
|---|
| 23 | CFLAGS="-m64 $org_cflags" |
|---|
| 24 | ],[ |
|---|
| 25 | AC_MSG_ERROR([Don't know how to build a 64-bit object.]) |
|---|
| 26 | ]) |
|---|
| 27 | fi |
|---|
| 28 | |
|---|
| 29 | trylibeventdir="" |
|---|
| 30 | AC_ARG_WITH(libevent, |
|---|
| 31 | [ --with-libevent=PATH Specify path to libevent installation ], |
|---|
| 32 | [ |
|---|
| 33 | if test "x$withval" != "xno" ; then |
|---|
| 34 | trylibeventdir=$withval |
|---|
| 35 | fi |
|---|
| 36 | ] |
|---|
| 37 | ) |
|---|
| 38 | |
|---|
| 39 | dnl ------------------------------------------------------ |
|---|
| 40 | dnl libevent detection. swiped from Tor. modified a bit. |
|---|
| 41 | |
|---|
| 42 | LIBEVENT_URL=http://www.monkey.org/~provos/libevent/ |
|---|
| 43 | |
|---|
| 44 | AC_CACHE_CHECK([for libevent directory], ac_cv_libevent_dir, [ |
|---|
| 45 | saved_LIBS="$LIBS" |
|---|
| 46 | saved_LDFLAGS="$LDFLAGS" |
|---|
| 47 | saved_CPPFLAGS="$CPPFLAGS" |
|---|
| 48 | le_found=no |
|---|
| 49 | for ledir in $trylibeventdir "" $prefix /usr/local ; do |
|---|
| 50 | LDFLAGS="$saved_LDFLAGS" |
|---|
| 51 | LIBS="$saved_LIBS -levent" |
|---|
| 52 | |
|---|
| 53 | # Skip the directory if it isn't there. |
|---|
| 54 | if test ! -z "$ledir" -a ! -d "$ledir" ; then |
|---|
| 55 | continue; |
|---|
| 56 | fi |
|---|
| 57 | if test ! -z "$ledir" ; then |
|---|
| 58 | if test -d "$ledir/lib" ; then |
|---|
| 59 | LDFLAGS="-L$ledir/lib $LDFLAGS" |
|---|
| 60 | else |
|---|
| 61 | LDFLAGS="-L$ledir $LDFLAGS" |
|---|
| 62 | fi |
|---|
| 63 | if test -d "$ledir/include" ; then |
|---|
| 64 | CPPFLAGS="-I$ledir/include $CPPFLAGS" |
|---|
| 65 | else |
|---|
| 66 | CPPFLAGS="-I$ledir $CPPFLAGS" |
|---|
| 67 | fi |
|---|
| 68 | fi |
|---|
| 69 | # Can I compile and link it? |
|---|
| 70 | AC_TRY_LINK([#include <sys/time.h> |
|---|
| 71 | #include <sys/types.h> |
|---|
| 72 | #include <event.h>], [ event_init(); ], |
|---|
| 73 | [ libevent_linked=yes ], [ libevent_linked=no ]) |
|---|
| 74 | if test $libevent_linked = yes; then |
|---|
| 75 | if test ! -z "$ledir" ; then |
|---|
| 76 | ac_cv_libevent_dir=$ledir |
|---|
| 77 | else |
|---|
| 78 | ac_cv_libevent_dir="(system)" |
|---|
| 79 | fi |
|---|
| 80 | le_found=yes |
|---|
| 81 | break |
|---|
| 82 | fi |
|---|
| 83 | done |
|---|
| 84 | LIBS="$saved_LIBS" |
|---|
| 85 | LDFLAGS="$saved_LDFLAGS" |
|---|
| 86 | CPPFLAGS="$saved_CPPFLAGS" |
|---|
| 87 | if test $le_found = no ; then |
|---|
| 88 | AC_MSG_ERROR([libevent is required. You can get it from $LIBEVENT_URL |
|---|
| 89 | |
|---|
| 90 | If it's already installed, specify its path using --with-libevent=/dir/ |
|---|
| 91 | ]) |
|---|
| 92 | fi |
|---|
| 93 | ]) |
|---|
| 94 | LIBS="$LIBS -levent" |
|---|
| 95 | if test $ac_cv_libevent_dir != "(system)"; then |
|---|
| 96 | if test -d "$ac_cv_libevent_dir/lib" ; then |
|---|
| 97 | LDFLAGS="-L$ac_cv_libevent_dir/lib $LDFLAGS" |
|---|
| 98 | le_libdir="$ac_cv_libevent_dir/lib" |
|---|
| 99 | else |
|---|
| 100 | LDFLAGS="-L$ac_cv_libevent_dir $LDFLAGS" |
|---|
| 101 | le_libdir="$ac_cv_libevent_dir" |
|---|
| 102 | fi |
|---|
| 103 | if test -d "$ac_cv_libevent_dir/include" ; then |
|---|
| 104 | CPPFLAGS="-I$ac_cv_libevent_dir/include $CPPFLAGS" |
|---|
| 105 | else |
|---|
| 106 | CPPFLAGS="-I$ac_cv_libevent_dir $CPPFLAGS" |
|---|
| 107 | fi |
|---|
| 108 | fi |
|---|
| 109 | |
|---|
| 110 | dnl ---------------------------------------------------------------------------- |
|---|
| 111 | |
|---|
| 112 | AC_SEARCH_LIBS(socket, socket) |
|---|
| 113 | AC_SEARCH_LIBS(gethostbyname, nsl) |
|---|
| 114 | AC_SEARCH_LIBS(mallinfo, malloc) |
|---|
| 115 | |
|---|
| 116 | AC_CHECK_FUNC(daemon,AC_DEFINE([HAVE_DAEMON],,[Define this if you have daemon()]),[AC_LIBOBJ(daemon)]) |
|---|
| 117 | |
|---|
| 118 | AC_HEADER_STDBOOL |
|---|
| 119 | AC_C_CONST |
|---|
| 120 | AC_CHECK_HEADER(malloc.h, AC_DEFINE(HAVE_MALLOC_H,,[do we have malloc.h?])) |
|---|
| 121 | AC_CHECK_MEMBER([struct mallinfo.arena], [ |
|---|
| 122 | AC_DEFINE(HAVE_STRUCT_MALLINFO,,[do we have stuct mallinfo?]) |
|---|
| 123 | ], ,[ |
|---|
| 124 | # include <malloc.h> |
|---|
| 125 | ] |
|---|
| 126 | ) |
|---|
| 127 | |
|---|
| 128 | dnl From licq: Copyright (c) 2000 Dirk Mueller |
|---|
| 129 | dnl Check if the type socklen_t is defined anywhere |
|---|
| 130 | AC_DEFUN([AC_C_SOCKLEN_T], |
|---|
| 131 | [AC_CACHE_CHECK(for socklen_t, ac_cv_c_socklen_t, |
|---|
| 132 | [ |
|---|
| 133 | AC_TRY_COMPILE([ |
|---|
| 134 | #include <sys/types.h> |
|---|
| 135 | #include <sys/socket.h> |
|---|
| 136 | ],[ |
|---|
| 137 | socklen_t foo; |
|---|
| 138 | ],[ |
|---|
| 139 | ac_cv_c_socklen_t=yes |
|---|
| 140 | ],[ |
|---|
| 141 | ac_cv_c_socklen_t=no |
|---|
| 142 | ]) |
|---|
| 143 | ]) |
|---|
| 144 | if test $ac_cv_c_socklen_t = no; then |
|---|
| 145 | AC_DEFINE(socklen_t, int, [define to int if socklen_t not available]) |
|---|
| 146 | fi |
|---|
| 147 | ]) |
|---|
| 148 | |
|---|
| 149 | AC_C_SOCKLEN_T |
|---|
| 150 | |
|---|
| 151 | dnl Check if we're a little-endian or a big-endian system, needed by hash code |
|---|
| 152 | AC_DEFUN([AC_C_ENDIAN], |
|---|
| 153 | [AC_CACHE_CHECK(for endianness, ac_cv_c_endian, |
|---|
| 154 | [ |
|---|
| 155 | AC_RUN_IFELSE( |
|---|
| 156 | [AC_LANG_PROGRAM([], [dnl |
|---|
| 157 | long val = 1; |
|---|
| 158 | char *c = (char *) &val; |
|---|
| 159 | exit(*c == 1); |
|---|
| 160 | ]) |
|---|
| 161 | ],[ |
|---|
| 162 | ac_cv_c_endian=big |
|---|
| 163 | ],[ |
|---|
| 164 | ac_cv_c_endian=little |
|---|
| 165 | ]) |
|---|
| 166 | ]) |
|---|
| 167 | if test $ac_cv_c_endian = big; then |
|---|
| 168 | AC_DEFINE(ENDIAN_BIG, 1, [machine is bigendian]) |
|---|
| 169 | fi |
|---|
| 170 | if test $ac_cv_c_endian = little; then |
|---|
| 171 | AC_DEFINE(ENDIAN_LITTLE, 1, [machine is littleendian]) |
|---|
| 172 | fi |
|---|
| 173 | ]) |
|---|
| 174 | |
|---|
| 175 | AC_C_ENDIAN |
|---|
| 176 | |
|---|
| 177 | dnl Check whether the user wants threads or not |
|---|
| 178 | AC_ARG_ENABLE(threads, |
|---|
| 179 | [AS_HELP_STRING([--enable-threads],[support multithreaded execution])]) |
|---|
| 180 | if test "x$enable_threads" == "xyes"; then |
|---|
| 181 | AC_SEARCH_LIBS(pthread_create, pthread) |
|---|
| 182 | if test "x$ac_cv_search_pthread_create" != "xno"; then |
|---|
| 183 | AC_DEFINE([USE_THREADS],,[Define this if you want to use pthreads]) |
|---|
| 184 | dnl Sun compilers need the -mt flag! |
|---|
| 185 | AC_RUN_IFELSE( |
|---|
| 186 | [AC_LANG_PROGRAM([], [dnl |
|---|
| 187 | #ifdef __SUNPRO_C |
|---|
| 188 | return 0; |
|---|
| 189 | #else |
|---|
| 190 | return 1; |
|---|
| 191 | #endif |
|---|
| 192 | ]) |
|---|
| 193 | ],[ |
|---|
| 194 | CFLAGS="-mt $CFLAGS" |
|---|
| 195 | ]) |
|---|
| 196 | else |
|---|
| 197 | AC_MSG_ERROR([Can't enable threads without the POSIX thread library.]) |
|---|
| 198 | fi |
|---|
| 199 | fi |
|---|
| 200 | |
|---|
| 201 | AC_CHECK_FUNCS(mlockall) |
|---|
| 202 | AC_CHECK_FUNCS(getpagesizes) |
|---|
| 203 | AC_CHECK_FUNCS(memcntl) |
|---|
| 204 | |
|---|
| 205 | AC_CONFIG_FILES(Makefile doc/Makefile) |
|---|
| 206 | AC_OUTPUT |
|---|