Add API to get version information
[platform/upstream/libsoup.git] / configure.ac
1 dnl *******************************************
2 dnl *** Initialize automake and set version ***
3 dnl *******************************************
4
5 m4_define([soup_major_version], [2])
6 m4_define([soup_minor_version], [41])
7 m4_define([soup_micro_version], [0])
8
9 AC_PREREQ(2.63)
10 AC_INIT([libsoup],[soup_major_version.soup_minor_version.soup_micro_version],[http://bugzilla.gnome.org/enter_bug.cgi?product=libsoup])
11 AC_CONFIG_SRCDIR([libsoup-2.4.pc.in])
12 AC_CONFIG_MACRO_DIR([m4])
13
14 AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz -Wno-portability])
15 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
16
17 AC_PROG_MAKE_SET
18
19 SOUP_MAJOR_VERSION=soup_major_version
20 SOUP_MINOR_VERSION=soup_minor_version
21 SOUP_MICRO_VERSION=soup_micro_version
22 AC_SUBST(SOUP_MAJOR_VERSION)
23 AC_SUBST(SOUP_MINOR_VERSION)
24 AC_SUBST(SOUP_MICRO_VERSION)
25
26 SOUP_API_VERSION=2.4
27 AC_SUBST(SOUP_API_VERSION)
28
29 # Increment on interface addition. Reset on removal.
30 SOUP_AGE=5
31
32 # Increment on interface add, remove, or change.
33 SOUP_CURRENT=6
34
35 # Increment on source change. Reset when CURRENT changes.
36 SOUP_REVISION=0
37
38 AC_SUBST(SOUP_CURRENT)
39 AC_SUBST(SOUP_REVISION)
40 AC_SUBST(SOUP_AGE)
41
42 dnl ***************************
43 dnl *** Set debugging flags ***
44 dnl ***************************
45
46 debug_default=minimum
47
48 # Declare --enable-* args and collect ac_help strings
49 AC_ARG_ENABLE(debug, 
50               AS_HELP_STRING([--enable-debug=[no/minimum/yes]],
51                              [turn on debugging (default=$debug_default)]),,
52               enable_debug=$debug_default)
53
54 # Set the debug flags
55 if test "x$enable_debug" = "xyes"; then
56         test "$cflags_set" = set || CFLAGS="$CFLAGS -g"
57         SOUP_DEBUG_FLAGS="-DG_ENABLE_DEBUG"
58 else
59         if test "x$enable_debug" = "xno"; then
60                 SOUP_DEBUG_FLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS"
61         fi
62 fi
63
64 AC_SUBST(SOUP_DEBUG_FLAGS)
65
66 # Set the maintainer flags
67 #if test -d .git; then
68 #       SOUP_MAINTAINER_FLAGS="-DG_DISABLE_DEPRECATED"
69 #fi
70 AC_SUBST(SOUP_MAINTAINER_FLAGS)
71
72 dnl ***************************
73 dnl *** Checks for programs ***
74 dnl ***************************
75
76 AC_PROG_CC
77 AC_PROG_INSTALL
78
79 # Initialize libtool
80 LT_INIT([win32-dll])
81
82 dnl ***********************
83 dnl *** Checks for glib ***
84 dnl ***********************
85
86 GLIB_REQUIRED=2.33.1
87 AM_PATH_GLIB_2_0($GLIB_REQUIRED,,,gobject gio)
88 if test "$GLIB_LIBS" = ""; then
89    AC_MSG_ERROR(GLIB $GLIB_REQUIRED or later is required to build libsoup)
90 fi
91 GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_34"
92
93 GLIB_MAKEFILE='$(top_srcdir)/Makefile.glib'
94 AC_SUBST(GLIB_MAKEFILE)
95
96 PKG_CHECK_MODULES(XML, libxml-2.0)
97 AC_SUBST(XML_CFLAGS)
98 AC_SUBST(XML_LIBS)
99
100 dnl ***********************
101 dnl *** Check for Win32 ***
102 dnl ***********************
103
104 AC_MSG_CHECKING([for Win32])
105 case "$host" in
106   *-*-mingw*)
107     os_win32=yes
108     CFLAGS="$CFLAGS -D_REENTRANT"
109     ;;
110   *)
111     os_win32=no
112     ;;
113 esac
114 AC_MSG_RESULT([$os_win32])
115 AM_CONDITIONAL(OS_WIN32, [test $os_win32 = yes])
116
117 dnl ************************
118 dnl *** gettext/intltool ***
119 dnl ************************
120 IT_PROG_INTLTOOL([0.35.0])
121 GETTEXT_PACKAGE=libsoup
122 AC_SUBST([GETTEXT_PACKAGE])
123 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The gettext domain name])
124 AM_GLIB_GNU_GETTEXT
125
126 dnl *******************
127 dnl *** Misc checks ***
128 dnl *******************
129 AC_CHECK_FUNCS(gmtime_r)
130 AC_CHECK_FUNCS(mmap)
131 AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket))
132
133 dnl *********************
134 dnl *** GNOME support ***
135 dnl *********************
136 AC_MSG_CHECKING(whether to build libsoup-gnome)
137 AC_ARG_WITH(gnome,
138             AS_HELP_STRING([--without-gnome], [Do not build libsoup-gnome]),
139             :, [if test $os_win32 = yes; then with_gnome=no; else with_gnome=yes; fi])
140 AC_MSG_RESULT($with_gnome)
141
142 if test $with_gnome != no -a $os_win32 != yes; then
143         PKG_CHECK_MODULES(GNOME_KEYRING, gnome-keyring-1, :,
144                           AC_MSG_ERROR(
145 [Could not find gnome-keyring devel files.
146 Configure with --without-gnome if you wish to build only libsoup
147 without GNOME-specific features.]))
148 fi
149 AC_SUBST(GNOME_KEYRING_CFLAGS)
150 AC_SUBST(GNOME_KEYRING_LIBS)
151
152 AM_CONDITIONAL(BUILD_LIBSOUP_GNOME, test $with_gnome != no)
153
154 if test $with_gnome != no; then
155         AC_DEFINE(HAVE_GNOME, 1, [Defined if GNOME support is enabled])
156
157         PKG_CHECK_MODULES(SQLITE, sqlite3, :, [AC_MSG_ERROR(dnl
158 [Could not find sqlite3 devel files:
159
160 $SQLITE_PKG_ERRORS
161
162 Pass "--without-gnome" to configure if you want to build libsoup
163 without GNOME support.])])
164 fi
165 AC_SUBST(HAVE_GNOME)
166 AC_SUBST(SQLITE_CFLAGS)
167 AC_SUBST(SQLITE_LIBS)
168
169
170 dnl ***************
171 dnl *** gtk-doc ***
172 dnl ***************
173 GTK_DOC_CHECK([1.10])
174
175 dnl *****************************
176 dnl *** gobject-introspection ***
177 dnl *****************************
178 GOBJECT_INTROSPECTION_CHECK([0.9.5])
179
180 AC_MSG_CHECKING([for glib-networking (glib TLS implementation)])
181 save_CFLAGS="$CFLAGS"
182 save_LIBS="$LIBS"
183 CFLAGS="$CFLAGS $GLIB_CFLAGS"
184 LIBS="$LIBS $GLIB_LIBS"
185 AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <gio/gio.h>],
186                                [g_type_init (); return !g_tls_backend_supports_tls (g_tls_backend_get_default ());])],
187               [have_glib_networking=yes],
188               [have_glib_networking=no],
189               [have_glib_networking="unknown (cross-compiling)"])
190 CFLAGS="$save_CFLAGS"
191 LIBS="$save_LIBS"
192 AC_MSG_RESULT($have_glib_networking)
193
194 AC_ARG_ENABLE(tls-check,
195               AS_HELP_STRING([--disable-tls-check], [Don't error out if glib-networking is unavailable]))
196 if test "$enable_tls_check" != "no" -a "$have_glib_networking" = "no"; then
197         AC_MSG_ERROR([libsoup requires glib-networking for TLS support.
198
199 If you are building a package, you can pass --disable-tls-check to
200 allow building libsoup anyway (since glib-networking is not actually
201 required at compile time), but you should be sure to add a runtime
202 dependency on it.])
203 fi
204
205 dnl ******************************
206 dnl *** Stuff for regression tests
207 dnl ******************************
208 AC_MSG_NOTICE([checking for programs needed for regression tests])
209 MISSING_REGRESSION_TEST_PACKAGES=""
210
211 if test "$have_glib_networking" = "no"; then
212         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES glib-networking"
213 fi
214
215 AC_ARG_WITH(apache-httpd,
216             AS_HELP_STRING([--with-apache-httpd], [Path to apache httpd (for tests)]),
217             APACHE_HTTPD="$withval",
218             [AC_PATH_PROGS(APACHE_HTTPD, httpd2 httpd apache2 apache, no, ${PATH}:/usr/sbin)])
219 if test "$APACHE_HTTPD" != "no"; then
220     AC_MSG_CHECKING([Apache version])
221     apache_version=`$APACHE_HTTPD -v 2>/dev/null | sed -ne 's/Server version: Apache\///p'`
222     case $apache_version in
223     2.2.*)
224         AC_MSG_RESULT([$apache_version (ok)])
225         ;;
226     *)
227         AC_MSG_RESULT([$apache_version (ignoring)])
228         APACHE_HTTPD="no"
229         ;;
230     esac
231 fi
232 AC_SUBST(APACHE_HTTPD)
233 AC_DEFINE_UNQUOTED(APACHE_HTTPD, "$APACHE_HTTPD", [Apache httpd])
234
235 if test "$APACHE_HTTPD" != "no"; then
236     AC_MSG_CHECKING([for Apache module directory])
237     AC_ARG_WITH(apache-module-dir,
238                 AS_HELP_STRING([--with-apache-module-dir], [Apache modules dirs (for tests)]),
239                 apache_module_dirs="$withval",
240                 [apache_prefix=`dirname \`dirname $APACHE_HTTPD\``
241                 mpm=`$APACHE_HTTPD -V | sed -ne 's/^Server MPM: */-/p' | tr 'A-Z' 'a-z'`
242                 # This only works with bash, but should fail harmlessly in sh
243                 apache_module_dirs=`echo $apache_prefix/lib{64,}/{apache,apache2,http,http2,httpd}{$mpm,}{/modules,}`])
244     for dir in $apache_module_dirs; do
245         if test -f $dir/mod_auth_digest.so; then
246             APACHE_MODULE_DIR="$dir"
247         fi
248         if test -f $dir/mod_ssl.so; then
249             APACHE_SSL_MODULE_DIR="$dir"
250             IF_HAVE_APACHE_SSL=""
251         fi
252         if test -f $dir/mod_php5.so; then
253             APACHE_PHP_MODULE_DIR="$dir"
254             APACHE_PHP_MODULE=mod_php5.so
255         fi
256         if test -f $dir/libphp5.so; then
257             APACHE_PHP_MODULE_DIR="$dir"
258             APACHE_PHP_MODULE=libphp5.so
259         fi
260     done
261     AC_MSG_RESULT($APACHE_MODULE_DIR)
262     AC_SUBST(APACHE_MODULE_DIR)
263     AC_SUBST(APACHE_SSL_MODULE_DIR)
264     AC_SUBST(APACHE_PHP_MODULE_DIR)
265     AC_SUBST(APACHE_PHP_MODULE)
266 fi
267
268 if test "$APACHE_HTTPD" != "no" -a -n "$APACHE_MODULE_DIR" -a -n "$APACHE_SSL_MODULE_DIR"; then
269     AC_DEFINE(HAVE_APACHE, 1, [Whether or not apache can be used for tests])
270     have_apache=1
271     if test -z "$APACHE_PHP_MODULE_DIR"; then
272         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_php5"
273     fi
274 else
275     have_apache=0
276     if test "$APACHE_HTTPD" = "no" -o -z "$APACHE_MODULE_DIR"; then
277         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES apache"
278     else
279         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES mod_ssl"
280     fi
281 fi
282 AM_CONDITIONAL(HAVE_APACHE, test $have_apache = 1)
283
284 if test "$have_apache" = 1; then
285     AC_CHECK_PROGS(PHP, php php5)
286
287     AC_MSG_CHECKING([for Apache PHP module])
288     if test -f $APACHE_PHP_MODULE_DIR/$APACHE_PHP_MODULE; then
289         have_php=yes
290         IF_HAVE_PHP=""
291     else
292         have_php=no
293         IF_HAVE_PHP="#"
294         MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php5"
295     fi
296     AC_MSG_RESULT($have_php)
297
298     if test "$have_php" = yes; then
299         AC_MSG_CHECKING([for xmlrpc-epi-php])
300         if $PHP --rf xmlrpc_server_create | grep -q "does not exist"; then
301             have_xmlrpc_epi_php=no
302             MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES php-xmlrpc"
303         else
304             have_xmlrpc_epi_php=yes
305         fi
306         AC_MSG_RESULT($have_xmlrpc_epi_php)
307     fi
308 fi
309
310 AC_SUBST(IF_HAVE_PHP)
311 AM_CONDITIONAL(HAVE_XMLRPC_EPI_PHP, test "$have_xmlrpc_epi_php" = yes)
312
313 AC_PATH_PROG(CURL, curl, no)
314 if test "$CURL" != no; then
315     AC_DEFINE(HAVE_CURL, 1, [Whether or not curl can be used for tests])
316 else
317     MISSING_REGRESSION_TEST_PACKAGES="$MISSING_REGRESSION_TEST_PACKAGES curl"
318 fi
319 AM_CONDITIONAL(HAVE_CURL, test "$CURL" != no)
320
321 GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
322 AC_SUBST(GLIB_COMPILE_RESOURCES)
323
324 AC_SUBST(MISSING_REGRESSION_TEST_PACKAGES)
325 AM_CONDITIONAL(MISSING_REGRESSION_TEST_PACKAGES, test -n "$MISSING_REGRESSION_TEST_PACKAGES")
326
327 dnl **********************************************************
328 dnl *** path of NTLM single-sign-on helper ntlm_auth
329 dnl **********************************************************
330 AC_ARG_WITH(ntlm-auth,
331             AC_HELP_STRING([--with-ntlm-auth=PATH],[Where to look for ntlm_auth, path points to ntlm_auth installation (default: /usr/bin/ntlm_auth)]),
332             ntlm_auth="$withval",
333             [if test $os_win32 = yes; then ntlm_auth="no"; else ntlm_auth="/usr/bin/ntlm_auth"; fi])
334 if test "$ntlm_auth" != "no"; then
335     AC_DEFINE(USE_NTLM_AUTH, 1, [Whether or not use Samba's 'winbind' daemon helper 'ntlm_auth' for NTLM single-sign-on])
336     if test "$ntlm_auth" = "yes"; then
337         dnl --with-ntlm-auth (without path) used, use default path
338         ntlm_auth="/usr/bin/ntlm_auth"
339     fi
340 fi
341 AC_SUBST(ntlm_auth)
342 AC_DEFINE_UNQUOTED(NTLM_AUTH, "$ntlm_auth", [Samba's 'winbind' daemon helper 'ntlm_auth' which can be used for NTLM single-sign-on])
343
344 dnl ****************************************************
345 dnl *** Warnings to show if using GCC                ***
346 dnl *** (do this last so -Werror won't mess up tests ***
347 dnl ****************************************************
348
349 AC_ARG_ENABLE(more-warnings,
350               AS_HELP_STRING([--disable-more-warnings], [Inhibit compiler warnings]),
351               set_more_warnings=no)
352
353 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
354         CFLAGS="$CFLAGS \
355                 -Wall -Wstrict-prototypes -Werror=missing-prototypes \
356                 -Werror=implicit-function-declaration \
357                 -Werror=pointer-arith -Werror=init-self -Werror=format=2 \
358                 -Werror=missing-include-dirs -Werror=aggregate-return \
359                 -Werror=declaration-after-statement"
360 fi
361
362 dnl *************************
363 dnl *** Output Everything ***
364 dnl *************************
365
366 AC_CONFIG_HEADERS([config.h])
367 AC_CONFIG_FILES([
368         libsoup-2.4.pc
369         libsoup-gnome-2.4.pc
370         Makefile
371         libsoup-zip
372         libsoup/Makefile
373         po/Makefile.in
374         po/Makefile
375         tests/Makefile
376         tests/httpd.conf
377         docs/Makefile
378         docs/reference/Makefile
379         libsoup/soup-version.h
380         ])
381 AC_OUTPUT
382
383 if test -n "$MISSING_REGRESSION_TEST_PACKAGES"; then
384     echo ""
385     echo Some regression tests will not be run due to missing packages:
386     echo $MISSING_REGRESSION_TEST_PACKAGES
387     echo ""
388 fi