add CFLAGS to apxs parameters, to output the correct compilation flags
[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} $XML_CFLAGS"
108 SOUP_LIBS="-lsoup $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=" -I${includedir} $APACHE_CFLAGS $XML_CFLAGS"
116 SOUP_APACHE_LIBS="-lsoup -lsoup-apache $APACHE_LIBS $XML_LIBS"
117
118 AC_SUBST(SOUP_APACHE_LIBDIR)
119 AC_SUBST(SOUP_APACHE_INCLUDEDIR)
120 AC_SUBST(SOUP_APACHE_LIBS)
121
122
123
124 # Networking needs
125 AC_CHECK_HEADERS(netinet/in.h netinet/tcp.h)
126 AC_CHECK_HEADERS(sys/sockio.h sys/poll.h sys/param.h)
127
128 AC_CHECK_LIB(nsl, main)
129 AC_CHECK_LIB(resolv, main)
130
131 # Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
132 AC_CHECK_FUNC(gethostbyname_r,
133   [
134   dnl  First check for the glibc variant of gethostbyname_r
135
136   AC_MSG_CHECKING(for glibc gethostbyname_r)
137   AC_TRY_LINK([ #include <netdb.h>],[
138           struct hostent result_buf;
139           char buf[1024];
140           struct hostent* result;
141           int h_errnop;
142
143           gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
144                           &result, &h_errnop);
145         ], [
146
147           dnl Have glibc gethostbyname_r
148
149           AC_MSG_RESULT(yes)
150           AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC)
151           HAVE_GETHOSTBYNAME_R=yes
152
153         ], [
154
155   dnl  If we don't have glibc gethostbyname_r, check
156   dnl  for Solaris/Irix gethostbyname_r
157
158   AC_MSG_RESULT(no)
159   AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
160   AC_TRY_LINK([ #include <netdb.h>],[
161           struct hostent result;
162           char buf[1024];
163           int h_errnop;
164
165           gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);
166
167         ], [
168
169           dnl Have Solaris/Irix gethostbyname_r
170
171           AC_MSG_RESULT(yes)
172           AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS)
173           HAVE_GETHOSTBYNAME_R=yes
174
175         ], [
176   dnl  If don't have Solaris/Irix gethostbyname_r, check
177   dnl  for HP-UX gethostbyname_r
178
179   AC_MSG_RESULT(no)
180   AC_MSG_CHECKING(for HP-UX gethostbyname_r)
181   AC_TRY_LINK([ #include <netdb.h>],[
182           struct hostent result;
183           char buf[1024];
184           gethostbyname_r("localhost", &result, buf);
185         ], [
186         
187           dnl Have HP-UX gethostbyname_r
188
189           AC_MSG_RESULT(yes)
190           AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX)
191           HAVE_GETHOSTBYNAME_R=yes
192
193         ]
194      )]
195   )]
196 )])
197
198 # If we don't have gethostbyname_r, try to use Glib mutexes
199 if test -z "$HAVE_GETHOSTBYNAME_R"; then
200         AM_PATH_GLIB(1.2.0, 
201                      AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX), [
202                      AC_MSG_WARN(You have neither Glib threads nor the function
203                                 gethostbyname_r.  This means that calls to
204                                 gethostbyname (called by the Soup address
205                                 functions) will not be thread safe so could
206                                 malfunction in programs that use threads.)
207                      ])
208 fi
209
210
211
212 # SSL Library Handling
213
214 AC_ARG_ENABLE(ssl, 
215               [  --enable-ssl            Turn on Secure Sockets Layer support [default=yes]],,
216               enable_ssl=yes)
217
218 AC_ARG_WITH(nspr-includes,
219             [  --with-nspr-includes     Specify location of Netscape Portable Runtime headers],
220             [nspr_inc_prefix=-I$withval])
221
222 AC_ARG_WITH(nspr-libs,
223             [  --with-nspr-libs         Specify location of Netscape Portable Runtime libs],[nspr_prefix=-L$withval])
224
225 AC_ARG_WITH(nss-includes,
226             [  --with-nss-includes      Specify location of NSS header files],
227             [nss_inc_prefix=-I$withval])
228
229 AC_ARG_WITH(nss-libs,
230             [  --with-nss-libs          Specify location of NSS libs],
231             [nss_prefix=-L$withval])
232
233
234 AC_ARG_WITH(openssl-includes,
235             [  --with-openssl-includes  Specify location of OpenSSL header files],
236             [openssl_inc_prefix=-I$withval])
237
238 AC_ARG_WITH(openssl-libs,
239             [  --with-openssl-libs      Specify location of OpenSSL libs],
240             [openssl_prefix=-L$withval], 
241             [openssl_prefix=-L/usr/lib])
242
243 enable_openssl="no"
244 enable_nss="no"
245
246 if test "x$enable_ssl" = xyes; then
247         save_CPPFLAGS=$CPPFLAGS
248         CPPFLAGS="$openssl_inc_prefix"
249         AC_CHECK_HEADERS(openssl/ssl.h openssl/err.h,
250                          [OPENSSL_CFLAGS="$CPPFLAGS" 
251                           OPENSSL_LIBS="$openssl_prefix -lssl -lcrypto"
252                           enable_openssl="yes"],
253                          [OPENSSL_CFLAGS="" 
254                           OPENSSL_LIBS="" 
255                           enable_openssl="no"
256                           break])
257         AC_SUBST(OPENSSL_CFLAGS)
258         AC_SUBST(OPENSSL_LIBS)
259         CPPFLAGS=$save_CPPFLAGS
260
261         save_CPPFLAGS=$CPPFLAGS
262         CPPFLAGS="$nspr_inc_prefix $nss_inc_prefix"
263         AC_CHECK_HEADERS(prthread.h security/ssl.h security/pk11func.h,
264                          [NSS_CFLAGS="$CPPFLAGS" 
265                           NSS_LIBS="-lpthread $nspr_prefix -lnspr4 $nss_prefix -lnss3 -lssl3"
266                           enable_nss="yes"],
267                          [NSS_CFLAGS="" 
268                           NSS_LIBS="" 
269                           enable_nss="no"
270                           break])
271         AC_SUBST(NSS_CFLAGS)
272         AC_SUBST(NSS_LIBS)
273         CPPFLAGS=$save_CPPFLAGS
274 fi
275
276
277 enable_apache="no"
278
279 AC_PATH_PROG(APXS,apxs,no)
280 if test x$APXS != xno; then
281         APACHE_CFLAGS="-I`apxs -q INCLUDEDIR CFLAGS`"
282         APACHE_LIBS=`apxs -q LDFLAGS_SHLIB LIBS_SHLIB`
283
284         save_CPPFLAGS=$CPPFLAGS
285         CPPFLAGS=$APACHE_CFLAGS
286         AC_CHECK_HEADERS(httpd.h http_config.h http_core.h http_log.h http_main.h http_protocol.h,
287                           [enable_apache="yes"],
288                           [enable_apache="no"
289                            break])
290         CPPFLAGS=$save_CPPFLAGS
291
292         AC_SUBST(APACHE_CFLAGS)
293         AC_SUBST(APACHE_LIBS)
294 fi
295
296
297 AC_ARG_ENABLE(more-warnings,
298               [  --enable-more-warnings  Maximum compiler warnings],
299               set_more_warnings="$enableval",
300               set_more_warnings=yes)
301
302 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
303         CFLAGS="$CFLAGS \
304         -Wall -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes \
305         -Wnested-externs -Wpointer-arith"
306         WSDL_CFLAGS="-Werror"
307 fi
308
309 AC_SUBST(WSDL_CFLAGS)
310
311 # Use reentrant functions
312 CFLAGS="$CFLAGS -D_REENTRANT"
313
314
315 #       doc/Makefile
316
317 AC_OUTPUT([
318         soup-config
319         soup.pc
320         soup.spec
321         Makefile
322         src/Makefile
323         src/soup-core/Makefile
324         src/soup-wsdl/Makefile
325         tests/Makefile
326         ])
327
328 echo "
329
330 Configuration:
331
332   Source code location:         ${srcdir}
333   Compiler:                     ${CC}
334   Build flags:                  ${CFLAGS} ${SOUP_DEBUG_FLAGS}
335
336   OpenSSL support:              ${enable_openssl}
337   Mozilla NSS support:          ${enable_nss}
338
339   Apache module support:        ${enable_apache}
340
341 "