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