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