More tests and fix the deadline overflow check.
[beanstalkd.git] / configure.in
blob41c5f38748edd5ad1b00a196be2cd7db4ab8d947
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,1.2-dev)
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"
17 BEAN_VERSION="`git describe`"
19 dnl generate version.h {{{
20 echo "/* automatically generated by configure */" > version.h.new
21 echo "/* edit configure.in to change the version number */" >> version.h.new
22 echo "#define BEAN_VERSION \"$BEAN_VERSION\"" >> version.h.new
23 cmp version.h.new $srcdir/version.h >/dev/null 2>&1
24 if test $? -ne 0 ; then
25   rm -f $srcdir/version.h && mv version.h.new $srcdir/version.h && \
26   echo 'Updated version.h'
27 else
28   rm -f version.h.new
30 dnl }}}
32 dnl {{{ --with-libdir
33 AC_ARG_WITH(libdir,
34   [AS_HELP_STRING([--with-libdir],[look for libraries in .../NAME rather than .../lib])
35   ],
36   [LIBDIR=$with_libdir],
37   [LIBDIR=lib]
39 dnl }}}
41 dnl {{{ --disable-rpath
42 AC_ARG_ENABLE(rpath,
43   [AS_HELP_STRING([--disable-rpath],[disable passing additional runtime library search paths])
44   ],
45   [BEAN_RPATH=no],
46   [BEAN_RPATH=yes]
48 dnl }}}
50 dnl {{{ check for rpath support
51 AC_MSG_CHECKING([if compiler supports -R])
52 AC_CACHE_VAL(bt_cv_cc_dashr,[
53   SAVE_LIBS=$LIBS
54   LIBS="-R /usr/$LIBDIR $LIBS"
55   AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_dashr=yes],[bt_cv_cc_dashr=no])
56   LIBS=$SAVE_LIBS])
57 AC_MSG_RESULT([$bt_cv_cc_dashr])
58 if test $bt_cv_cc_dashr = "yes"; then
59   ld_runpath_switch=-R
60 else
61   AC_MSG_CHECKING([if compiler supports -Wl,-rpath,])
62   AC_CACHE_VAL(bt_cv_cc_rpath,[
63     SAVE_LIBS=$LIBS
64     LIBS="-Wl,-rpath,/usr/$LIBDIR $LIBS"
65     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[bt_cv_cc_rpath=yes],[bt_cv_cc_rpath=no])
66     LIBS=$SAVE_LIBS])
67   AC_MSG_RESULT([$bt_cv_cc_rpath])
68   if test $bt_cv_cc_rpath = "yes"; then
69     ld_runpath_switch=-Wl,-rpath,
70   else
71     ld_runpath_switch=-L
72   fi
74 if test "$BEAN_RPATH" = "no"; then
75   ld_runpath_switch=
77 dnl }}}
79 dnl {{{ --with-event
80 AC_ARG_WITH(event,
81   [AS_HELP_STRING([--with-event],[specify libevent install prefix])
82   ],
83   [ ],
84   [with_event=yes]
87 if test "x$with_event" = "xno"; then
88   AC_MSG_ERROR([can't continue without libevent])
89 else
90   AC_MSG_CHECKING([libevent install prefix])
92   if test "x$with_event" = "xyes"; then
93     for i in `echo "$STANDARD_PREFIXES"`; do
94       if test -f "$i/include/event.h"; then
95         LIBEVENT_DIR="$i"
96         break;
97       fi
98     done
99   else
100     if test -f "$with_event/include/event.h"; then
101       LIBEVENT_DIR="$with_event"
102       break;
103     else
104       AC_MSG_ERROR([Can't find libevent headers under $with_event directory])
105     fi
106   fi
108   if test "x$LIBEVENT_DIR" = "x"; then
109     AC_MSG_ERROR([Unable to locate libevent headers, please use --with-event=<DIR>])
110   fi
112   AC_MSG_RESULT([$LIBEVENT_DIR])
113   LDFLAGS="$LDFLAGS -L$LIBEVENT_DIR/$LIBDIR"
114   CFLAGS="$CFLAGS -I$LIBEVENT_DIR/include"
115   LIBS="$LIBS -levent"
117   if test "$BEAN_RPATH" != "no"; then
118     LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
119   fi
121   AC_CHECK_LIB([event], [event_get_version], [], [
122     AC_MSG_ERROR([event_get_version() is missing, check config.log for more details])
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