c9f25bcac9cc1af7463da79429e6ecf0836f4d8c
[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.29.6)
7 AC_CONFIG_SRCDIR(libsoup-2.4.pc.in)
8 AC_CONFIG_MACRO_DIR([m4])
9
10 AM_INIT_AUTOMAKE([foreign])
11 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
12
13 AM_CONFIG_HEADER(config.h)
14 AC_PROG_MAKE_SET
15
16 SOUP_API_VERSION=2.4
17 AC_SUBST(SOUP_API_VERSION)
18
19 # Increment on interface addition. Reset on removal.
20 SOUP_AGE=3
21
22 # Increment on interface add, remove, or change.
23 SOUP_CURRENT=4
24
25 # Increment on source change. Reset when CURRENT changes.
26 SOUP_REVISION=0
27
28 AC_SUBST(SOUP_CURRENT)
29 AC_SUBST(SOUP_REVISION)
30 AC_SUBST(SOUP_AGE)
31
32 dnl ***************************
33 dnl *** Set debugging flags ***
34 dnl ***************************
35
36 debug_default=minimum
37
38 # Declare --enable-* args and collect ac_help strings
39 AC_ARG_ENABLE(debug, 
40               AS_HELP_STRING([--enable-debug=[no/minimum/yes]],
41                              [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 # Set the maintainer flags
57 if test -d .git; then
58         SOUP_MAINTAINER_FLAGS="-DG_DISABLE_DEPRECATED"
59         AC_SUBST(SOUP_MAINTAINER_FLAGS)
60 fi
61
62 dnl ***************************
63 dnl *** Checks for programs ***
64 dnl ***************************
65
66 AC_PROG_CC
67 AM_PROG_CC_STDC
68 AC_PROG_INSTALL
69
70 # Set STDC_HEADERS
71 AC_HEADER_STDC
72
73 # Initialize libtool
74 AC_LIBTOOL_WIN32_DLL
75 AM_PROG_LIBTOOL
76
77 # This isn't a program, but it doesn't fit anywhere else...
78 AC_FUNC_ALLOCA
79
80 dnl ***********************
81 dnl *** Checks for glib ***
82 dnl ***********************
83
84 AM_PATH_GLIB_2_0(2.21.3,,,gobject gthread gio)
85 if test "$GLIB_LIBS" = ""; then
86    AC_MSG_ERROR(GLIB 2.21.3 or later is required to build libsoup)
87 fi
88 GLIB_CFLAGS="$GLIB_CFLAGS -DG_DISABLE_SINGLE_INCLUDES"
89
90 PKG_CHECK_MODULES(XML, libxml-2.0)
91 AC_SUBST(XML_CFLAGS)
92 AC_SUBST(XML_LIBS)
93
94 dnl ***********************
95 dnl *** Check for Win32 ***
96 dnl ***********************
97
98 AC_MSG_CHECKING([for Win32])
99 case "$host" in
100   *-*-mingw*)
101     os_win32=yes
102     ;;
103   *)
104     os_win32=no
105     ;;
106 esac
107 AC_MSG_RESULT([$os_win32])
108 AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
109
110 dnl *******************
111 dnl *** Misc checks ***
112 dnl *******************
113 AC_CHECK_FUNCS(gmtime_r)
114 AC_CHECK_FUNCS(mmap)
115
116 dnl *********************************
117 dnl *** Networking library checks ***
118 dnl *********************************
119
120 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
121
122 dnl **********************************
123 dnl *** SSL Library check (GnuTLS) ***
124 dnl **********************************
125
126 AC_ARG_ENABLE(ssl, 
127               AS_HELP_STRING([--disable-ssl], [Disable SSL/TLS support (not recommended)]),,
128               enable_ssl=auto)
129
130 have_ssl=no
131 if test "$enable_ssl" != "no"; then
132         PKG_CHECK_MODULES(LIBGNUTLS, gnutls >= 2.1.7,
133                 [AM_PATH_LIBGCRYPT([], have_ssl=yes, have_ssl=no)], have_ssl=no)
134 fi
135 if test "$have_ssl" = "yes"; then
136         AC_DEFINE(HAVE_SSL, 1, [Defined if you have SSL support])
137         SSL_REQUIREMENT="gnutls"
138 else
139         if test "$enable_ssl" = "no"; then
140                 AC_MSG_WARN(Disabling SSL support);
141         else
142                 AC_MSG_ERROR([Could not configure SSL support.
143 Pass "--disable-ssl" if you really want to build without SSL support]);
144         fi
145 fi
146
147 AC_SUBST(LIBGNUTLS_CFLAGS)
148 AC_SUBST(LIBGNUTLS_LIBS)
149 AC_SUBST(SSL_REQUIREMENT)
150
151 dnl This is not supposed to be conditional, but...
152 AM_CONDITIONAL(HAVE_SSL, test $enable_ssl != no)
153
154
155 dnl *********************
156 dnl *** GNOME support ***
157 dnl *********************
158 AC_MSG_CHECKING(whether to build libsoup-gnome)
159 AC_ARG_WITH(gnome,
160             AS_HELP_STRING([--without-gnome], [Do not build libsoup-gnome]),
161             :, [if test $os_win32 = yes; then with_gnome=no; else with_gnome=yes; fi])
162 AC_MSG_RESULT($with_gnome)
163
164 if test $with_gnome != no; then
165         PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1, :,
166                           AC_MSG_ERROR(
167 [Could not find gnome-keyring devel files.
168 Configure with --without-gnome if you wish to build only libsoup
169 without GNOME-specific features.]))
170 fi
171 AC_SUBST(GNOME_KEYRING_CFLAGS)
172 AC_SUBST(GNOME_KEYRING_LIBS)
173
174 AM_CONDITIONAL(BUILD_LIBSOUP_GNOME, test $with_gnome != no)
175
176 if test $with_gnome != no; then
177         AC_DEFINE(HAVE_GNOME, 1, [Defined if GNOME support is enabled])
178
179         PKG_CHECK_MODULES(LIBPROXY, libproxy-1.0, :, [AC_MSG_ERROR(dnl
180 [Could not find libproxy:
181
182 $LIBPROXY_PKG_ERRORS
183
184 This is required for GNOME proxy support.
185
186 Pass "--without-gnome" to configure if you want to build libsoup
187 without GNOME support.])])
188
189         PKG_CHECK_MODULES(GCONF, gconf-2.0, , [AC_MSG_ERROR(dnl
190 [Could not find GConf:
191
192 $GCONF_PKG_ERRORS
193
194 Due to bugs in libproxy as of the GNOME 2.26 freeze date, GConf is
195 *also* required for GNOME proxy support.
196
197 Pass "--without-gnome" to configure if you want to build libsoup
198 without GNOME support.])])
199
200         PKG_CHECK_MODULES(SQLITE, sqlite3, :, [AC_MSG_ERROR(dnl
201 [Could not find sqlite3 devel files:
202
203 $SQLITE_PKG_ERRORS
204
205 Pass "--without-gnome" to configure if you want to build libsoup
206 without GNOME support.])])
207 fi
208 AC_SUBST(HAVE_GNOME)
209 AC_SUBST(GCONF_CFLAGS)
210 AC_SUBST(GCONF_LIBS)
211 AC_SUBST(LIBPROXY_CFLAGS)
212 AC_SUBST(LIBPROXY_LIBS)
213 AC_SUBST(SQLITE_CFLAGS)
214 AC_SUBST(SQLITE_LIBS)
215
216
217 dnl ***************
218 dnl *** gtk-doc ***
219 dnl ***************
220 GTK_DOC_CHECK([1.0])
221
222
223 dnl *************************************
224 dnl *** Warnings to show if using GCC ***
225 dnl *************************************
226
227 AC_ARG_ENABLE(more-warnings,
228               AS_HELP_STRING([--disable-more-warnings], [Inhibit compiler warnings]),
229               set_more_warnings=no)
230
231 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
232         CFLAGS="$CFLAGS \
233                 -Wall -Wstrict-prototypes -Wmissing-declarations \
234                 -Wmissing-prototypes -Wnested-externs -Wpointer-arith \
235                 -Wdeclaration-after-statement -Wformat=2 -Winit-self \
236                 -Waggregate-return -Wmissing-format-attribute"
237
238         for option in -Wmissing-include-dirs -Wundef; do
239                 SAVE_CFLAGS="$CFLAGS"
240                 CFLAGS="$CFLAGS $option"
241                 AC_MSG_CHECKING([whether gcc understands $option])
242                 AC_TRY_COMPILE([], [],
243                         has_option=yes,
244                         has_option=no,)
245                 AC_MSG_RESULT($has_option)
246                 if test $has_option = no; then
247                         CFLAGS="$SAVE_CFLAGS"
248                 fi
249         done
250 fi
251
252 if test "$os_win32" != yes; then
253         # Use reentrant functions (FIXME!)
254         CFLAGS="$CFLAGS -D_REENTRANT"
255 fi
256
257 dnl ******************************
258 dnl *** Stuff for regression tests
259 dnl ******************************
260 AC_MSG_NOTICE([checking for programs needed for regression tests])
261 MISSING_REGRESSION_TEST_PACKAGES=""
262 if test $have_ssl = "no"; then
263     MISSING_REGRESSION_TEST_PACKAGES=" gnutls"
264 fi
265
266 AC_ARG_WITH(apache-httpd,
267             AS_HELP_STRING([--with-apache-httpd], [Path to apache httpd (for tests)]),
268             APACHE_HTTPD="$withval",
269             [AC_PATH_PROGS(APACHE_HTTPD, httpd2 httpd apache2 apache, no, ${PATH}:/usr/sbin)])
270 if test "$APACHE_HTTPD" != "no"; then
271     AC_MSG_CHECKING([Apache version])
272     apache_version=`$APACHE_HTTPD -v 2>/dev/null | sed -ne 's/Server version: Apache\///p'`
273     case $apache_version in
274     2.2.*)
275         AC_MSG_RESULT([$apache_version (ok)])
276         ;;
277     *)
278         AC_MSG_RESULT([$apache_version (ignoring)])
279         APACHE_HTTPD="no"
280         ;;
281     esac
282 fi
283 AC_SUBST(APACHE_HTTPD)
284 AC_DEFINE_UNQUOTED(APACHE_HTTPD, "$APACHE_HTTPD", [Apache httpd])
285
286 if test "$APACHE_HTTPD" != "no"; then
287     AC_MSG_CHECKING([for Apache module directory])
288     AC_ARG_WITH(apache-module-dir,
289                 AS_HELP_STRING([--with-apache-module-dir], [Apache modules dirs (for tests)]),
290                 apache_module_dirs="$withval",
291                 [apache_prefix=`dirname \`dirname $APACHE_HTTPD\``
292                 mpm=`$APACHE_HTTPD -V | sed -ne 's/^Server MPM: */-/p' | tr 'A-Z' 'a-z'`
293                 # This only works with bash, but should fail harmlessly in sh
294                 apache_module_dirs=`echo $apache_prefix/lib{64,}/{apache,apache2,http,http2,httpd}{$mpm,}{/modules,}`])
295     for dir in $apache_module_dirs; do
296         if test -f $dir/mod_auth_digest.so; then
297             APACHE_MODULE_DIR="$dir"
298         fi
299         if test -f $dir/mod_ssl.so; then
300             APACHE_SSL_MODULE_DIR="$dir"
301             IF_HAVE_APACHE_SSL=""
302         fi
303         if test -f $dir/mod_php5.so; then
304             APACHE_PHP_MODULE_DIR="$dir"
305             APACHE_PHP_MODULE=mod_php5.so
306         fi
307         if test -f $dir/libphp5.so; then
308             APACHE_PHP_MODULE_DIR="$dir"
309             APACHE_PHP_MODULE=libphp5.so
310         fi
311     done
312     AC_MSG_RESULT($APACHE_MODULE_DIR)
313     AC_SUBST(APACHE_MODULE_DIR)
314     AC_SUBST(APACHE_SSL_MODULE_DIR)
315     AC_SUBST(APACHE_PHP_MODULE_DIR)
316     AC_SUBST(APACHE_PHP_MODULE)
317 fi
318
319 if test "$APACHE_HTTPD" != "no" -a -n "$APACHE_MODULE_DIR" -a -n "$APACHE_SSL_MODULE_DIR"; then
320     AC_DEFINE(HAVE_APACHE, 1, [Whether or not apache can be used for tests])
321     have_apache=1
322     if test -z "$APACHE_PHP_MODULE_DIR"; then
323         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_php5"
324     fi
325 else
326     have_apache=0
327     if test "$APACHE_HTTPD" = "no" -o -z "$APACHE_MODULE_DIR"; then
328         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES apache"
329     else
330         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_ssl"
331     fi
332 fi
333 AM_CONDITIONAL(HAVE_APACHE, test $have_apache = 1)
334
335 if test "$have_apache" = 1; then
336     AC_CHECK_PROGS(PHP, php php5)
337
338     AC_MSG_CHECKING([for Apache PHP module])
339     if test -f $APACHE_PHP_MODULE_DIR/$APACHE_PHP_MODULE; then
340         have_php=yes
341         IF_HAVE_PHP=""
342     else
343         have_php=no
344         IF_HAVE_PHP="#"
345         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php5"
346     fi
347     AC_MSG_RESULT($have_php)
348
349     if test "$have_php" = yes; then
350         AC_MSG_CHECKING([for xmlrpc-epi-php])
351         if $PHP --rf xmlrpc_server_create | grep -q "does not exist"; then
352             have_xmlrpc_epi_php=no
353             MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php-xmlrpc"
354         else
355             have_xmlrpc_epi_php=yes
356         fi
357         AC_MSG_RESULT($have_xmlrpc_epi_php)
358     fi
359 fi
360
361 AC_SUBST(IF_HAVE_PHP)
362 AM_CONDITIONAL(HAVE_XMLRPC_EPI_PHP, test "$have_xmlrpc_epi_php" = yes)
363
364 AC_PATH_PROG(CURL, curl, no)
365 if test "$CURL" != no; then
366     AC_DEFINE(HAVE_CURL, 1, [Whether or not curl can be used for tests])
367 else
368     MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES curl"
369 fi
370 AM_CONDITIONAL(HAVE_CURL, test "$CURL" != no)
371
372 if test -n "$MISSING_REGRESSION_TEST_PACKAGES"; then
373     AC_MSG_NOTICE([Some regression tests will not be run due to missing packages:$MISSING_REGRESSION_TEST_PACKAGES])
374 fi
375 AC_SUBST(MISSING_REGRESSION_TEST_PACKAGES)
376 AM_CONDITIONAL(MISSING_REGRESSION_TEST_PACKAGES, test -n "$MISSING_REGRESSION_TEST_PACKAGES")
377
378 dnl *************************
379 dnl *** Output Everything ***
380 dnl *************************
381
382 AC_OUTPUT([
383         libsoup-2.4.pc
384         libsoup-gnome-2.4.pc
385         Makefile
386         libsoup-zip
387         libsoup/Makefile
388         tests/Makefile
389         tests/httpd.conf
390         docs/Makefile
391         docs/reference/Makefile
392         ])