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