gnutls: don't crash if G_TLS_GNUTLS_PRIORITY is invalid
[platform/upstream/glib-networking.git] / configure.ac
1 AC_PREREQ(2.65)
2 AC_CONFIG_MACRO_DIR([m4])
3
4 AC_INIT([glib-networking],[2.37.2],[http://bugzilla.gnome.org/enter_bug.cgi?product=glib&component=network])
5
6 AC_CONFIG_SRCDIR([proxy/libproxy/glibproxyresolver.h])
7 AC_CONFIG_HEADERS([config.h])
8
9 dnl Other initialization
10 AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wno-portability])
11 AM_MAINTAINER_MODE([enable])
12 AM_SILENT_RULES([yes])
13 LT_INIT
14
15 dnl Checks for programs.
16 AC_PROG_CC
17 AM_PROG_CC_C_O
18 AC_PROG_CPP
19
20 dnl Checks for libraries.
21
22 dnl ****************************
23 dnl *** Checks for intltool  ***
24 dnl ****************************
25
26 IT_PROG_INTLTOOL([0.35.0])
27 GETTEXT_PACKAGE=glib-networking
28
29 AC_SUBST([GETTEXT_PACKAGE])
30 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["$GETTEXT_PACKAGE"],[The gettext domain name])
31 AM_GLIB_GNU_GETTEXT
32
33 dnl *****************************
34 dnl *** Check GLib GIO        ***
35 dnl *****************************
36 AM_PATH_GLIB_2_0(2.35.8,,AC_MSG_ERROR(GLIB not found),gio)
37 GLIB_CFLAGS="$GLIB_CFLAGS -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36"
38
39 GIO_MODULE_DIR=$($PKG_CONFIG --variable giomoduledir gio-2.0)
40 AS_IF([test "x$GIO_MODULE_DIR" = "x"],
41       [AC_MSG_FAILURE(GIO_MODULE_DIR is missing from gio-2.0.pc)])
42 AC_SUBST(GIO_MODULE_DIR)
43
44 AC_PATH_PROG(GIO_QUERYMODULES, gio-querymodules)
45 AC_SUBST(GIO_QUERYMODULES)
46
47 dnl *****************************
48 dnl *** Checks for LibProxy   ***
49 dnl *****************************
50
51 AC_ARG_WITH(libproxy,
52     [AC_HELP_STRING([--with-libproxy],
53                     [support for libproxy @<:@default=check@:>@])],
54     [],
55     [with_libproxy=check])
56 AS_IF([test "x$with_libproxy" != "xno"],
57     [PKG_CHECK_MODULES(LIBPROXY, [libproxy-1.0 >= 0.3.1],
58         [with_libproxy=yes; proxy_support=libproxy],
59         [AS_IF([test "x$with_libproxy" = "xyes"],
60                [AC_MSG_FAILURE("$LIBPROXY_PKG_ERRORS")])])])
61 AM_CONDITIONAL(HAVE_LIBPROXY, [test "x$with_libproxy" = "xyes"])
62 AC_SUBST(LIBPROXY_CFLAGS)
63 AC_SUBST(LIBPROXY_LIBS)
64
65 dnl **************************************
66 dnl *** Checks for GNOME proxy backend ***
67 dnl **************************************
68 AC_ARG_WITH(gnome-proxy,
69     [AC_HELP_STRING([--with-gnome-proxy],
70                     [support for GNOME proxy configuration @<:@default=check@:>@])],
71     [],
72     [with_gnome_proxy=check])
73 AS_IF([test "x$with_gnome_proxy" != "xno"],
74     [PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, [gsettings-desktop-schemas],
75         [with_gnome_proxy=yes; proxy_support="gnome $proxy_support"],
76         [AS_IF([test "x$with_gnome_proxy" = "xyes"],
77                [AC_MSG_FAILURE("$GSETTINGS_DESKTOP_SCHEMAS_PKG_ERRORS")])])])
78 AM_CONDITIONAL(HAVE_GNOME_PROXY, [test "x$with_gnome_proxy" = "xyes"])
79 AC_SUBST(GSETTINGS_DESKTOP_SCHEMAS_CFLAGS)
80
81 dnl *****************************
82 dnl *** Checks for GNUTLS     ***
83 dnl *****************************
84
85 GNUTLS_MIN_REQUIRED=2.11.0
86 GNUTLS_MIN_PKCS11=2.12.8
87
88 AC_ARG_WITH(gnutls,
89     [AC_HELP_STRING([--with-gnutls],
90                     [support for GNUTLS @<:@default=yes@:>@])],
91     [],
92     [with_gnutls=yes])
93 if test "x$with_gnutls" != "xno"; then
94         PKG_CHECK_MODULES(GNUTLS,
95                           [gnutls >= $GNUTLS_MIN_REQUIRED],
96                           [with_gnutls=yes
97                            tls_support="${tls_support}gnutls "],
98                           [AS_IF([test "x$with_gnutls" = "xyes"],
99                                  [AC_MSG_FAILURE("$GNUTLS_PKG_ERRORS")])])
100 fi
101 AM_CONDITIONAL(HAVE_GNUTLS, [test "x$with_gnutls" = "xyes"])
102 AC_SUBST(GNUTLS_CFLAGS)
103 AC_SUBST(GNUTLS_LIBS)
104
105 if test "x$with_gnutls" = "xyes"; then
106     AC_MSG_CHECKING([location of system Certificate Authority list])
107     AC_ARG_WITH(ca-certificates,
108                 [AC_HELP_STRING([--with-ca-certificates=@<:@path@:>@],
109                                 [path to system Certificate Authority list])])
110     if test "$with_ca_certificates" = "no"; then
111         AC_MSG_RESULT([disabled])
112     else
113         if test -z "$with_ca_certificates"; then
114             for f in /etc/pki/tls/certs/ca-bundle.crt \
115                      /etc/ssl/certs/ca-certificates.crt \
116                      /etc/ssl/ca-bundle.pem; do
117                 if test -f "$f"; then
118                     with_ca_certificates="$f"
119                 fi
120             done
121             if test -z "$with_ca_certificates"; then
122                 AC_MSG_ERROR([could not find. Use --with-ca-certificates=path to set, or --without-ca-certificates to disable])
123             fi
124         fi
125
126         AC_MSG_RESULT($with_ca_certificates)
127         AC_DEFINE_UNQUOTED(GTLS_SYSTEM_CA_FILE, ["$with_ca_certificates"], [The system TLS CA list])
128     fi
129 fi
130
131 dnl *****************************
132 dnl *** Checks for pkcs11    ***
133 dnl *****************************
134
135 P11_KIT_REQUIRED=0.8
136
137 AC_ARG_WITH(pkcs11,
138         [AC_HELP_STRING([--with-pkcs11],
139                         [support for pkcs11 @<:@default=check@:>@])],
140                         [],
141                         [with_pkcs11=check])
142 if test "x$with_pkcs11" != "xno"; then
143         PKG_CHECK_MODULES(PKCS11,
144                           [p11-kit-1 >= $P11_KIT_REQUIRED gnutls >= $GNUTLS_MIN_PKCS11],
145                           [with_pkcs11=yes
146                            pkcs11_support=p11-kit
147                            tls_support="${tls_support}gnutls-pkcs11 "
148                            AC_DEFINE_UNQUOTED([HAVE_PKCS11], [1], [Building with PKCS#11 support])],
149                           [AS_IF([test "x$with_pkcs11" = "xyes"],
150                                  [AC_MSG_FAILURE("$PKCS11_PKG_ERRORS")])
151                            pkcs11_support=no])
152 else
153         pkcs11_support=no
154 fi
155 AM_CONDITIONAL(HAVE_PKCS11, [test "x$with_pkcs11" = "xyes"])
156 AC_SUBST(PKCS11_CFLAGS)
157 AC_SUBST(PKCS11_LIBS)
158
159 dnl ************************************
160 dnl *** Enable lcov coverage reports ***
161 dnl ************************************
162
163 AC_ARG_ENABLE(gcov,
164   AS_HELP_STRING([--enable-gcov],
165                  [Enable gcov]),
166   [use_gcov=$enableval], [use_gcov=no])
167
168 if test "x$use_gcov" = "xyes"; then
169   dnl we need gcc:
170   if test "$GCC" != "yes"; then
171     AC_MSG_ERROR([GCC is required for --enable-gcov])
172   fi
173
174   ltp_version_list="1.6 1.7 1.8 1.9"
175   AC_CHECK_PROG(LTP, lcov, lcov)
176   AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
177
178   if test "$LTP"; then
179     AC_CACHE_CHECK([for ltp version], glib_cv_ltp_version, [
180       glib_cv_ltp_version=invalid
181       ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
182       for ltp_check_version in $ltp_version_list; do
183         if test "$ltp_version" = "$ltp_check_version"; then
184           glib_cv_ltp_version="$ltp_check_version (ok)"
185         fi
186       done
187     ])
188   else
189     ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
190     AC_MSG_ERROR([$ltp_msg])
191   fi
192
193   case $glib_cv_ltp_version in
194     ""|invalid[)]
195       ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
196       AC_MSG_ERROR([$ltp_msg])
197       LTP="exit 0;"
198       ;;
199   esac
200
201   if test -z "$LTP_GENHTML"; then
202     AC_MSG_ERROR([Could not find genhtml from the LTP package])
203   fi
204
205   AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
206
207   dnl Remove all optimization flags from CFLAGS
208   changequote({,})
209   CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
210   changequote([,])
211
212   dnl Add the special gcc flags
213   CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
214   LDFLAGS="$LDFLAGS -lgcov"
215 fi
216
217 dnl ****************************************************
218 dnl *** Warnings to show if using GCC                ***
219 dnl *** (do this last so -Werror won't mess up tests ***
220 dnl ****************************************************
221
222 AC_ARG_ENABLE(more-warnings,
223               AS_HELP_STRING([--disable-more-warnings], [Inhibit compiler warnings]),
224               set_more_warnings=no)
225
226 if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
227         CFLAGS="$CFLAGS \
228                 -Wall -Wstrict-prototypes -Werror=missing-prototypes \
229                 -Werror=implicit-function-declaration \
230                 -Werror=pointer-arith -Werror=init-self -Werror=format=2 \
231                 -Werror=missing-include-dirs \
232                 -Werror=declaration-after-statement"
233 fi
234
235 dnl *****************************
236 dnl *** done                  ***
237 dnl *****************************
238 AC_CONFIG_FILES([Makefile
239                  po/Makefile.in po/Makefile
240                  proxy/libproxy/Makefile
241                  proxy/gnome/Makefile
242                  proxy/tests/Makefile
243                  tls/gnutls/Makefile
244                  tls/pkcs11/Makefile
245                  tls/tests/Makefile
246                 ])
247 AC_OUTPUT
248
249 echo ""
250 echo     "  Proxy support:     ${proxy_support:-no}"
251 echo     "  TLS support:       ${tls_support:-no}"
252 if test "$tls_support" != "no"; then
253     echo "  PKCS#11 Support:   $pkcs11_support"
254     echo "  TLS CA file:       ${with_ca_certificates:-(none)}"
255     if test -n "$with_ca_certificates"; then
256         if ! test -f "$with_ca_certificates"; then
257             AC_MSG_WARN([Specified certificate authority file '$with_ca_certificates' does not exist])
258         fi
259     fi
260 fi