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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
|
dnl *******************************************
dnl *** Initialize automake and set version ***
dnl *******************************************
AC_INIT(libsoup/soup.h)
AM_INIT_AUTOMAKE(libsoup, 1.99.31)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_PROG_MAKE_SET
# Increment on interface addition. Reset on removal.
SOUP_AGE=0
# Increment on interface add, remove, or change.
SOUP_CURRENT=0
# Increment on source change. Reset when CURRENT changes.
SOUP_REVISION=0
AC_SUBST(SOUP_CURRENT)
AC_SUBST(SOUP_REVISION)
AC_SUBST(SOUP_AGE)
dnl ***************************
dnl *** Set debugging flags ***
dnl ***************************
debug_default=minimum
# Declare --enable-* args and collect ac_help strings
AC_ARG_ENABLE(debug,
[ --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,
enable_debug=$debug_default)
# Set the debug flags
if test "x$enable_debug" = "xyes"; then
test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
else
if test "x$enable_debug" = "xno"; then
SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
fi
fi
AC_SUBST(SOUP_DEBUG_FLAGS)
dnl ***************************
dnl *** Checks for programs ***
dnl ***************************
AC_PROG_CC
AM_PROG_CC_STDC
AC_PROG_INSTALL
# Set STDC_HEADERS
AC_HEADER_STDC
# Initialize libtool
AM_PROG_LIBTOOL
# This isn't a program, but it doesn't fit anywhere else...
AC_FUNC_ALLOCA
dnl ***********************
dnl *** Checks for glib ***
dnl ***********************
PKG_CHECK_MODULES(GLIB, glib-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
dnl *******************
dnl *** Type checks ***
dnl *******************
AC_CHECK_TYPE(socklen_t, size_t)
dnl *********************************
dnl *** Networking library checks ***
dnl *********************************
AC_CHECK_HEADERS(sys/sockio.h sys/poll.h sys/param.h)
AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
AC_CHECK_FUNCS(inet_pton inet_aton)
### Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
AC_CHECK_FUNC(gethostbyname_r,
[
dnl First check for the glibc variant of gethostbyname_r
AC_MSG_CHECKING(for glibc gethostbyname_r)
AC_TRY_LINK([ #include <netdb.h>],[
struct hostent result_buf;
char buf[1024];
struct hostent* result;
int h_errnop;
gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
&result, &h_errnop);
], [
dnl Have glibc gethostbyname_r
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC, 1,
[Define if you have a glibc-style gethostbyname_r()])
HAVE_GETHOSTBYNAME_R=yes
], [
dnl If we don't have glibc gethostbyname_r, check
dnl for Solaris/Irix gethostbyname_r
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
AC_TRY_LINK([ #include <netdb.h>],[
struct hostent result;
char buf[1024];
int h_errnop;
gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);
], [
dnl Have Solaris/Irix gethostbyname_r
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS, 1,
[Define if you have a Solaris-style gethostbyname_r()])
HAVE_GETHOSTBYNAME_R=yes
], [
dnl If don't have Solaris/Irix gethostbyname_r, check
dnl for HP-UX gethostbyname_r
AC_MSG_RESULT(no)
AC_MSG_CHECKING(for HP-UX gethostbyname_r)
AC_TRY_LINK([ #include <netdb.h>],[
struct hostent result;
char buf[1024];
gethostbyname_r("localhost", &result, buf);
], [
dnl Have HP-UX gethostbyname_r
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX, 1,
[Define if you have an HP-UX-style gethostbyname_r()])
HAVE_GETHOSTBYNAME_R=yes
]
)]
)]
)])
# If we don't have gethostbyname_r, we'll use Glib mutexes, but give a warning
if test -z "$HAVE_GETHOSTBYNAME_R"; then
AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX, 1,
[Define if you have no gethostbyname_r()])
AC_MSG_WARN([You have neither Glib threads nor the function
gethostbyname_r. This means that calls to
gethostbyname (called by the Soup address
functions) will not be thread safe so could
malfunction in programs that use threads.])
fi
AC_CACHE_CHECK(IPv6 support, soup_cv_ipv6, [
AC_EGREP_HEADER(sockaddr_in6, netinet/in.h, soup_cv_ipv6=yes, soup_cv_ipv6=no)
])
case $soup_cv_ipv6 in
yes)
AC_DEFINE(HAVE_IPV6, 1, [Define if you have support for IPv6 sockets])
;;
esac
dnl ************************************************************
dnl *** SSL Library checks (GnuTLS, Mozilla NSS, or OpenSSL) ***
dnl ************************************************************
AC_ARG_ENABLE(ssl,
[ --enable-ssl Turn on Secure Sockets Layer support [default=yes]],,
enable_ssl=yes)
dnl NSS AC_ARG_WITH(nspr-includes,
dnl NSS [ --with-nspr-includes Specify location of Netscape Portable Runtime headers],
dnl NSS [nspr_inc_prefix=-I$withval])
dnl NSS
dnl NSS AC_ARG_WITH(nspr-libs,
dnl NSS [ --with-nspr-libs Specify location of Netscape Portable Runtime libs],
dnl NSS [nspr_prefix=$withval],
dnl NSS [nspr_prefix=$libdir])
dnl NSS
dnl NSS AC_ARG_WITH(nss-includes,
dnl NSS [ --with-nss-includes Specify location of NSS header files],
dnl NSS [nss_inc_prefix=-I$withval])
dnl NSS
dnl NSS AC_ARG_WITH(nss-libs,
dnl NSS [ --with-nss-libs Specify location of NSS libs],
dnl NSS [nss_prefix=$withval],
dnl NSS [nss_prefix=$libdir])
AC_ARG_WITH(openssl-includes,
[ --with-openssl-includes Specify location of OpenSSL header files],
[openssl_inc_prefix=-I$withval])
AC_ARG_WITH(openssl-libs,
[ --with-openssl-libs Specify location of OpenSSL libs],
[openssl_prefix=$withval],
[openssl_prefix=$libdir])
AC_ARG_WITH(gnutls-includes,
[ --with-gnutls-includes Specify location of GnuTLS header files],
[gnutls_inc_prefix=-I$withval])
AC_ARG_WITH(gnutls-libs,
[ --with-gnutls-libs Specify location of GnuTLS libs],
[gnutls_prefix=$withval],
[gnutls_prefix=$libdir])
AC_ARG_ENABLE(libgpg-error,
[ --enable-libgpg-error Work around broken libgcrypt-config scripts],
enable_libgpg_error=yes, enable_libgpg_error=no)
###
### Allow for a custom SSL proxy name
###
SSL_PROXY_NAME=libsoup-ssl-proxy
AC_ARG_WITH(ssl-proxy-name,
[ --with-ssl-proxy-name Custom name for ssl proxy executable [default=libsoup-ssl-proxy]],
[SSL_PROXY_NAME=$withval],
[SSL_PROXY_NAME=libsoup-ssl-proxy])
AC_DEFINE_UNQUOTED(SSL_PROXY_NAME, "${SSL_PROXY_NAME}",
[The name to use for the SSL proxy binary. Defaults to libsoup-ssl-proxy])
AC_SUBST(SSL_PROXY_NAME)
###
### Try to link statically with the SSL library
###
AC_ARG_ENABLE(ssl-link-static,
[ --enable-static-ssl Link with SSL library statically [default=no]],
[enable_static_ssl=yes])
enable_gnutls="no"
enable_openssl="no"
dnl NSS enable_nss="no"
if test "x$enable_ssl" = xyes; then
found_ssl=
###
### Check for GnuTLS
###
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $gnutls_inc_prefix"
AC_CHECK_HEADERS(gnutls/gnutls.h,
[enable_gnutls="yes"],
[enable_gnutls="no"; break])
if test "x$enable_gnutls" = xyes; then
libgpg_error_libs_static=""
libgpg_error_libs=""
if test "x$enable_libgpg_error" = "xyes"; then
AM_PATH_GPG_ERROR("0.4")
if test "x$GPG_ERROR_LIBS" = "x"; then
AC_MSG_ERROR([libgpg-error is needed])
fi
gpg_error_prefix=$($GPG_ERROR_CONFIG --prefix)
libgpg_error_libs_static="$gpg_error_prefix/lib/libgpg-error.a"
libgpg_error_libs="$GPG_ERROR_LIBS"
fi
if test "x$enable_static_ssl" = "xyes"; then
GNUTLS_LIBS="$gnutls_prefix/libgnutls.a $gnutls_prefix/libgcrypt.a $libgpg_error_libs_static"
else
GNUTLS_LIBS="-L$gnutls_prefix -lgnutls -lgcrypt $libgpg_error_libs"
fi
GNUTLS_CFLAGS=$CPPFLAGS
AC_DEFINE(HAVE_GNUTLS, 1,
[Defined if you are using GnuTLS for SSL support])
found_ssl=yes
else
GNUTLS_LIBS=
GNUTLS_CFLAGS=
fi
AC_SUBST(GNUTLS_CFLAGS)
AC_SUBST(GNUTLS_LIBS)
CPPFLAGS=$save_CPPFLAGS
AM_CONDITIONAL(BUILD_PROXY, false)
###
### Check for OpenSSL
###
if test "x$found_ssl" != "xyes"; then
PKG_CHECK_MODULES(OPENSSL, openssl, enable_openssl=yes, [
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $openssl_inc_prefix"
AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
[enable_openssl="yes"],
[enable_openssl="no"; break])
if test "x$enable_openssl" = xyes; then
if test "x$enable_static_ssl" = "xyes"; then
OPENSSL_LIBS="$openssl_prefix/libssl.a $openssl_prefix/libcrypto.a"
else
OPENSSL_LIBS="-L$openssl_prefix -lssl -lcrypto $DL_LDFLAGS"
fi
OPENSSL_CFLAGS=$CPPFLAGS
else
OPENSSL_LIBS=
OPENSSL_CFLAGS=
fi
CPPFLAGS=$save_CPPFLAGS
])
if test "x$enable_openssl" = xyes; then
AC_DEFINE(HAVE_OPENSSL, 1,
[Defined if you are using OpenSSL for SSL support])
found_ssl=yes
AM_CONDITIONAL(BUILD_PROXY, true)
fi
AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LIBS)
fi
dnl NSS ###
dnl NSS ### Check for Mozilla NSS
dnl NSS ###
dnl NSS if test "x$found_ssl" != "xyes"; then
dnl NSS save_CPPFLAGS=$CPPFLAGS
dnl NSS CPPFLAGS="$CPPFLAGS $nspr_inc_prefix $nss_inc_prefix"
dnl NSS AC_CHECK_HEADERS(nss.h ssl.h pk11func.h,
dnl NSS [enable_nss="yes"],
dnl NSS [enable_nss="no"; break])
dnl NSS
dnl NSS if test "x$enable_nss" = xyes; then
dnl NSS if test "x$enable_static_ssl" = "xyes"; then
dnl NSS NSS_LIBS="-lpthread $nspr_prefix/libnspr4.a $nspr_prefix/libplc4.a $nspr_prefix/libplds4.a $nss_prefix/libnssb.a"
dnl NSS else
dnl NSS NSS_LIBS="-lpthread -L$nspr_prefix -lnspr4 -lplc4 -lplds4 $nss_prefix -lnss3 -lssl3"
dnl NSS fi
dnl NSS NSS_CFLAGS=$CPPFLAGS
dnl NSS AC_DEFINE(HAVE_NSS, 1,
dnl NSS [Defined if you are using Mozilla NSS for SSL support])
dnl NSS found_ssl=yes
dnl NSS else
dnl NSS NSS_LIBS=
dnl NSS NSS_CFLAGS=
dnl NSS fi
dnl NSS
dnl NSS AC_SUBST(NSS_CFLAGS)
dnl NSS AC_SUBST(NSS_LIBS)
dnl NSS CPPFLAGS=$save_CPPFLAGS
dnl NSS fi
fi
dnl *********************************************
dnl *** Checks for gtk-doc (lifted from glib) ***
dnl *********************************************
AC_ARG_WITH(html-dir, [ --with-html-dir=PATH Path to installed docs ])
if test "x$with_html_dir" = "x" ; then
HTML_DIR='${datadir}/gtk-doc/html'
else
HTML_DIR=$with_html_dir
fi
AC_SUBST(HTML_DIR)
AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
AC_SUBST(HAVE_GTK_DOC)
AC_CHECK_PROG(DB2HTML, db2html, true, false)
AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc,
[ --enable-gtk-doc Use gtk-doc to build documentation [default=auto]],
enable_gtk_doc="$enableval",
enable_gtk_doc=auto)
if test x$enable_gtk_doc = xauto ; then
if test x$GTKDOC = xtrue ; then
enable_gtk_doc=yes
else
enable_gtk_doc=no
fi
fi
dnl NOTE: We need to use a separate automake conditional for this
dnl to make this work with the tarballs.
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
dnl *************************************
dnl *** Warnings to show if using GCC ***
dnl *************************************
AC_ARG_ENABLE(more-warnings,
[ --disable-more-warnings Inhibit compiler warnings],
set_more_warnings=no)
if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
CFLAGS="$CFLAGS \
-Wall -Wstrict-prototypes -Wmissing-declarations \
-Wmissing-prototypes -Wnested-externs -Wpointer-arith"
fi
# Use reentrant functions
CFLAGS="$CFLAGS -D_REENTRANT"
dnl *****************************
dnl *** link proxy statically ***
dnl *****************************
AC_ARG_ENABLE(static-proxy,
[ --enable-static-proxy Build ${SSL_PROXY_NAME} statically ])
if test x"$enable_static_proxy" = xyes; then
LINK_STATIC="-Wl,-Bstatic"
LINK_DYNAMIC="-Wl,-Bdynamic"
FORCE_SHLIBS="dl resolv rt nsl"
for lib in $FORCE_SHLIBS; do
OPENSSL_LIBS=`echo $OPENSSL_LIBS | sed "s/-l$lib/-Wl,-Bdynamic -l$lib -Wl,-Bstatic/"`
GMODULE_LIBS=`echo $GMODULE_LIBS | sed "s/-l$lib/-Wl,-Bdynamic -l$lib -Wl,-Bstatic/"`
done
else
LINK_STATIC=
LINK_DYNAMIC=
fi
AC_SUBST(LINK_STATIC)
AC_SUBST(LINK_DYNAMIC)
dnl *************************
dnl *** Output Everything ***
dnl *************************
AC_OUTPUT([
soup-2.0.pc
Makefile
libsoup/Makefile
tests/Makefile
])
echo "
Configuration:
Source code location: ${srcdir}
Compiler: ${CC}
Build flags: ${CFLAGS} ${SOUP_DEBUG_FLAGS}
GnuTLS support: ${enable_gnutls}
OpenSSL support: ${enable_openssl}
Static SSL Proxy: ${enable_static_proxy:-no}
SSL Proxy Name: ${SSL_PROXY_NAME}
"
|