Bump development version to 0.7.99.
[platform/upstream/libsoup.git] / configure.in
1 dnl *******************************************
2 dnl *** Initialize automake and set version ***
3 dnl *******************************************
4
5 AC_INIT(src/libsoup/soup.h)
6
7 # Increment on interface addition. Reset on removal.
8 SOUP_AGE=1
9
10 # Increment on interface add, remove, or change.
11 SOUP_CURRENT=4
12
13 # Increment on source change. Reset when CURRENT changes.
14 SOUP_REVISION=0
15
16 AC_SUBST(SOUP_CURRENT)
17 AC_SUBST(SOUP_REVISION)
18 AC_SUBST(SOUP_AGE)
19
20 # Update in src/soup-core/soup-private.h for Windows
21 AM_INIT_AUTOMAKE(soup, 0.7.99)
22
23 AM_CONFIG_HEADER(config.h)
24 AM_MAINTAINER_MODE
25 AC_PROG_MAKE_SET
26
27
28 dnl ***************************
29 dnl *** Set debugging flags ***
30 dnl ***************************
31
32 debug_default=minimum
33
34 # Declare --enable-* args and collect ac_help strings
35 AC_ARG_ENABLE(debug, 
36               [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,
37               enable_debug=$debug_default)
38
39 # Set the debug flags
40 if test "x$enable_debug" = "xyes"; then
41         test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
42         SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
43 else
44         if test "x$enable_debug" = "xno"; then
45                 SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
46         fi
47 fi
48
49 AC_SUBST(SOUP_DEBUG_FLAGS)
50
51
52 dnl ***************************
53 dnl *** Checks for programs ***
54 dnl ***************************
55
56 AC_PROG_CC
57 AM_PROG_CC_STDC
58 AC_PROG_INSTALL
59
60 # Set STDC_HEADERS
61 AC_HEADER_STDC
62
63 # Initialize libtool
64 AM_PROG_LIBTOOL
65
66 # This isn't a program, but it doesn't fit anywhere else...
67 AC_FUNC_ALLOCA
68
69
70 dnl ***************************
71 dnl *** Checks for glib 1.2 ***
72 dnl ***************************
73
74 AM_PATH_GLIB(1.2.0,,
75              AC_MSG_ERROR([Cannot find GLIB: Is glib-config in path?]))
76
77 GLIB_CFLAGS=`glib-config --cflags glib`
78 GLIB_LIBS=`glib-config --libs glib`
79 GMODULE_LIBS=`glib-config --libs gmodule`
80
81 AC_SUBST(GLIB_CFLAGS)
82 AC_SUBST(GLIB_LIBS)
83 AC_SUBST(GMODULE_LIBS)
84
85
86 dnl ****************************
87 dnl *** Checks for gnome-xml ***
88 dnl ****************************
89
90 FAVOUR_LIBXML=1
91 AC_ARG_WITH(libxml,
92         [  --with-libxml=[1/2] which version of libxml to use [default=$FAVOUR_LIBXML]],,
93         with_libxml=$FAVOUR_LIBXML)
94
95 if test "x$with_libxml" = "x" -o "$with_libxml" = "yes"; then
96         with_libxml=$FAVOUR_LIBXML
97 fi
98
99 if test "$with_libxml" = "1"; then
100         AC_PATH_PROG(XML_CONFIG,xml-config,no)
101         if test x$XML_CONFIG = xno; then
102                 AC_MSG_ERROR([Cannot find LIBXML: Is xml-config in path?])
103         fi
104
105         XML_MIN_VERSION=1.8.8
106 else
107         if test "$with_libxml" = "2"; then
108                 AC_PATH_PROG(XML_CONFIG,xml2-config,no)
109                 if test x$XML_CONFIG = xno; then
110                         AC_MSG_ERROR([Cannot find LIBXML2: Is xml2-config in path?])
111                 fi
112
113                 XML_MIN_VERSION=2.3.10
114         else
115                 AC_MSG_ERROR(Can't use libxml version $with_libxml)
116         fi
117 fi
118
119 dnl Check version
120 XML_VERSION=`$XML_CONFIG --version`
121 ver=`echo $XML_VERSION | awk -F. '{printf("%d", ($1*1000+$2)*1000+$3);}'`
122 minver=`echo $XML_MIN_VERSION | awk -F. '{printf("%d", ($1*1000+$2)*1000+$3);}'`
123 if test "$minver" -gt "$ver"
124 then
125         AC_MSG_ERROR(Found libxml version $XML_VERSION. You need $XML_MIN_VERSION or newer)
126 fi
127
128 XML_CFLAGS=`$XML_CONFIG --cflags`
129 XML_LIBS=`$XML_CONFIG --libs`
130
131 AC_SUBST(XML_CFLAGS)
132 AC_SUBST(XML_LIBS)
133
134
135 dnl ***********************
136 dnl *** Checks for popt ***
137 dnl ***********************
138
139 AC_ARG_WITH(popt-includes,
140             [  --with-popt-includes     Specify location of popt headers],
141             [popt_inc_prefix=-I$withval])
142
143 AC_ARG_WITH(popt-libs,
144             [  --with-popt-libs         Specify location of popt libs],
145             [popt_prefix=$withval],
146             [popt_prefix=/usr/lib])
147         
148 save_CPPFLAGS=$CPPFLAGS
149 save_LIBS=$LIBS
150 CPPFLAGS="$CPPFLAGS $popt_inc_prefix"
151 LIBS="$LIBS -L$prefix"
152
153 AC_CHECK_LIB(popt, 
154              poptGetContext, 
155              [POPT_LIBS="$LIBS -lpopt"] , 
156              AC_MSG_ERROR([popt is required]))
157 AC_CHECK_HEADERS(popt.h, [POPT_CFLAGS="$CFLAGS"], AC_MSG_ERROR([popt.h is required]))
158
159 CPPFLAGS=$save_CPPFLAGS
160 LIBS=$save_LIBS
161
162 AC_SUBST(POPT_CFLAGS)
163 AC_SUBST(POPT_LIBS)
164
165
166 dnl **********************************************
167 dnl *** Variable substitution for soup*Conf.sh ***
168 dnl **********************************************
169
170 ### soupConf.sh
171 SOUP_LIBDIR='-L${libdir}'
172 SOUP_INCLUDEDIR=" -I${includedir}/soup $GLIB_CFLAGS $XML_CFLAGS"
173 SOUP_LIBS="-lsoup $GLIB_LIBS $XML_LIBS"
174
175 AC_SUBST(SOUP_LIBDIR)
176 AC_SUBST(SOUP_INCLUDEDIR)
177 AC_SUBST(SOUP_LIBS)
178
179 ### soup-apacheConf.sh
180 SOUP_APACHE_LIBDIR='-L${libdir}'
181 SOUP_APACHE_INCLUDEDIR="$SOUP_INCLUDEDIR $APACHE_CFLAGS"
182 SOUP_APACHE_LIBS="$SOUP_LIBS -lsoup-apache $APACHE_LIBS"
183
184 AC_SUBST(SOUP_APACHE_LIBDIR)
185 AC_SUBST(SOUP_APACHE_INCLUDEDIR)
186 AC_SUBST(SOUP_APACHE_LIBS)
187
188 ### soup-wsdlConf.sh
189 SOUP_WSDL_LIBDIR='-L${libdir}'
190 SOUP_WSDL_INCLUDEDIR=" -I${includedir}/soup $GLIB_CFLAGS $XML_CFLAGS"
191 SOUP_WSDL_LIBS="$SOUP_LIBS -lwsdl"
192
193 AC_SUBST(SOUP_WSDL_LIBDIR)
194 AC_SUBST(SOUP_WSDL_INCLUDEDIR)
195 AC_SUBST(SOUP_WSDL_LIBS)
196
197
198 dnl *********************************
199 dnl *** Networking library checks ***
200 dnl *********************************
201
202 AC_CHECK_HEADERS(unistd.h)
203 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h)
204 AC_CHECK_HEADERS(sys/socket.h sys/sockio.h sys/poll.h sys/param.h sys/wait.h)
205 AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
206
207 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
208 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
209
210 AC_CHECK_FUNCS(inet_pton inet_aton)
211
212 ### Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
213 AC_CHECK_FUNC(gethostbyname_r,
214   [
215   dnl  First check for the glibc variant of gethostbyname_r
216
217   AC_MSG_CHECKING(for glibc gethostbyname_r)
218   AC_TRY_LINK([ #include <netdb.h>],[
219           struct hostent result_buf;
220           char buf[1024];
221           struct hostent* result;
222           int h_errnop;
223
224           gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
225                           &result, &h_errnop);
226         ], [
227
228           dnl Have glibc gethostbyname_r
229
230           AC_MSG_RESULT(yes)
231           AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC)
232           HAVE_GETHOSTBYNAME_R=yes
233
234         ], [
235
236   dnl  If we don't have glibc gethostbyname_r, check
237   dnl  for Solaris/Irix gethostbyname_r
238
239   AC_MSG_RESULT(no)
240   AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
241   AC_TRY_LINK([ #include <netdb.h>],[
242           struct hostent result;
243           char buf[1024];
244           int h_errnop;
245
246           gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);
247
248         ], [
249
250           dnl Have Solaris/Irix gethostbyname_r
251
252           AC_MSG_RESULT(yes)
253           AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS)
254           HAVE_GETHOSTBYNAME_R=yes
255
256         ], [
257   dnl  If don't have Solaris/Irix gethostbyname_r, check
258   dnl  for HP-UX gethostbyname_r
259
260   AC_MSG_RESULT(no)
261   AC_MSG_CHECKING(for HP-UX gethostbyname_r)
262   AC_TRY_LINK([ #include <netdb.h>],[
263           struct hostent result;
264           char buf[1024];
265           gethostbyname_r("localhost", &result, buf);
266         ], [
267         
268           dnl Have HP-UX gethostbyname_r
269
270           AC_MSG_RESULT(yes)
271           AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX)
272           HAVE_GETHOSTBYNAME_R=yes
273
274         ]
275      )]
276   )]
277 )])
278
279 ### If we don't have gethostbyname_r, try to use Glib mutexes
280 if test -z "$HAVE_GETHOSTBYNAME_R"; then
281         AM_PATH_GLIB(1.2.0, 
282                      AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX), [
283                      AC_MSG_WARN(You have neither Glib threads nor the function
284                                  gethostbyname_r.  This means that calls to
285                                  gethostbyname (called by the Soup address
286                                  functions) will not be thread safe so could
287                                  malfunction in programs that use threads.)
288                      ])
289 fi
290
291
292 dnl ****************************************************
293 dnl *** SSL Library checks (Mozilla NSS, or OpenSSL) ***
294 dnl ****************************************************
295
296 AC_ARG_ENABLE(ssl, 
297               [  --enable-ssl             Turn on Secure Sockets Layer support [default=yes]],,
298               enable_ssl=yes)
299
300 AC_ARG_WITH(nspr-includes,
301             [  --with-nspr-includes     Specify location of Netscape Portable Runtime headers],
302             [nspr_inc_prefix=-I$withval])
303
304 AC_ARG_WITH(nspr-libs,
305             [  --with-nspr-libs         Specify location of Netscape Portable Runtime libs],
306             [nspr_prefix=$withval],
307             [nspr_prefix=/usr/lib])
308
309 AC_ARG_WITH(nss-includes,
310             [  --with-nss-includes      Specify location of NSS header files],
311             [nss_inc_prefix=-I$withval])
312
313 AC_ARG_WITH(nss-libs,
314             [  --with-nss-libs          Specify location of NSS libs],
315             [nss_prefix=$withval],
316             [nss_prefix=/usr/lib])
317
318
319 AC_ARG_WITH(openssl-includes,
320             [  --with-openssl-includes  Specify location of OpenSSL header files],
321             [openssl_inc_prefix=-I$withval])
322
323 AC_ARG_WITH(openssl-libs,
324             [  --with-openssl-libs      Specify location of OpenSSL libs],
325             [openssl_prefix=$withval], 
326             [openssl_prefix=/usr/lib])
327
328 ###
329 ### Allow for a custom SSL proxy name
330 ###
331 AC_ARG_WITH(ssl-proxy-name,
332             [  --with-ssl-proxy-name    Custom name for ssl proxy executable [default=soup-ssl-proxy]],
333             [SSL_PROXY_NAME=$withval],
334             [SSL_PROXY_NAME=soup-ssl-proxy])
335
336 AC_DEFINE_UNQUOTED(SSL_PROXY_NAME, "${SSL_PROXY_NAME}")
337 AC_SUBST(SSL_PROXY_NAME)
338
339 ###
340 ### Try to link statically with the SSL library
341 ###
342 AC_ARG_ENABLE(ssl-link-static, 
343               [  --enable-static-ssl      Link with SSL library statically [default=no]],
344               [enable_static_ssl=yes])
345
346 if test "x$enable_ssl" = xyes; then
347         ###
348         ### Check for OpenSSL
349         ###
350         save_CPPFLAGS=$CPPFLAGS
351         CPPFLAGS="$CPPFLAGS $openssl_inc_prefix"
352         AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
353         AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
354                          [enable_openssl="yes"],
355                          [enable_openssl="no"; break])
356
357         if test "x$enable_openssl" = xyes; then
358                 if test "x$enable_static_ssl" = "xyes"; then
359                         OPENSSL_LIBS="$openssl_prefix/libssl.a $openssl_prefix/libcrypto.a"
360                 else
361                         OPENSSL_LIBS="-L$openssl_prefix -lssl -lcrypto $DL_LDFLAGS"
362                 fi
363                 OPENSSL_CFLAGS=$CPPFLAGS
364                 AC_DEFINE(HAVE_OPENSSL)
365         else
366                 OPENSSL_LIBS=
367                 OPENSSL_CFLAGS=
368         fi
369
370         AC_SUBST(OPENSSL_CFLAGS)
371         AC_SUBST(OPENSSL_LIBS)
372         CPPFLAGS=$save_CPPFLAGS
373
374         ###
375         ### Check for Mozilla NSS
376         ###
377         save_CPPFLAGS=$CPPFLAGS
378         CPPFLAGS="$CPPFLAGS $nspr_inc_prefix $nss_inc_prefix"
379         AC_CHECK_HEADERS(nss.h ssl.h pk11func.h,
380                          [enable_nss="yes"],
381                          [enable_nss="no"; break])
382
383         if test "x$enable_nss" = xyes; then
384                 if test "x$enable_static_ssl" = "xyes"; then
385                         NSS_LIBS="-lpthread $nspr_prefix/libnspr4.a $nspr_prefix/libplc4.a $nspr_prefix/libplds4.a $nss_prefix/libnssb.a"
386                 else
387                         NSS_LIBS="-lpthread -L$nspr_prefix -lnspr4 -lplc4 -lplds4 $nss_prefix -lnss3 -lssl3"
388                 fi
389                 NSS_CFLAGS=$CPPFLAGS
390                 AC_DEFINE(HAVE_NSS)
391         else
392                 NSS_LIBS=
393                 NSS_CFLAGS=
394         fi
395
396         AC_SUBST(NSS_CFLAGS)
397         AC_SUBST(NSS_LIBS)
398         CPPFLAGS=$save_CPPFLAGS
399 fi
400
401
402 dnl *************************
403 dnl *** Checks for Apache ***
404 dnl *************************
405
406 enable_apache="no"
407
408 AC_PATH_PROG(APXS,apxs,no)
409 if test x$APXS != xno; then
410         APACHE_CFLAGS="-I`apxs -q INCLUDEDIR CFLAGS`"
411         APACHE_LIBS=`apxs -q LDFLAGS_SHLIB LIBS_SHLIB`
412
413         save_CPPFLAGS=$CPPFLAGS
414         CPPFLAGS=$APACHE_CFLAGS
415         AC_CHECK_HEADERS(httpd.h http_config.h http_core.h http_log.h http_main.h http_protocol.h,
416                           [enable_apache="yes"],
417                           [enable_apache="no"
418                            break])
419         CPPFLAGS=$save_CPPFLAGS
420
421         AC_SUBST(APACHE_CFLAGS)
422         AC_SUBST(APACHE_LIBS)
423 fi
424
425
426 dnl *********************************************
427 dnl *** Checks for gtk-doc (lifted from glib) ***
428 dnl *********************************************
429
430 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH     Path to installed docs ])
431
432 if test "x$with_html_dir" = "x" ; then
433   HTML_DIR='${datadir}/gtk-doc/html'
434 else
435   HTML_DIR=$with_html_dir
436 fi
437
438 AC_SUBST(HTML_DIR)
439
440 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
441 AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
442 AC_SUBST(HAVE_GTK_DOC)
443
444 AC_CHECK_PROG(DB2HTML, db2html, true, false)
445 AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
446
447 dnl Let people disable the gtk-doc stuff.
448 AC_ARG_ENABLE(gtk-doc, 
449               [  --enable-gtk-doc         Use gtk-doc to build documentation [default=auto]], 
450               enable_gtk_doc="$enableval", 
451               enable_gtk_doc=auto)
452
453 if test x$enable_gtk_doc = xauto ; then
454   if test x$GTKDOC = xtrue ; then
455     enable_gtk_doc=yes
456   else
457     enable_gtk_doc=no 
458   fi
459 fi
460
461 dnl NOTE: We need to use a separate automake conditional for this
462 dnl       to make this work with the tarballs.
463 AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
464
465
466 dnl *******************************************************
467 dnl *** Type alignment test (based on the one in ORBit) ***
468 dnl *******************************************************
469
470 AC_DEFUN(AC_CHECK_ALIGNOF,
471 [changequote(<<, >>)dnl
472 dnl The name to #define.
473 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
474 dnl The cache variable name.
475 define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl
476 changequote([, ])dnl
477 AC_MSG_CHECKING(alignment of $1)
478 align_save_libs="$LIBS"
479 LIBS="$GLIB_LIBS $LIBS"
480 AC_CACHE_VAL(AC_CV_NAME,
481 [AC_TRY_RUN([
482 #include <stdio.h>
483 #include <glib.h>
484 typedef struct {char s1;} gstruct;
485 struct test {char s1; $1 s2;};
486 main()
487 {
488   FILE *f=fopen("conftestval", "w");
489   if (!f) exit(1);
490   fprintf(f, "%d\n", &(((struct test*)0)->s2));
491   exit(0);
492 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
493 AC_MSG_RESULT($AC_CV_NAME)
494 LIBS="$align_save_libs"
495 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
496 undefine([AC_TYPE_NAME])dnl
497 undefine([AC_CV_NAME])dnl
498 ])
499
500 orig_CPPFLAGS=$CPPFLAGS
501 CPPFLAGS=$GLIB_CFLAGS
502 AC_CHECK_ALIGNOF(gboolean)
503 AC_CHECK_ALIGNOF(gchar)
504 AC_CHECK_ALIGNOF(guchar)
505 AC_CHECK_ALIGNOF(gint)
506 AC_CHECK_ALIGNOF(guint)
507 AC_CHECK_ALIGNOF(gshort)
508 AC_CHECK_ALIGNOF(gushort)
509 AC_CHECK_ALIGNOF(glong)
510 AC_CHECK_ALIGNOF(gulong)
511 AC_CHECK_ALIGNOF(gint8)
512 AC_CHECK_ALIGNOF(guint8)
513 AC_CHECK_ALIGNOF(gint16)
514 AC_CHECK_ALIGNOF(guint16)
515 AC_CHECK_ALIGNOF(gint32)
516 AC_CHECK_ALIGNOF(guint32)
517 AC_CHECK_ALIGNOF(gfloat)
518 AC_CHECK_ALIGNOF(gdouble)
519 AC_CHECK_ALIGNOF(gpointer)
520 AC_CHECK_ALIGNOF(gstruct)
521 CPPFLAGS=$orig_CPPFLAGS
522
523
524 dnl *************************************
525 dnl *** Warnings to show if using GCC ***
526 dnl *************************************
527
528 AC_ARG_ENABLE(more-warnings,
529               [  --disable-more-warnings  Inhibit compiler warnings],
530               set_more_warnings=no)
531
532 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
533         CFLAGS="$CFLAGS \
534                 -Wall -Wstrict-prototypes -Wmissing-declarations \
535                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
536 fi
537
538 # Use reentrant functions
539 CFLAGS="$CFLAGS -D_REENTRANT"
540
541
542 dnl *************************
543 dnl *** Output Everything ***
544 dnl *************************
545
546 AC_OUTPUT([
547         soup-config
548         soup.pc
549         soup.spec
550         Makefile
551         docs/Makefile
552         docs/reference/Makefile
553         src/Makefile
554         src/libsoup/Makefile
555         src/libsoup-apache/Makefile
556         src/libwsdl/Makefile
557         src/soup-httpd/Makefile
558         src/soup-ssl-proxy/Makefile
559         src/soup-wsdl/Makefile
560         tests/Makefile
561         ])
562
563 echo "
564
565 Configuration:
566
567   Source code location:         ${srcdir}
568   Compiler:                     ${CC}
569   Build flags:                  ${CFLAGS} ${SOUP_DEBUG_FLAGS}
570
571   OpenSSL support:              ${enable_openssl}
572   Mozilla NSS support:          ${enable_nss}
573
574   Apache module support:        ${enable_apache}
575
576 "