Explicitly add libplc4 and libplds4 which are dependencies of libnspr4.
[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_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
324         AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
325                          [OPENSSL_CFLAGS="$CPPFLAGS" 
326                           OPENSSL_LIBS="$openssl_prefix -lssl -lcrypto $DL_LDFLAGS"
327                           enable_openssl="yes"],
328                          [OPENSSL_CFLAGS="" 
329                           OPENSSL_LIBS="" 
330                           enable_openssl="no"
331                           break])
332         AC_SUBST(OPENSSL_CFLAGS)
333         AC_SUBST(OPENSSL_LIBS)
334         CPPFLAGS=$save_CPPFLAGS
335
336         if test "x$enable_openssl" = xyes; then
337                 AC_DEFINE(HAVE_OPENSSL)
338         fi
339
340         save_CPPFLAGS=$CPPFLAGS
341         CPPFLAGS="$nspr_inc_prefix $nss_inc_prefix"
342         AC_CHECK_HEADERS(nss.h ssl.h pk11func.h,
343                          [NSS_CFLAGS="$CPPFLAGS" 
344                           NSS_LIBS="-lpthread $nspr_prefix -lnspr4 -lplc4 -lplds4 $nss_prefix -lnss3 -lssl3"
345                           enable_nss="yes"],
346                          [NSS_CFLAGS="" 
347                           NSS_LIBS="" 
348                           enable_nss="no"
349                           break])
350         AC_SUBST(NSS_CFLAGS)
351         AC_SUBST(NSS_LIBS)
352         CPPFLAGS=$save_CPPFLAGS
353
354         if test "x$enable_nss" = xyes; then
355                 AC_DEFINE(HAVE_NSS)
356         fi
357 fi
358
359
360 dnl *************************
361 dnl *** Checks for Apache ***
362 dnl *************************
363
364 enable_apache="no"
365
366 AC_PATH_PROG(APXS,apxs,no)
367 if test x$APXS != xno; then
368         APACHE_CFLAGS="-I`apxs -q INCLUDEDIR CFLAGS`"
369         APACHE_LIBS=`apxs -q LDFLAGS_SHLIB LIBS_SHLIB`
370
371         save_CPPFLAGS=$CPPFLAGS
372         CPPFLAGS=$APACHE_CFLAGS
373         AC_CHECK_HEADERS(httpd.h http_config.h http_core.h http_log.h http_main.h http_protocol.h,
374                           [enable_apache="yes"],
375                           [enable_apache="no"
376                            break])
377         CPPFLAGS=$save_CPPFLAGS
378
379         AC_SUBST(APACHE_CFLAGS)
380         AC_SUBST(APACHE_LIBS)
381 fi
382
383
384 dnl *********************************************
385 dnl *** Checks for gtk-doc (lifted from glib) ***
386 dnl *********************************************
387
388 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH     Path to installed docs ])
389
390 if test "x$with_html_dir" = "x" ; then
391   HTML_DIR='${datadir}/gtk-doc/html'
392 else
393   HTML_DIR=$with_html_dir
394 fi
395
396 AC_SUBST(HTML_DIR)
397
398 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
399 AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
400 AC_SUBST(HAVE_GTK_DOC)
401
402 AC_CHECK_PROG(DB2HTML, db2html, true, false)
403 AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
404
405 dnl Let people disable the gtk-doc stuff.
406 AC_ARG_ENABLE(gtk-doc, 
407               [  --enable-gtk-doc         Use gtk-doc to build documentation [default=auto]], 
408               enable_gtk_doc="$enableval", 
409               enable_gtk_doc=auto)
410
411 if test x$enable_gtk_doc = xauto ; then
412   if test x$GTKDOC = xtrue ; then
413     enable_gtk_doc=yes
414   else
415     enable_gtk_doc=no 
416   fi
417 fi
418
419 dnl NOTE: We need to use a separate automake conditional for this
420 dnl       to make this work with the tarballs.
421 AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
422
423
424 dnl *******************************************************
425 dnl *** Type alignment test (based on the one in ORBit) ***
426 dnl *******************************************************
427
428 AC_DEFUN(AC_CHECK_ALIGNOF,
429 [changequote(<<, >>)dnl
430 dnl The name to #define.
431 define(<<AC_TYPE_NAME>>, translit(alignof_$1, [a-z *], [A-Z_P]))dnl
432 dnl The cache variable name.
433 define(<<AC_CV_NAME>>, translit(ac_cv_alignof_$1, [ *], [_p]))dnl
434 changequote([, ])dnl
435 AC_MSG_CHECKING(alignment of $1)
436 align_save_libs="$LIBS"
437 LIBS="$GLIB_LIBS $LIBS"
438 AC_CACHE_VAL(AC_CV_NAME,
439 [AC_TRY_RUN([
440 #include <stdio.h>
441 #include <glib.h>
442 typedef struct {char s1;} gstruct;
443 struct test {char s1; $1 s2;};
444 main()
445 {
446   FILE *f=fopen("conftestval", "w");
447   if (!f) exit(1);
448   fprintf(f, "%d\n", &(((struct test*)0)->s2));
449   exit(0);
450 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, AC_CV_NAME=0)])dnl
451 AC_MSG_RESULT($AC_CV_NAME)
452 LIBS="$align_save_libs"
453 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
454 undefine([AC_TYPE_NAME])dnl
455 undefine([AC_CV_NAME])dnl
456 ])
457
458 orig_CPPFLAGS=$CPPFLAGS
459 CPPFLAGS=$GLIB_CFLAGS
460 AC_CHECK_ALIGNOF(gboolean)
461 AC_CHECK_ALIGNOF(gchar)
462 AC_CHECK_ALIGNOF(guchar)
463 AC_CHECK_ALIGNOF(gint)
464 AC_CHECK_ALIGNOF(guint)
465 AC_CHECK_ALIGNOF(gshort)
466 AC_CHECK_ALIGNOF(gushort)
467 AC_CHECK_ALIGNOF(glong)
468 AC_CHECK_ALIGNOF(gulong)
469 AC_CHECK_ALIGNOF(gint8)
470 AC_CHECK_ALIGNOF(guint8)
471 AC_CHECK_ALIGNOF(gint16)
472 AC_CHECK_ALIGNOF(guint16)
473 AC_CHECK_ALIGNOF(gint32)
474 AC_CHECK_ALIGNOF(guint32)
475 AC_CHECK_ALIGNOF(gfloat)
476 AC_CHECK_ALIGNOF(gdouble)
477 AC_CHECK_ALIGNOF(gpointer)
478 AC_CHECK_ALIGNOF(gstruct)
479 CPPFLAGS=$orig_CPPFLAGS
480
481
482 dnl *************************************
483 dnl *** Warnings to show if using GCC ***
484 dnl *************************************
485
486 AC_ARG_ENABLE(more-warnings,
487               [  --disable-more-warnings  Inhibit compiler warnings],
488               set_more_warnings=no)
489
490 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
491         CFLAGS="$CFLAGS \
492                 -Wall -Wstrict-prototypes -Wmissing-declarations \
493                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
494 fi
495
496 # Use reentrant functions
497 CFLAGS="$CFLAGS -D_REENTRANT"
498
499
500 dnl *************************
501 dnl *** Output Everything ***
502 dnl *************************
503
504 AC_OUTPUT([
505         soup-config
506         soup.pc
507         soup.spec
508         Makefile
509         docs/Makefile
510         docs/reference/Makefile
511         src/Makefile
512         src/libsoup/Makefile
513         src/libsoup-apache/Makefile
514         src/libwsdl/Makefile
515         src/soup-httpd/Makefile
516         src/soup-ssl-proxy/Makefile
517         src/soup-wsdl/Makefile
518         tests/Makefile
519         ])
520
521 echo "
522
523 Configuration:
524
525   Source code location:         ${srcdir}
526   Compiler:                     ${CC}
527   Build flags:                  ${CFLAGS} ${SOUP_DEBUG_FLAGS}
528
529   OpenSSL support:              ${enable_openssl}
530   Mozilla NSS support:          ${enable_nss}
531
532   Apache module support:        ${enable_apache}
533
534 "