Added. Starts a server only on the interface specified, instead of all
[platform/upstream/libsoup.git] / configure.in
1 dnl *******************************************
2 dnl *** Initialize automake and set version ***
3 dnl *******************************************
4
5 AC_INIT(libsoup/soup.h)
6
7 AM_INIT_AUTOMAKE(libsoup, 1.99.3)
8 AM_CONFIG_HEADER(config.h)
9 AM_MAINTAINER_MODE
10 AC_PROG_MAKE_SET
11
12 # Increment on interface addition. Reset on removal.
13 SOUP_AGE=0
14
15 # Increment on interface add, remove, or change.
16 SOUP_CURRENT=0
17
18 # Increment on source change. Reset when CURRENT changes.
19 SOUP_REVISION=0
20
21 AC_SUBST(SOUP_CURRENT)
22 AC_SUBST(SOUP_REVISION)
23 AC_SUBST(SOUP_AGE)
24
25 dnl ***************************
26 dnl *** Set debugging flags ***
27 dnl ***************************
28
29 debug_default=minimum
30
31 # Declare --enable-* args and collect ac_help strings
32 AC_ARG_ENABLE(debug, 
33               [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,
34               enable_debug=$debug_default)
35
36 # Set the debug flags
37 if test "x$enable_debug" = "xyes"; then
38         test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
39         SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
40 else
41         if test "x$enable_debug" = "xno"; then
42                 SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
43         fi
44 fi
45
46 AC_SUBST(SOUP_DEBUG_FLAGS)
47
48
49 dnl ***************************
50 dnl *** Checks for programs ***
51 dnl ***************************
52
53 AC_PROG_CC
54 AM_PROG_CC_STDC
55 AC_PROG_INSTALL
56
57 # Set STDC_HEADERS
58 AC_HEADER_STDC
59
60 # Initialize libtool
61 AM_PROG_LIBTOOL
62
63 # This isn't a program, but it doesn't fit anywhere else...
64 AC_FUNC_ALLOCA
65
66 dnl ***********************
67 dnl *** Checks for glib ***
68 dnl ***********************
69
70 PKG_CHECK_MODULES(GLIB, glib-2.0)
71 AC_SUBST(GLIB_CFLAGS)
72 AC_SUBST(GLIB_LIBS)
73
74 dnl *********************************
75 dnl *** Networking library checks ***
76 dnl *********************************
77
78 AC_CHECK_HEADERS(sys/sockio.h sys/poll.h sys/param.h)
79 AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
80
81 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
82 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
83
84 AC_CHECK_FUNCS(inet_pton inet_aton)
85
86 ### Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
87 AC_CHECK_FUNC(gethostbyname_r,
88   [
89   dnl  First check for the glibc variant of gethostbyname_r
90
91   AC_MSG_CHECKING(for glibc gethostbyname_r)
92   AC_TRY_LINK([ #include <netdb.h>],[
93           struct hostent result_buf;
94           char buf[1024];
95           struct hostent* result;
96           int h_errnop;
97
98           gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
99                           &result, &h_errnop);
100         ], [
101
102           dnl Have glibc gethostbyname_r
103
104           AC_MSG_RESULT(yes)
105           AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC, 1,
106                     [Define if you have a glibc-style gethostbyname_r()])
107           HAVE_GETHOSTBYNAME_R=yes
108
109         ], [
110
111   dnl  If we don't have glibc gethostbyname_r, check
112   dnl  for Solaris/Irix gethostbyname_r
113
114   AC_MSG_RESULT(no)
115   AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
116   AC_TRY_LINK([ #include <netdb.h>],[
117           struct hostent result;
118           char buf[1024];
119           int h_errnop;
120
121           gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);
122
123         ], [
124
125           dnl Have Solaris/Irix gethostbyname_r
126
127           AC_MSG_RESULT(yes)
128           AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS, 1,
129                     [Define if you have a Solaris-style gethostbyname_r()])
130           HAVE_GETHOSTBYNAME_R=yes
131
132         ], [
133   dnl  If don't have Solaris/Irix gethostbyname_r, check
134   dnl  for HP-UX gethostbyname_r
135
136   AC_MSG_RESULT(no)
137   AC_MSG_CHECKING(for HP-UX gethostbyname_r)
138   AC_TRY_LINK([ #include <netdb.h>],[
139           struct hostent result;
140           char buf[1024];
141           gethostbyname_r("localhost", &result, buf);
142         ], [
143         
144           dnl Have HP-UX gethostbyname_r
145
146           AC_MSG_RESULT(yes)
147           AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX, 1,
148                     [Define if you have an HP-UX-style gethostbyname_r()])
149           HAVE_GETHOSTBYNAME_R=yes
150
151         ]
152      )]
153   )]
154 )])
155
156 # If we don't have gethostbyname_r, we'll use Glib mutexes, but give a warning
157 if test -z "$HAVE_GETHOSTBYNAME_R"; then
158         AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX, 1,
159                   [Define if you have no gethostbyname_r()])
160         AC_MSG_WARN([You have neither Glib threads nor the function
161                     gethostbyname_r.  This means that calls to
162                     gethostbyname (called by the Soup address
163                     functions) will not be thread safe so could
164                     malfunction in programs that use threads.])
165 fi
166
167 AC_CACHE_CHECK(IPv6 support, soup_cv_ipv6, [
168         AC_EGREP_HEADER(sockaddr_in6, netinet/in.h, soup_cv_ipv6=yes, soup_cv_ipv6=no)
169 ])
170 case $soup_cv_ipv6 in
171 yes)
172         AC_DEFINE(HAVE_IPV6, 1, [Define if you have support for IPv6 sockets])
173         ;;
174 esac
175
176 dnl ****************************************************
177 dnl *** SSL Library checks (Mozilla NSS, or OpenSSL) ***
178 dnl ****************************************************
179
180 AC_ARG_ENABLE(ssl, 
181               [  --enable-ssl             Turn on Secure Sockets Layer support [default=yes]],,
182               enable_ssl=yes)
183
184 AC_ARG_WITH(nspr-includes,
185             [  --with-nspr-includes     Specify location of Netscape Portable Runtime headers],
186             [nspr_inc_prefix=-I$withval])
187
188 AC_ARG_WITH(nspr-libs,
189             [  --with-nspr-libs         Specify location of Netscape Portable Runtime libs],
190             [nspr_prefix=$withval],
191             [nspr_prefix=$libdir])
192
193 AC_ARG_WITH(nss-includes,
194             [  --with-nss-includes      Specify location of NSS header files],
195             [nss_inc_prefix=-I$withval])
196
197 AC_ARG_WITH(nss-libs,
198             [  --with-nss-libs          Specify location of NSS libs],
199             [nss_prefix=$withval],
200             [nss_prefix=$libdir])
201
202
203 AC_ARG_WITH(openssl-includes,
204             [  --with-openssl-includes  Specify location of OpenSSL header files],
205             [openssl_inc_prefix=-I$withval])
206
207 AC_ARG_WITH(openssl-libs,
208             [  --with-openssl-libs      Specify location of OpenSSL libs],
209             [openssl_prefix=$withval], 
210             [openssl_prefix=$libdir])
211
212 ###
213 ### Allow for a custom SSL proxy name
214 ###
215 SSL_PROXY_NAME=libsoup-ssl-proxy
216 AC_ARG_WITH(ssl-proxy-name,
217             [  --with-ssl-proxy-name    Custom name for ssl proxy executable [default=libsoup-ssl-proxy]],
218             [SSL_PROXY_NAME=$withval],
219             [SSL_PROXY_NAME=libsoup-ssl-proxy])
220
221 AC_DEFINE_UNQUOTED(SSL_PROXY_NAME, "${SSL_PROXY_NAME}",
222                    [The name to use for the SSL proxy binary. Defaults to libsoup-ssl-proxy])
223 AC_SUBST(SSL_PROXY_NAME)
224
225 ###
226 ### Try to link statically with the SSL library
227 ###
228 AC_ARG_ENABLE(ssl-link-static, 
229               [  --enable-static-ssl      Link with SSL library statically [default=no]],
230               [enable_static_ssl=yes])
231
232 if test "x$enable_ssl" = xyes; then
233         ###
234         ### Check for OpenSSL
235         ###
236         save_CPPFLAGS=$CPPFLAGS
237         CPPFLAGS="$CPPFLAGS $openssl_inc_prefix"
238         AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
239         AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
240                          [enable_openssl="yes"],
241                          [enable_openssl="no"; break])
242
243         if test "x$enable_openssl" = xyes; then
244                 if test "x$enable_static_ssl" = "xyes"; then
245                         OPENSSL_LIBS="$openssl_prefix/libssl.a $openssl_prefix/libcrypto.a"
246                 else
247                         OPENSSL_LIBS="-L$openssl_prefix -lssl -lcrypto $DL_LDFLAGS"
248                 fi
249                 OPENSSL_CFLAGS=$CPPFLAGS
250                 AC_DEFINE(HAVE_OPENSSL, 1,
251                           [Defined if you are using OpenSSL for SSL support])
252         else
253                 OPENSSL_LIBS=
254                 OPENSSL_CFLAGS=
255         fi
256
257         AC_SUBST(OPENSSL_CFLAGS)
258         AC_SUBST(OPENSSL_LIBS)
259         CPPFLAGS=$save_CPPFLAGS
260
261         ###
262         ### Check for Mozilla NSS
263         ###
264         save_CPPFLAGS=$CPPFLAGS
265         CPPFLAGS="$CPPFLAGS $nspr_inc_prefix $nss_inc_prefix"
266         AC_CHECK_HEADERS(nss.h ssl.h pk11func.h,
267                          [enable_nss="yes"],
268                          [enable_nss="no"; break])
269
270         if test "x$enable_nss" = xyes; then
271                 if test "x$enable_static_ssl" = "xyes"; then
272                         NSS_LIBS="-lpthread $nspr_prefix/libnspr4.a $nspr_prefix/libplc4.a $nspr_prefix/libplds4.a $nss_prefix/libnssb.a"
273                 else
274                         NSS_LIBS="-lpthread -L$nspr_prefix -lnspr4 -lplc4 -lplds4 $nss_prefix -lnss3 -lssl3"
275                 fi
276                 NSS_CFLAGS=$CPPFLAGS
277                 AC_DEFINE(HAVE_NSS, 1,
278                           [Defined if you are using Mozilla NSS for SSL support])
279         else
280                 NSS_LIBS=
281                 NSS_CFLAGS=
282         fi
283
284         AC_SUBST(NSS_CFLAGS)
285         AC_SUBST(NSS_LIBS)
286         CPPFLAGS=$save_CPPFLAGS
287 fi
288
289
290 dnl *********************************************
291 dnl *** Checks for gtk-doc (lifted from glib) ***
292 dnl *********************************************
293
294 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH     Path to installed docs ])
295
296 if test "x$with_html_dir" = "x" ; then
297   HTML_DIR='${datadir}/gtk-doc/html'
298 else
299   HTML_DIR=$with_html_dir
300 fi
301
302 AC_SUBST(HTML_DIR)
303
304 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
305 AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
306 AC_SUBST(HAVE_GTK_DOC)
307
308 AC_CHECK_PROG(DB2HTML, db2html, true, false)
309 AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
310
311 dnl Let people disable the gtk-doc stuff.
312 AC_ARG_ENABLE(gtk-doc, 
313               [  --enable-gtk-doc         Use gtk-doc to build documentation [default=auto]], 
314               enable_gtk_doc="$enableval", 
315               enable_gtk_doc=auto)
316
317 if test x$enable_gtk_doc = xauto ; then
318   if test x$GTKDOC = xtrue ; then
319     enable_gtk_doc=yes
320   else
321     enable_gtk_doc=no 
322   fi
323 fi
324
325 dnl NOTE: We need to use a separate automake conditional for this
326 dnl       to make this work with the tarballs.
327 AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
328
329
330 dnl *************************************
331 dnl *** Warnings to show if using GCC ***
332 dnl *************************************
333
334 AC_ARG_ENABLE(more-warnings,
335               [  --disable-more-warnings  Inhibit compiler warnings],
336               set_more_warnings=no)
337
338 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
339         CFLAGS="$CFLAGS \
340                 -Wall -Wstrict-prototypes -Wmissing-declarations \
341                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
342 fi
343
344 # Use reentrant functions
345 CFLAGS="$CFLAGS -D_REENTRANT"
346
347 dnl *****************************
348 dnl *** link proxy statically ***
349 dnl *****************************
350 AC_ARG_ENABLE(static-proxy, 
351   [  --enable-static-proxy  Build ${SSL_PROXY_NAME} statically ])
352
353 if test x"$enable_static_proxy" = xyes; then
354         LINK_STATIC="-Wl,-Bstatic"
355         LINK_DYNAMIC="-Wl,-Bdynamic"
356         FORCE_SHLIBS="dl resolv rt nsl"
357         for lib in $FORCE_SHLIBS; do
358           OPENSSL_LIBS=`echo $OPENSSL_LIBS | sed "s/-l$lib/-Wl,-Bdynamic -l$lib -Wl,-Bstatic/"`
359           GMODULE_LIBS=`echo $GMODULE_LIBS | sed "s/-l$lib/-Wl,-Bdynamic -l$lib -Wl,-Bstatic/"`
360         done
361 else
362         LINK_STATIC=
363         LINK_DYNAMIC=
364 fi
365
366 AC_SUBST(LINK_STATIC)
367 AC_SUBST(LINK_DYNAMIC)
368
369 dnl *************************
370 dnl *** Output Everything ***
371 dnl *************************
372
373 AC_OUTPUT([
374         soup-2.0.pc
375         Makefile
376         libsoup/Makefile
377         tests/Makefile
378         ])
379
380 echo "
381
382 Configuration:
383
384   Source code location:         ${srcdir}
385   Compiler:                     ${CC}
386   Build flags:                  ${CFLAGS} ${SOUP_DEBUG_FLAGS}
387
388   Static SSL Proxy:             ${enable_static_proxy:-no}
389   SSL Proxy Name:               ${SSL_PROXY_NAME}
390
391   OpenSSL support:              ${enable_openssl}
392   Mozilla NSS support:          ${enable_nss}
393
394 "