Add in the --enable-libgpg-error flag from the 2.0 branch.
[platform/upstream/libsoup.git] / configure.in
1 dnl *******************************************
2 dnl *** Initialize automake and set version ***
3 dnl *******************************************
4
5 AC_PREREQ(2.53)
6 AC_INIT(libsoup, 2.1.1)
7 AC_CONFIG_SRCDIR(libsoup-2.2.pc.in)
8 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
9
10 AM_CONFIG_HEADER(config.h)
11 AM_MAINTAINER_MODE
12 AC_PROG_MAKE_SET
13
14 SOUP_API_VERSION=2.2
15 AC_SUBST(SOUP_API_VERSION)
16
17 # Increment on interface addition. Reset on removal.
18 SOUP_AGE=0
19
20 # Increment on interface add, remove, or change.
21 SOUP_CURRENT=0
22
23 # Increment on source change. Reset when CURRENT changes.
24 SOUP_REVISION=0
25
26 AC_SUBST(SOUP_CURRENT)
27 AC_SUBST(SOUP_REVISION)
28 AC_SUBST(SOUP_AGE)
29
30 dnl ***************************
31 dnl *** Set debugging flags ***
32 dnl ***************************
33
34 debug_default=minimum
35
36 # Declare --enable-* args and collect ac_help strings
37 AC_ARG_ENABLE(debug, 
38               [  --enable-debug=[no/minimum/yes] turn on debugging [default=$debug_default]],,
39               enable_debug=$debug_default)
40
41 # Set the debug flags
42 if test "x$enable_debug" = "xyes"; then
43         test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
44         SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
45 else
46         if test "x$enable_debug" = "xno"; then
47                 SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
48         fi
49 fi
50
51 AC_SUBST(SOUP_DEBUG_FLAGS)
52
53
54 dnl ***************************
55 dnl *** Checks for programs ***
56 dnl ***************************
57
58 AC_PROG_CC
59 AM_PROG_CC_STDC
60 AC_PROG_INSTALL
61
62 # Set STDC_HEADERS
63 AC_HEADER_STDC
64
65 # Initialize libtool
66 AM_PROG_LIBTOOL
67
68 # This isn't a program, but it doesn't fit anywhere else...
69 AC_FUNC_ALLOCA
70
71 dnl ***********************
72 dnl *** Checks for glib ***
73 dnl ***********************
74
75 AM_PATH_GLIB_2_0(2.0.0,,,gobject)
76
77 dnl *********************************
78 dnl *** Networking library checks ***
79 dnl *********************************
80
81 AC_CHECK_HEADERS(sys/sockio.h sys/poll.h sys/param.h)
82 AC_CHECK_HEADERS(sys/ioctl.h sys/filio.h)
83
84 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
85 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
86
87 AC_CHECK_FUNCS(inet_pton inet_aton)
88
89 ### Check if we have gethostbyname_r (if so, assume gethostbyaddr_r).
90 AC_CHECK_FUNC(gethostbyname_r,
91   [
92   dnl  First check for the glibc variant of gethostbyname_r
93
94   AC_MSG_CHECKING(for glibc gethostbyname_r)
95   AC_TRY_LINK([ #include <netdb.h>],[
96           struct hostent result_buf;
97           char buf[1024];
98           struct hostent* result;
99           int h_errnop;
100
101           gethostbyname_r("localhost", &result_buf, buf, sizeof(buf),
102                           &result, &h_errnop);
103         ], [
104
105           dnl Have glibc gethostbyname_r
106
107           AC_MSG_RESULT(yes)
108           AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIBC, 1,
109                     [Define if you have a glibc-style gethostbyname_r()])
110           HAVE_GETHOSTBYNAME_R=yes
111
112         ], [
113
114   dnl  If we don't have glibc gethostbyname_r, check
115   dnl  for Solaris/Irix gethostbyname_r
116
117   AC_MSG_RESULT(no)
118   AC_MSG_CHECKING(for Solaris/Irix gethostbyname_r)
119   AC_TRY_LINK([ #include <netdb.h>],[
120           struct hostent result;
121           char buf[1024];
122           int h_errnop;
123
124           gethostbyname_r("localhost", &result, buf, sizeof(buf), &h_errnop);
125
126         ], [
127
128           dnl Have Solaris/Irix gethostbyname_r
129
130           AC_MSG_RESULT(yes)
131           AC_DEFINE(HAVE_GETHOSTBYNAME_R_SOLARIS, 1,
132                     [Define if you have a Solaris-style gethostbyname_r()])
133           HAVE_GETHOSTBYNAME_R=yes
134
135         ], [
136   dnl  If don't have Solaris/Irix gethostbyname_r, check
137   dnl  for HP-UX gethostbyname_r
138
139   AC_MSG_RESULT(no)
140   AC_MSG_CHECKING(for HP-UX gethostbyname_r)
141   AC_TRY_LINK([ #include <netdb.h>],[
142           struct hostent result;
143           char buf[1024];
144           gethostbyname_r("localhost", &result, buf);
145         ], [
146         
147           dnl Have HP-UX gethostbyname_r
148
149           AC_MSG_RESULT(yes)
150           AC_DEFINE(HAVE_GETHOSTBYNAME_R_HPUX, 1,
151                     [Define if you have an HP-UX-style gethostbyname_r()])
152           HAVE_GETHOSTBYNAME_R=yes
153
154         ]
155      )]
156   )]
157 )])
158
159 # If we don't have gethostbyname_r, we'll use Glib mutexes, but give a warning
160 if test -z "$HAVE_GETHOSTBYNAME_R"; then
161         AC_DEFINE(HAVE_GETHOSTBYNAME_R_GLIB_MUTEX, 1,
162                   [Define if you have no gethostbyname_r()])
163         AC_MSG_WARN([You have neither Glib threads nor the function
164                     gethostbyname_r.  This means that calls to
165                     gethostbyname (called by the Soup address
166                     functions) will not be thread safe so could
167                     malfunction in programs that use threads.])
168 fi
169
170 AC_CACHE_CHECK(IPv6 support, soup_cv_ipv6, [
171         AC_EGREP_HEADER(sockaddr_in6, netinet/in.h, soup_cv_ipv6=yes, soup_cv_ipv6=no)
172 ])
173 case $soup_cv_ipv6 in
174 yes)
175         AC_DEFINE(HAVE_IPV6, 1, [Define if you have support for IPv6 sockets])
176         ;;
177 esac
178
179 dnl **********************************
180 dnl *** SSL Library check (GnuTLS) ***
181 dnl **********************************
182
183 AC_ARG_ENABLE(ssl, 
184               [  --enable-ssl             Turn on Secure Sockets Layer support [default=yes]],,
185               enable_ssl=yes)
186
187 AC_ARG_ENABLE(ssl-link-static, 
188               [  --enable-static-ssl      Link with SSL library statically [default=no]],
189               [enable_static_ssl=yes])
190
191 AC_ARG_ENABLE(libgpg-error,
192               [  --enable-libgpg-error    Work around broken libgcrypt-config scripts],
193               enable_libgpg_error=yes, enable_libgpg_error=no)
194
195
196 case $enable_ssl in
197 yes)
198         libgpg_error_libs_static=""
199         libgpg_error_libs=""
200
201         if test "x$enable_libgpg_error" = "xyes"; then
202                 AM_PATH_GPG_ERROR("0.4")
203                 if test "x$GPG_ERROR_LIBS" = "x"; then
204                         AC_MSG_ERROR([libgpg-error is needed])
205                 fi
206                 gpg_error_prefix=$($GPG_ERROR_CONFIG --prefix)
207                 libgpg_error_libs_static="$gpg_error_prefix/lib/libgpg-error.a"
208                 libgpg_error_libs="$GPG_ERROR_LIBS"
209         fi
210
211         AC_PATH_PROG(LIBGNUTLS_CONFIG, libgnutls-config, no)
212         case $LIBGNUTLS_CONFIG in
213         no)
214                 AC_MSG_WARN(Disabling SSL support)
215                 enable_ssl=no
216                 break 2
217                 ;;
218         esac
219
220         GNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG --cflags | sed -e 's:-I/usr/include::'`
221         GNUTLS_LIBS="`$LIBGNUTLS_CONFIG --libs | sed -e 's:-L/usr/lib *::'` $libgpg_error_libs"
222
223         save_CPPFLAGS="$CPPFLAGS"
224         CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS"
225         AC_CHECK_HEADERS(gnutls/gnutls.h,,
226                          [AC_MSG_WARN(Disabling SSL support)
227                           enable_ssl=no
228                           break])
229         CPPFLAGS="$save_CPPFLAGS"
230
231         case $enable_static_ssl in
232         yes)
233                 gnutls_libdir=`$LIBGNUTLS_CONFIG --exec-prefix`/lib
234                 GNUTLS_LIBS="$gnutls_libdir/libgnutls.a $gnutls_libdir/libgcrypt.a $libgpg_error_libs_static"
235                 ;;
236         esac
237
238         AC_DEFINE(HAVE_SSL, 1, [Defined if you have SSL support])
239         ;;
240 esac
241
242 AC_SUBST(GNUTLS_CFLAGS)
243 AC_SUBST(GNUTLS_LIBS)
244
245
246 dnl *********************************************
247 dnl *** Checks for gtk-doc (lifted from glib) ***
248 dnl *********************************************
249
250 AC_ARG_WITH(html-dir, [  --with-html-dir=PATH     Path to installed docs ])
251
252 if test "x$with_html_dir" = "x" ; then
253   HTML_DIR='${datadir}/gtk-doc/html'
254 else
255   HTML_DIR=$with_html_dir
256 fi
257
258 AC_SUBST(HTML_DIR)
259
260 AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
261 AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
262 AC_SUBST(HAVE_GTK_DOC)
263
264 AC_CHECK_PROG(DB2HTML, db2html, true, false)
265 AM_CONDITIONAL(HAVE_DOCBOOK, $DB2HTML)
266
267 dnl Let people disable the gtk-doc stuff.
268 AC_ARG_ENABLE(gtk-doc, 
269               [  --enable-gtk-doc         Use gtk-doc to build documentation [default=auto]], 
270               enable_gtk_doc="$enableval", 
271               enable_gtk_doc=auto)
272
273 if test x$enable_gtk_doc = xauto ; then
274   if test x$GTKDOC = xtrue ; then
275     enable_gtk_doc=yes
276   else
277     enable_gtk_doc=no 
278   fi
279 fi
280
281 dnl NOTE: We need to use a separate automake conditional for this
282 dnl       to make this work with the tarballs.
283 AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
284
285
286 dnl *************************************
287 dnl *** Warnings to show if using GCC ***
288 dnl *************************************
289
290 AC_ARG_ENABLE(more-warnings,
291               [  --disable-more-warnings  Inhibit compiler warnings],
292               set_more_warnings=no)
293
294 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
295         CFLAGS="$CFLAGS \
296                 -Wall -Wstrict-prototypes -Wmissing-declarations \
297                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith"
298 fi
299
300 # Use reentrant functions (FIXME!)
301 CFLAGS="$CFLAGS -D_REENTRANT"
302
303 dnl *************************
304 dnl *** Output Everything ***
305 dnl *************************
306
307 AC_OUTPUT([
308         libsoup-2.2.pc
309         Makefile
310         libsoup/Makefile
311         tests/Makefile
312         ])
313
314 echo "
315
316 Configuration:
317
318   Source code location:         ${srcdir}
319   Compiler:                     ${CC}
320   Build flags:                  ${CFLAGS} ${SOUP_DEBUG_FLAGS}
321
322   SSL support:                  ${enable_ssl}
323
324 "