]> granicus.if.org Git - pgbouncer/blob - configure.ac
Fix terminology
[pgbouncer] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT([PgBouncer],
4         [1.11.0],
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)
9 AC_PREREQ([2.59])
10
11 dnl basic init
12 AC_USUAL_INIT
13
14 dnl Checks for programs.
15 AC_USUAL_PROGRAM_CHECK
16
17 PKG_PROG_PKG_CONFIG
18
19 AC_CHECK_PROGS(PANDOC, pandoc, pandoc)
20
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])
26 fi
27 AC_CHECK_TOOL([STRIP], [strip])
28
29 dnl Checks for header files.
30 AC_USUAL_HEADER_CHECK
31 AC_CHECK_HEADERS([sys/resource.h sys/wait.h])
32
33 dnl Checks for typedefs, structures, and compiler characteristics.
34 AC_USUAL_TYPE_CHECK
35
36 dnl autoconf 2.59 does not have UINT macros nor docdir
37 m4_ifdef([AC_TYPE_UINT8_T], [
38   AC_TYPE_UINT8_T
39   AC_TYPE_UINT32_T
40   AC_TYPE_UINT64_T
41 ], [
42   datarootdir='${prefix}/share'
43   docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
44   AC_SUBST(datarootdir)
45   AC_SUBST(docdir)
46 ])
47
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)
54 AC_CHECK_FUNCS(lstat)
55
56 dnl Find libevent
57 PKG_CHECK_MODULES(LIBEVENT, libevent)
58
59 dnl Check for PAM authentication support
60 pam_support=no
61 AC_ARG_WITH(pam,
62   AC_HELP_STRING([--with-pam], [build with PAM support]),
63   [ PAM=
64     if test "$withval" != no; then
65         have_pthreads=no
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])
73         fi
74         if test x"${have_pam_header}" != x -a x"${have_libpam}" != x -a x"${have_pthreads}" = xyes; then
75           pam_support=yes
76           AC_DEFINE(HAVE_PAM, 1, [PAM support])
77         fi
78     fi
79   ], [])
80
81 ##
82 ## DNS backend
83 ##
84
85 # make sure all vars are set
86 use_cares=no
87 use_udns=no
88 use_evdns=no
89
90 dnl Find c-ares
91 AC_MSG_CHECKING([whether to use c-ares for DNS lookups])
92 AC_ARG_WITH(cares,
93   AC_HELP_STRING([--with-cares@<:@=PREFIX@:>@], [build with c-ares support]),
94   [ if test "$withval" = "no"; then
95       use_cares=no
96     elif test "$withval" = "yes"; then
97       use_cares="$withval"
98       CARES_CFLAGS=""
99       CARES_LIBS="-lcares"
100     elif test "$withval" = "auto"; then
101       use_cares="$withval"
102     else
103       use_cares=yes
104       CARES_CFLAGS="-I$withval/include"
105       CARES_LIBS="-L$withval/lib -lcares"
106     fi
107   ], [use_cares=auto])
108 AC_MSG_RESULT([$use_cares])
109
110 if test "$use_cares" = "auto"; then
111   PKG_CHECK_MODULES(CARES, [libcares >= 1.6.0], [use_cares=yes], [use_cares=no])
112 fi
113
114 if test "$use_cares" = "yes"; then
115   AC_DEFINE(USE_CARES, 1, [Use c-ares for name resolution.])
116
117   # does it support SOA parse
118   tmp_CFLAGS="$CFLAGS"
119   tmp_LIBS="$LIBS"
120   CFLAGS="$CARES_CFLAGS $CFLAGS"
121   LIBS="$CARES_LIBS $LIBS"
122   AC_CHECK_FUNCS(ares_parse_soa_reply)
123   LIBS="$tmp_LIBS"
124   CFLAGS="$tmp_CFLAGS"
125
126 else # !cares
127
128 dnl Find libudns
129 AC_MSG_CHECKING([whether to use libudns])
130 AC_ARG_WITH(udns,
131   AC_HELP_STRING([--with-udns@<:@=PREFIX@:>@], [build with udns support]),
132   [ if test "$withval" = "no"; then
133       use_udns=no
134     elif test "$withval" = "yes"; then
135       use_udns=yes
136     else
137       use_udns=yes
138       CPPFLAGS="$CPPFLAGS -I$withval/include"
139       LDFLAGS="$LDFLAGS -L$withval/lib"
140     fi
141   ], [])
142 AC_MSG_RESULT([$use_udns])
143
144 if test "$use_udns" = "yes"; then
145   AC_DEFINE(USE_UDNS, 1, [Use UDNS for name resolution.])
146   LIBS="-ludns $LIBS"
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>
151     #include <stddef.h>
152     #include <udns.h>
153     int main(void) {
154       struct dns_ctx *ctx = NULL;
155       dns_init(ctx, 0);
156       dns_reset(ctx);
157     } ])],
158   [AC_MSG_RESULT([found])],
159   [AC_MSG_ERROR([not found, cannot proceed])])
160
161 else # !udns
162
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.])
169   AC_MSG_RESULT([yes])
170 else
171   AC_MSG_RESULT([no])
172 fi
173
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
177 fi
178
179 fi # !udns
180
181 fi # !cares
182
183 ## end of DNS
184
185 AC_USUAL_TLS
186
187 AC_USUAL_DEBUG
188 AC_USUAL_CASSERT
189 AC_USUAL_WERROR
190
191 dnl Output findings
192 AC_OUTPUT([config.mak])
193
194 dnl If separate build dir, link Makefile over
195 test -f Makefile || {
196   echo "Linking Makefile"
197   ln -s $srcdir/Makefile
198 }
199
200 echo ""
201 echo "Results:"
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
206   echo "  adns = udns"
207 elif test "$use_evdns" = "yes"; then
208   echo "  adns = evdns2"
209 elif test "$ac_cv_usual_glibc_gaia" = "yes"; then
210   echo "  adns = libc"
211 else
212   echo "  adns = compat"
213 fi
214 echo "  pam  = $pam_support"
215 echo "  tls  = $tls_support"
216 echo ""