1 dnl Process this file with autoconf to produce a configure script.
5 [https://github.com/pgbouncer/pgbouncer/issues], [],
6 [https://pgbouncer.github.io/])
7 AC_CONFIG_SRCDIR(src/janitor.c)
8 AC_CONFIG_HEADER(lib/usual/config.h)
14 dnl Checks for programs.
15 AC_USUAL_PROGRAM_CHECK
19 AC_CHECK_PROGS(PANDOC, pandoc, pandoc)
21 dnl check for windows tools
22 if test "$PORTNAME" = "win32"; then
23 AC_CHECK_TOOL([WINDRES], [windres])
24 AC_CHECK_TOOL([DLLWRAP], [dllwrap])
25 AC_CHECK_TOOL([DLLTOOL], [dlltool])
27 AC_CHECK_TOOL([STRIP], [strip])
29 dnl Checks for header files.
31 AC_CHECK_HEADERS([sys/resource.h sys/wait.h])
33 dnl Checks for typedefs, structures, and compiler characteristics.
36 dnl autoconf 2.59 does not have UINT macros nor docdir
37 m4_ifdef([AC_TYPE_UINT8_T], [
42 datarootdir='${prefix}/share'
43 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
48 dnl Checks for library functions.
49 AC_USUAL_FUNCTION_CHECK
50 AC_SEARCH_LIBS(clock_gettime, rt)
51 AC_SEARCH_LIBS(getsockname, socket)
52 AC_SEARCH_LIBS(gethostbyname, nsl)
53 AC_SEARCH_LIBS(hstrerror, resolv)
57 PKG_CHECK_MODULES(LIBEVENT, libevent)
59 dnl Check for PAM authentication support
62 AC_HELP_STRING([--with-pam], [build with PAM support]),
64 if test "$withval" != no; then
66 # Look for PAM header and lib
67 AC_CHECK_HEADERS(security/pam_appl.h, [have_pam_header=t])
68 AC_CHECK_HEADERS(pthread.h, [have_pthreads=yes])
69 AC_SEARCH_LIBS(pam_start, pam, [have_libpam=t])
70 AC_SEARCH_LIBS(pthread_create, pthread, [], [have_pthreads=no])
71 if test x"${have_pthreads}" != xyes; then
72 AC_MSG_ERROR([pthread library should be available for PAM support])
74 if test x"${have_pam_header}" != x -a x"${have_libpam}" != x -a x"${have_pthreads}" = xyes; then
76 AC_DEFINE(HAVE_PAM, 1, [PAM support])
85 # make sure all vars are set
91 AC_MSG_CHECKING([whether to use c-ares for DNS lookups])
93 AC_HELP_STRING([--with-cares@<:@=PREFIX@:>@], [build with c-ares support]),
94 [ if test "$withval" = "no"; then
96 elif test "$withval" = "yes"; then
100 elif test "$withval" = "auto"; then
104 CARES_CFLAGS="-I$withval/include"
105 CARES_LIBS="-L$withval/lib -lcares"
108 AC_MSG_RESULT([$use_cares])
110 if test "$use_cares" = "auto"; then
111 PKG_CHECK_MODULES(CARES, [libcares >= 1.6.0], [use_cares=yes], [use_cares=no])
114 if test "$use_cares" = "yes"; then
115 AC_DEFINE(USE_CARES, 1, [Use c-ares for name resolution.])
117 # does it support SOA parse
120 CFLAGS="$CARES_CFLAGS $CFLAGS"
121 LIBS="$CARES_LIBS $LIBS"
122 AC_CHECK_FUNCS(ares_parse_soa_reply)
129 AC_MSG_CHECKING([whether to use libudns])
131 AC_HELP_STRING([--with-udns@<:@=PREFIX@:>@], [build with udns support]),
132 [ if test "$withval" = "no"; then
134 elif test "$withval" = "yes"; then
138 CPPFLAGS="$CPPFLAGS -I$withval/include"
139 LDFLAGS="$LDFLAGS -L$withval/lib"
142 AC_MSG_RESULT([$use_udns])
144 if test "$use_udns" = "yes"; then
145 AC_DEFINE(USE_UDNS, 1, [Use UDNS for name resolution.])
147 AC_MSG_CHECKING([whether libudns is available])
148 AC_LINK_IFELSE([AC_LANG_SOURCE([
149 #include <sys/types.h>
150 #include <sys/time.h>
154 struct dns_ctx *ctx = NULL;
158 [AC_MSG_RESULT([found])],
159 [AC_MSG_ERROR([not found, cannot proceed])])
163 dnl Allow user to override the decision
164 AC_ARG_ENABLE(evdns, AC_HELP_STRING([--disable-evdns], [do not use libevent for DNS lookups]),
165 [use_evdns=$enableval], [use_evdns=yes])
166 AC_MSG_CHECKING([whether to use libevent for DNS lookups])
167 if test "$use_evdns" = "yes"; then
168 AC_DEFINE(USE_EVDNS, 1, [Use libevent for DNS lookups.])
174 dnl Check if need getaddinfo_a compat
175 if test "$use_udns.$use_cares.$use_evdns" = "no.no.no"; then
176 AC_USUAL_GETADDRINFO_A
192 AC_OUTPUT([config.mak])
194 dnl If separate build dir, link Makefile over
195 test -f Makefile || {
196 echo "Linking Makefile"
197 ln -s $srcdir/Makefile
202 dnl Note: Report here should match selection in src/dnslookup.c
203 if test "$use_cares" = "yes"; then
204 echo " adns = c-ares"
205 elif test "$use_udns" = "yes"; then
207 elif test "$use_evdns" = "yes"; then
208 echo " adns = evdns2"
209 elif test "$ac_cv_usual_glibc_gaia" = "yes"; then
212 echo " adns = compat"
214 echo " pam = $pam_support"
215 echo " tls = $tls_support"