1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT(pgbouncer, 1.3.2rc1)
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 Check if linker supports -Wl,--as-needed
28 dnl That helps to get rid of unnecessary -lrt
29 if test "$GCC" = "yes"; then
30 old_LDFLAGS="$LDFLAGS"
31 LDFLAGS="$LDFLAGS -Wl,--as-needed"
32 AC_MSG_CHECKING([whether linker supports --as-needed])
33 AC_LINK_IFELSE([int main(void) { return 0; }],
34 [AC_MSG_RESULT([yes])],
36 LDFLAGS="$old_LDFLAGS"])
39 dnl Check if compiler supports __func__
40 AC_CACHE_CHECK([whether compiler supports __func__], pgac_cv_funcname_func,
41 [AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
42 [pgac_cv_funcname_func=yes], [pgac_cv_funcname_func=no])])
43 if test x"$pgac_cv_funcname_func" = xyes ; then
44 AC_DEFINE(HAVE_FUNCNAME__FUNC, 1,
45 [Define to 1 if your compiler understands __func__.])
49 AC_CHECK_PROGS(ASCIIDOC, asciidoc)
50 if test -n "$ASCIIDOC"; then
51 AC_MSG_CHECKING([for asciidoc version >= 8.2])
52 ver=`$ASCIIDOC --version 2>&1 | sed -e 's/asciidoc //'`
54 dnl hack to make possible to use [, ] in regex
56 [0-7].*|8.[01]|8.[01].*)
58 AC_MSG_RESULT([$ver, too old])
62 AC_MSG_RESULT([$ver, ok])
67 dnl check for xmlto, but only if asciidoc is found
68 if test -n "$ASCIIDOC"; then
69 AC_CHECK_PROGS(XMLTO, xmlto)
72 dnl check for windows tools
73 if test "$PORTNAME" = "win32"; then
74 AC_CHECK_TOOL([WINDRES], [windres])
75 AC_CHECK_TOOL([DLLWRAP], [dllwrap])
76 AC_CHECK_TOOL([DLLTOOL], [dlltool])
78 AC_CHECK_TOOL([STRIP], [strip])
80 dnl Additional gcc tuning
81 if test x"$GCC" = xyes; then
82 AC_MSG_CHECKING([for working warning switches])
86 # turn off noise from Wextra
87 flags="$flags -Wno-unused-parameter -Wno-missing-field-initializers"
88 # Wextra does not turn those on?
89 flags="$flags -Wmissing-prototypes -Wpointer-arith -Wendif-labels"
90 flags="$flags -Wdeclaration-after-statement -Wold-style-definition"
91 flags="$flags -Wstrict-prototypes -Wundef -Wformat -Wnonnull -Wstrict-overflow"
93 CFLAGS="$good_CFLAGS $warnings $f"
94 AC_COMPILE_IFELSE([void foo(void){}], [warnings="$warnings $f"])
96 CFLAGS="$good_CFLAGS $warnings"
97 AC_MSG_RESULT([$warnings])
100 dnl Checks for header files.
101 AC_CHECK_HEADERS([crypt.h sys/param.h sys/socket.h sys/uio.h libgen.h pwd.h grp.h])
102 AC_CHECK_HEADERS([sys/resource.h sys/wait.h sys/un.h arpa/inet.h])
103 AC_CHECK_HEADERS([netinet/in.h netinet/tcp.h netdb.h regex.h])
105 dnl ucred.h may have prereqs
106 AC_CHECK_HEADERS([ucred.h sys/ucred.h], [], [], [
107 #ifdef HAVE_SYS_TYPES_H
108 #include <sys/types.h>
110 #ifdef HAVE_SYS_PARAM_H
111 #include <sys/param.h>
115 dnl Checks for typedefs, structures, and compiler characteristics.
122 dnl autoconf 2.59 does not have UINT macros nor docdir
123 m4_ifdef([AC_TYPE_UINT8_T], [
128 datarootdir='${prefix}/share'
129 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
130 AC_SUBST(datarootdir)
134 dnl Checks for library functions.
135 AC_CHECK_FUNCS(strlcpy strlcat getpeereid getpeerucred basename)
136 AC_SEARCH_LIBS(crypt, crypt)
137 AC_SEARCH_LIBS(clock_gettime, rt)
138 AC_SEARCH_LIBS(getsockname, socket)
139 AC_SEARCH_LIBS(gethostbyname, nsl)
140 AC_SEARCH_LIBS(hstrerror, resolv)
141 AC_SEARCH_LIBS(regcomp, regex, [], AC_MSG_ERROR([regcomp not found]))
142 AC_CHECK_FUNCS(crypt inet_ntop lstat)
145 AC_MSG_CHECKING([for libevent])
146 AC_ARG_WITH(libevent,
147 AC_HELP_STRING([--with-libevent=prefix],[Specify where libevent is installed]),
148 [ test "$withval" = "no" && AC_MSG_ERROR("cannot work without libevent")
149 CPPFLAGS="$CPPFLAGS -I$withval/include"
150 LDFLAGS="$LDFLAGS -L$withval/lib" ])
153 #include <sys/types.h>
154 #include <sys/time.h>
160 event_set(&ev, 1, EV_READ, NULL, NULL);
161 /* this checks for 1.2+ but next we check for 1.3b+ anyway */
162 /* event_base_free(NULL); */
164 [AC_MSG_RESULT([found])],
165 [AC_MSG_ERROR([not found, cannot proceed])])
167 dnl libevent < 1.3b crashes on event_base_free()
168 dnl no good way to check libevent version. use hack:
169 dnl evhttp.h defines HTTP_SERVUNAVAIL only since 1.3b
170 AC_MSG_CHECKING([whether libevent version >= 1.3b])
171 AC_EGREP_CPP([HTTP_SERVUNAVAIL],
174 [AC_MSG_ERROR([no, cannot proceed])],
175 [AC_MSG_RESULT([yes])])
177 AC_CHECK_FUNCS(event_loopbreak)
179 # autoconf does not want to find 'install', if not using automake...
183 AC_HELP_STRING([--disable-debug],[strip binary]),
184 [], [enable_debug=yes])
185 AC_MSG_CHECKING([whether to build debug binary])
186 if test "$enable_debug" = "yes"; then
187 LDFLAGS="-g $LDFLAGS"
188 BININSTALL="$INSTALL"
191 BININSTALL="$INSTALL -s"
194 AC_SUBST(enable_debug)
198 AC_ARG_ENABLE(cassert, AC_HELP_STRING([--enable-cassert],[turn on assert checking in code]))
199 AC_MSG_CHECKING([whether to enable asserts])
200 if test "$enable_cassert" = "yes"; then
201 AC_DEFINE(CASSERT, 1, [Define to enable assert checking])
207 AC_ARG_ENABLE(werror, AC_HELP_STRING([--enable-werror],[add -Werror to CFLAGS]))
208 AC_MSG_CHECKING([whether to fail on warnings])
209 if test "$enable_werror" = "yes"; then
210 CFLAGS="$CFLAGS -Werror"
216 if test \! "$srcdir" = "$builddir"; then
217 CPPFLAGS="-I\$(builddir)/include $CPPFLAGS"
221 AC_OUTPUT([config.mak])
223 dnl If separate build dir, link Makefile over
224 test -f Makefile || {
225 echo "Linking Makefile"
226 ln -s $srcdir/Makefile