Step one for preallocation on several platforms.
[beanstalkd.git] / configure.in
blob3bc24951b265aec7e2d7b85633c084f99dc424eb
1 dnl this files has to be processed by autoconf
2 AC_PREREQ(2.61)
4 AC_INIT
5 AC_CONFIG_SRCDIR([README])
6 AC_CONFIG_SRCDIR(job.c)
7 AC_CONFIG_HEADERS(config.h)
8 AM_INIT_AUTOMAKE(beanstalkd,$($srcdir/version.sh))
9 AM_MAINTAINER_MODE
11 AC_PROG_CC
12 AC_PROG_INSTALL
14 DEFAULT_INSTALL_PREFIX="/usr/local"
15 STANDARD_PREFIXES="/usr /usr/local /opt /local"
18 dnl {{{ --with-libdir
19 AC_ARG_WITH(libdir,
20   [AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
21   ],
22   [LIBDIR=$with_libdir],
23   [LIBDIR=lib]
25 dnl }}}
27 dnl {{{ --disable-rpath
28 AC_ARG_ENABLE(rpath,
29   [AS_HELP_STRING([--disable-rpath],[disable passing additional runtime library search paths])
30   ],
31   [BEAN_RPATH=no],
32   [BEAN_RPATH=yes]
34 dnl }}}
36 dnl {{{ check for rpath support
37 AC_MSG_CHECKING([if compiler supports -R])
38 AC_CACHE_VAL(bt_cv_cc_dashr,[
39   SAVE_LIBS=$LIBS
40   LIBS="-R /usr/$LIBDIR $LIBS"
41   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_dashr=yes],[bt_cv_cc_dashr=no])
42   LIBS=$SAVE_LIBS])
43 AC_MSG_RESULT([$bt_cv_cc_dashr])
44 if test $bt_cv_cc_dashr = "yes"; then
45   ld_runpath_switch=-R
46 else
47   AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
48   AC_CACHE_VAL(bt_cv_cc_rpath,[
49     SAVE_LIBS=$LIBS
50     LIBS="-Wl,-rpath,/usr/$LIBDIR $LIBS"
51     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_rpath=yes],[bt_cv_cc_rpath=no])
52     LIBS=$SAVE_LIBS])
53   AC_MSG_RESULT([$bt_cv_cc_rpath])
54   if test $bt_cv_cc_rpath = "yes"; then
55     ld_runpath_switch=-Wl,-rpath,
56   else
57     ld_runpath_switch=-L
58   fi
60 if test "$BEAN_RPATH" = "no"; then
61   ld_runpath_switch=
63 dnl }}}
65 dnl {{{ --with-event
66 AC_ARG_WITH(event,
67   [AS_HELP_STRING([--with-event],[specify libevent install prefix])
68   ],
69   [ ],
70   [with_event=yes]
73 if test "x$with_event" = "xno"; then
74   AC_MSG_ERROR([can't continue without libevent])
75 else
76   AC_MSG_CHECKING([libevent install prefix])
78   if test "x$with_event" = "xyes"; then
79     for i in `echo "$STANDARD_PREFIXES"`; do
80       if test -f "$i/include/event.h"; then
81         LIBEVENT_DIR="$i"
82         break;
83       fi
84     done
85   else
86     if test -f "$with_event/include/event.h"; then
87       LIBEVENT_DIR="$with_event"
88       break;
89     else
90       AC_MSG_ERROR([Can't find libevent headers under $with_event directory])
91     fi
92   fi
94   if test "x$LIBEVENT_DIR" = "x"; then
95     AC_MSG_ERROR([Unable to locate libevent headers, please use --with-event=<DIR>])
96   fi
98   AC_MSG_RESULT([$LIBEVENT_DIR])
99   LDFLAGS="$LDFLAGS -L$LIBEVENT_DIR/$LIBDIR"
100   CFLAGS="$CFLAGS -I$LIBEVENT_DIR/include"
101   LIBS="$LIBS -levent"
103   AC_CHECK_FUNCS([posix_fallocate])
105   AC_CHECK_LIB([socket], [bind], [
106     LIBS="$LIBS -lsocket"
107   ])
109   AC_CHECK_LIB([nsl], [inet_aton], [
110     LIBS="$LIBS -lnsl"
111   ])
113   if test "$BEAN_RPATH" != "no"; then
114     LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
115   fi
117   AC_CHECK_LIB([event], [event_get_version], [], [
118     AC_MSG_ERROR([event_get_version() is missing, check config.log for more details])
119   ])
121   AC_CHECK_LIB([event], [event_reinit], [], [
122     AC_MSG_ERROR([beanstalkd requires libevent version 1.4.1 or later.])
123   ])
125   if test -f "$LIBEVENT_DIR/$LIBDIR/libevent.so"; then
126     LIBEVENT="$LIBEVENT_DIR/$LIBDIR/libevent.so";
127   else 
128     if test -f "$LIBEVENT_DIR/lib/libevent.so"; then
129       LIBEVENT="$LIBEVENT_DIR/lib/libevent.so";
130     else 
131       if test -f "$LIBEVENT_DIR/lib64/libevent.so"; then 
132         LIBEVENT="$LIBEVENT_DIR/lib64/libevent.so";
133       fi
134     fi
135   fi
138 dnl }}}
140 dnl {{{ --enable-debug 
141 AC_ARG_ENABLE(debug,
142   [AS_HELP_STRING([--enable-debug],[enable debugging symbols and compile flags])
143   ],
144   [
145   if test x"$enableval" = xyes ; then
146     debug="yes"
147   else
148     debug="no"
149   fi
150   ]
153 if test x"$debug" = xyes ; then
154   AC_DEFINE([BEAN_DEBUG], [], [debug build])
156   if test x"$GCC" = xyes; then
157     dnl Remove any optimization flags from CFLAGS
158     changequote({,})
159     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
160     CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[0-2]\? //g'`
161     changequote([,])
162     CFLAGS="$CFLAGS -g3 -Wall -O0"
163   fi
165   dnl Do not strip symbols from developer object files.
166   INSTALL_STRIP_FLAG=""
167 else
168   dnl Make sure to strip symbols from non-developer object files.
169   INSTALL_STRIP_FLAG="-s"
171 dnl }}}
173 AC_SUBST(INSTALL_STRIP_FLAG)
175 AC_CONFIG_FILES([Makefile])
176 AC_OUTPUT
178 dnl vim700: ts=2 sw=2 et