Get "make distcheck" to work.
[beanstalkd.git] / configure.in
blob8572f12f5f62f4da07b10b191294dda0db8c19e3
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   if test "$BEAN_RPATH" != "no"; then
104     LDFLAGS="$LDFLAGS $ld_runpath_switch$LIBEVENT_DIR/$LIBDIR"
105   fi
107   AC_CHECK_LIB([event], [event_get_version], [], [
108     AC_MSG_ERROR([event_get_version() is missing, check config.log for more details])
109   ])
111   if test -f "$LIBEVENT_DIR/$LIBDIR/libevent.so"; then
112     LIBEVENT="$LIBEVENT_DIR/$LIBDIR/libevent.so";
113   else 
114     if test -f "$LIBEVENT_DIR/lib/libevent.so"; then
115       LIBEVENT="$LIBEVENT_DIR/lib/libevent.so";
116     else 
117       if test -f "$LIBEVENT_DIR/lib64/libevent.so"; then 
118         LIBEVENT="$LIBEVENT_DIR/lib64/libevent.so";
119       fi
120     fi
121   fi
124 dnl }}}
126 dnl {{{ --enable-debug 
127 AC_ARG_ENABLE(debug,
128   [AS_HELP_STRING([--enable-debug],[enable debugging symbols and compile flags])
129   ],
130   [
131   if test x"$enableval" = xyes ; then
132     debug="yes"
133   else
134     debug="no"
135   fi
136   ]
139 if test x"$debug" = xyes ; then
140   AC_DEFINE([BEAN_DEBUG], [], [debug build])
142   if test x"$GCC" = xyes; then
143     dnl Remove any optimization flags from CFLAGS
144     changequote({,})
145     CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9s]*//g'`
146     CFLAGS=`echo "$CFLAGS" | sed -e 's/-g[0-2]\? //g'`
147     changequote([,])
148     CFLAGS="$CFLAGS -g3 -Wall -O0"
149   fi
151   dnl Do not strip symbols from developer object files.
152   INSTALL_STRIP_FLAG=""
153 else
154   dnl Make sure to strip symbols from non-developer object files.
155   INSTALL_STRIP_FLAG="-s"
157 dnl }}}
159 AC_SUBST(INSTALL_STRIP_FLAG)
161 AC_CONFIG_FILES([Makefile])
162 AC_OUTPUT
164 dnl vim700: ts=2 sw=2 et