1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pgbouncer, 1.3.4)
4 AC_CONFIG_SRCDIR(src/janitor.c)
5 AC_CONFIG_HEADER(include/config.h)
8 dnl windows port check (Not use AC_CANONICAL_HOST)
9 AC_MSG_CHECKING([target host type])
11 if test "x$xhost" = "x"; then
15 *cygwin* | *mingw* | *pw32* | *MINGW*)
21 AC_MSG_RESULT([$PORTNAME])
23 dnl Checks for programs.
27 dnl ./install-sh must be manually set up if not using automake
30 dnl Check if linker supports -Wl,--as-needed
31 dnl That helps to get rid of unnecessary -lrt
32 if test "$GCC" = "yes"; then
33 old_LDFLAGS="$LDFLAGS"
34 LDFLAGS="$LDFLAGS -Wl,--as-needed"
35 AC_MSG_CHECKING([whether linker supports --as-needed])
36 AC_LINK_IFELSE([int main(void) { return 0; }],
37 [AC_MSG_RESULT([yes])],
39 LDFLAGS="$old_LDFLAGS"])
42 dnl Check if compiler supports __func__
43 AC_CACHE_CHECK([whether compiler supports __func__], pgac_cv_funcname_func,
44 [AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
45 [pgac_cv_funcname_func=yes], [pgac_cv_funcname_func=no])])
46 if test x"$pgac_cv_funcname_func" = xyes ; then
47 AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
48 [Define to 1 if your compiler understands __func__.])
52 AC_CHECK_PROGS(ASCIIDOC, asciidoc)
53 if test -n "$ASCIIDOC"; then
54 AC_MSG_CHECKING([for asciidoc version >= 8.2])
55 ver=`$ASCIIDOC --version 2>&1 | sed -e 's/asciidoc //'`
57 dnl hack to make possible to use [, ] in regex
59 [0-7].*|8.[01]|8.[01].*)
61 AC_MSG_RESULT([$ver, too old])
65 AC_MSG_RESULT([$ver, ok])
70 dnl check for xmlto, but only if asciidoc is found
71 if test -n "$ASCIIDOC"; then
72 AC_CHECK_PROGS(XMLTO, xmlto)
75 dnl check for windows tools
76 if test "$PORTNAME" = "win32"; then
77 AC_CHECK_TOOL([WINDRES], [windres])
78 AC_CHECK_TOOL([DLLWRAP], [dllwrap])
79 AC_CHECK_TOOL([DLLTOOL], [dlltool])
81 AC_CHECK_TOOL([STRIP], [strip])
83 dnl Additional gcc tuning
84 if test x"$GCC" = xyes; then
85 AC_MSG_CHECKING([for working warning switches])
89 # turn off noise from Wextra
90 flags="$flags -Wno-unused-parameter -Wno-missing-field-initializers"
91 # Wextra does not turn those on?
92 flags="$flags -Wmissing-prototypes -Wpointer-arith -Wendif-labels"
93 flags="$flags -Wdeclaration-after-statement -Wold-style-definition"
94 flags="$flags -Wstrict-prototypes -Wundef -Wformat=2 -Wnonnull"
96 CFLAGS="$good_CFLAGS $warnings $f"
97 AC_COMPILE_IFELSE([void foo(void){}], [warnings="$warnings $f"])
100 # avoid -Wextra if missing-field.initializers does not work
101 echo "$warnings" | grep missing-field-initializers > /dev/null \
102 || warnings=`echo "$warnings"|sed 's/-Wextra//'`
104 CFLAGS="$good_CFLAGS $warnings"
105 AC_MSG_RESULT([$warnings])
108 dnl Checks for header files.
109 AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h sys/uio.h libgen.h pwd.h grp.h])
110 AC_CHECK_HEADERS([sys/resource.h sys/wait.h sys/un.h arpa/inet.h])
111 AC_CHECK_HEADERS([netinet/in.h netinet/tcp.h netdb.h regex.h])
113 dnl ucred.h may have prereqs
114 AC_CHECK_HEADERS([ucred.h sys/ucred.h], [], [], [
115 #ifdef HAVE_SYS_TYPES_H
116 #include <sys/types.h>
118 #ifdef HAVE_SYS_PARAM_H
119 #include <sys/param.h>
123 dnl Checks for typedefs, structures, and compiler characteristics.
130 dnl autoconf 2.59 does not have UINT macros nor docdir
131 m4_ifdef([AC_TYPE_UINT8_T], [
136 datarootdir='${prefix}/share'
137 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
138 AC_SUBST(datarootdir)
142 dnl Checks for library functions.
143 AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
144 AC_SEARCH_LIBS(crypt, crypt)
145 AC_SEARCH_LIBS(clock_gettime, rt)
146 AC_SEARCH_LIBS(getsockname, socket)
147 AC_SEARCH_LIBS(gethostbyname, nsl)
148 AC_SEARCH_LIBS(hstrerror, resolv)
149 AC_SEARCH_LIBS(regcomp, regex, [], AC_MSG_ERROR([regcomp not found]))
150 AC_CHECK_FUNCS(crypt inet_ntop lstat)
153 AC_MSG_CHECKING([for libevent])
154 AC_ARG_WITH(libevent,
155 AC_HELP_STRING([--with-libevent=prefix],[Specify where libevent is installed]),
156 [ test "$withval" = "no" && AC_MSG_ERROR("cannot work without libevent")
157 CPPFLAGS="$CPPFLAGS -I$withval/include"
158 LDFLAGS="$LDFLAGS -L$withval/lib" ])
161 #include <sys/types.h>
162 #include <sys/time.h>
168 event_set(&ev, 1, EV_READ, NULL, NULL);
169 /* this checks for 1.2+ but next we check for 1.3b+ anyway */
170 /* event_base_free(NULL); */
172 [AC_MSG_RESULT([found])],
173 [AC_MSG_ERROR([not found, cannot proceed])])
175 dnl libevent < 1.3b crashes on event_base_free()
176 dnl no good way to check libevent version. use hack:
177 dnl evhttp.h defines HTTP_SERVUNAVAIL only since 1.3b
178 AC_MSG_CHECKING([whether libevent version >= 1.3b])
179 AC_EGREP_CPP([HTTP_SERVUNAVAIL],
182 [AC_MSG_ERROR([no, cannot proceed])],
183 [AC_MSG_RESULT([yes])])
185 AC_CHECK_FUNCS(event_loopbreak)
188 AC_HELP_STRING([--disable-debug],[strip binary]),
189 [], [enable_debug=yes])
190 AC_MSG_CHECKING([whether to build debug binary])
191 if test "$enable_debug" = "yes"; then
192 LDFLAGS="-g $LDFLAGS"
193 BININSTALL="$INSTALL"
196 BININSTALL="$INSTALL -s"
199 AC_SUBST(enable_debug)
202 AC_ARG_ENABLE(cassert, AC_HELP_STRING([--enable-cassert],[turn on assert checking in code]))
203 AC_MSG_CHECKING([whether to enable asserts])
204 if test "$enable_cassert" = "yes"; then
205 AC_DEFINE(CASSERT, 1, [Define to enable assert checking])
211 AC_ARG_ENABLE(werror, AC_HELP_STRING([--enable-werror],[add -Werror to CFLAGS]))
212 AC_MSG_CHECKING([whether to fail on warnings])
213 if test "$enable_werror" = "yes"; then
214 CFLAGS="$CFLAGS -Werror"
220 if test \! "$srcdir" = "$builddir"; then
221 CPPFLAGS="-I\$(builddir)/include $CPPFLAGS"
225 AC_OUTPUT([config.mak])
227 dnl If separate build dir, link Makefile over
228 test -f Makefile || {
229 echo "Linking Makefile"
230 ln -s $srcdir/Makefile