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