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