forked from pgbouncer/pgbouncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
217 lines (185 loc) · 5.42 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
dnl Process this file with autoconf to produce a configure script.
AC_INIT([PgBouncer],
[1.12.0],
[https://github.com/pgbouncer/pgbouncer/issues], [],
[https://www.pgbouncer.org/])
AC_CONFIG_SRCDIR(src/janitor.c)
AC_CONFIG_HEADER(lib/usual/config.h)
AC_PREREQ([2.59])
dnl basic init
AC_USUAL_INIT
dnl Checks for programs.
AC_USUAL_PROGRAM_CHECK
PKG_PROG_PKG_CONFIG
AC_CHECK_PROGS(PANDOC, pandoc, pandoc)
AC_CHECK_PROGS(PYTHON, [python python3 python2], python)
dnl check for windows tools
if test "$PORTNAME" = "win32"; then
AC_CHECK_TOOL([WINDRES], [windres])
AC_CHECK_TOOL([DLLWRAP], [dllwrap])
AC_CHECK_TOOL([DLLTOOL], [dlltool])
fi
AC_CHECK_TOOL([STRIP], [strip])
dnl Checks for header files.
AC_USUAL_HEADER_CHECK
AC_CHECK_HEADERS([sys/resource.h sys/wait.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_USUAL_TYPE_CHECK
dnl autoconf 2.59 does not have UINT macros nor docdir
m4_ifdef([AC_TYPE_UINT8_T], [
AC_TYPE_UINT8_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
], [
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
AC_SUBST(datarootdir)
AC_SUBST(docdir)
])
dnl Checks for library functions.
AC_USUAL_FUNCTION_CHECK
AC_SEARCH_LIBS(clock_gettime, rt)
AC_SEARCH_LIBS(getsockname, socket)
AC_SEARCH_LIBS(gethostbyname, nsl)
AC_SEARCH_LIBS(hstrerror, resolv)
AC_CHECK_FUNCS(lstat)
dnl Find libevent
PKG_CHECK_MODULES(LIBEVENT, libevent)
dnl Check for PAM authentication support
pam_support=no
AC_ARG_WITH(pam,
AC_HELP_STRING([--with-pam], [build with PAM support]),
[ PAM=
if test "$withval" != no; then
have_pthreads=no
# Look for PAM header and lib
AC_CHECK_HEADERS(security/pam_appl.h, [have_pam_header=t])
AC_CHECK_HEADERS(pthread.h, [have_pthreads=yes])
AC_SEARCH_LIBS(pam_start, pam, [have_libpam=t])
AC_SEARCH_LIBS(pthread_create, pthread, [], [have_pthreads=no])
if test x"${have_pthreads}" != xyes; then
AC_MSG_ERROR([pthread library should be available for PAM support])
fi
if test x"${have_pam_header}" != x -a x"${have_libpam}" != x -a x"${have_pthreads}" = xyes; then
pam_support=yes
AC_DEFINE(HAVE_PAM, 1, [PAM support])
fi
fi
], [])
##
## DNS backend
##
# make sure all vars are set
use_cares=no
use_udns=no
use_evdns=no
dnl Find c-ares
AC_MSG_CHECKING([whether to use c-ares for DNS lookups])
AC_ARG_WITH(cares,
AC_HELP_STRING([--with-cares@<:@=PREFIX@:>@], [build with c-ares support]),
[ if test "$withval" = "no"; then
use_cares=no
elif test "$withval" = "yes"; then
use_cares="$withval"
CARES_CFLAGS=""
CARES_LIBS="-lcares"
elif test "$withval" = "auto"; then
use_cares="$withval"
else
use_cares=yes
CARES_CFLAGS="-I$withval/include"
CARES_LIBS="-L$withval/lib -lcares"
fi
], [use_cares=auto])
AC_MSG_RESULT([$use_cares])
if test "$use_cares" = "auto"; then
PKG_CHECK_MODULES(CARES, [libcares >= 1.6.0], [use_cares=yes], [use_cares=no])
fi
if test "$use_cares" = "yes"; then
AC_DEFINE(USE_CARES, 1, [Use c-ares for name resolution.])
# does it support SOA parse
tmp_CFLAGS="$CFLAGS"
tmp_LIBS="$LIBS"
CFLAGS="$CARES_CFLAGS $CFLAGS"
LIBS="$CARES_LIBS $LIBS"
AC_CHECK_FUNCS(ares_parse_soa_reply)
LIBS="$tmp_LIBS"
CFLAGS="$tmp_CFLAGS"
else # !cares
dnl Find libudns
AC_MSG_CHECKING([whether to use libudns])
AC_ARG_WITH(udns,
AC_HELP_STRING([--with-udns@<:@=PREFIX@:>@], [build with udns support]),
[ if test "$withval" = "no"; then
use_udns=no
elif test "$withval" = "yes"; then
use_udns=yes
else
use_udns=yes
CPPFLAGS="$CPPFLAGS -I$withval/include"
LDFLAGS="$LDFLAGS -L$withval/lib"
fi
], [])
AC_MSG_RESULT([$use_udns])
if test "$use_udns" = "yes"; then
AC_DEFINE(USE_UDNS, 1, [Use UDNS for name resolution.])
LIBS="-ludns $LIBS"
AC_MSG_CHECKING([whether libudns is available])
AC_LINK_IFELSE([AC_LANG_SOURCE([
#include <sys/types.h>
#include <sys/time.h>
#include <stddef.h>
#include <udns.h>
int main(void) {
struct dns_ctx *ctx = NULL;
dns_init(ctx, 0);
dns_reset(ctx);
} ])],
[AC_MSG_RESULT([found])],
[AC_MSG_ERROR([not found, cannot proceed])])
else # !udns
dnl Allow user to override the decision
AC_ARG_ENABLE(evdns, AC_HELP_STRING([--disable-evdns], [do not use libevent for DNS lookups]),
[use_evdns=$enableval], [use_evdns=yes])
AC_MSG_CHECKING([whether to use libevent for DNS lookups])
if test "$use_evdns" = "yes"; then
AC_DEFINE(USE_EVDNS, 1, [Use libevent for DNS lookups.])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
dnl Check if need getaddinfo_a compat
if test "$use_udns.$use_cares.$use_evdns" = "no.no.no"; then
AC_USUAL_GETADDRINFO_A
fi
fi # !udns
fi # !cares
## end of DNS
AC_USUAL_TLS
AC_USUAL_DEBUG
AC_USUAL_CASSERT
AC_USUAL_WERROR
dnl Output findings
AC_OUTPUT([config.mak])
dnl If separate build dir, link Makefile over
test -f Makefile || {
echo "Linking Makefile"
ln -s $srcdir/Makefile
}
echo ""
echo "Results:"
dnl Note: Report here should match selection in src/dnslookup.c
if test "$use_cares" = "yes"; then
echo " adns = c-ares"
elif test "$use_udns" = "yes"; then
echo " adns = udns"
elif test "$use_evdns" = "yes"; then
echo " adns = evdns2"
elif test "$ac_cv_usual_glibc_gaia" = "yes"; then
echo " adns = libc"
else
echo " adns = compat"
fi
echo " pam = $pam_support"
echo " tls = $tls_support"
echo ""