certtool: allow specifying a purpose and a hostname for chain verification
[gnutls:gnutls.git] / m4 / hooks.m4
1 # Copyright (C) 2000-2012 Free Software Foundation, Inc.
2 #
3 # Author: Nikos Mavrogiannopoulos, Simon Josefsson
4 #
5 # This file is part of GnuTLS.
6 #
7 # The GnuTLS is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public License
9 # as published by the Free Software Foundation; either version 2.1 of
10 # the License, or (at your option) any later version.
11 #
12 # The GnuTLS is distributed in the hope that it will be
13 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # Lesser General Public License for more details.
16 #
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with GnuTLS; if not, write to the Free
19 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 # MA 02110-1301, USA
21
22 AC_DEFUN([LIBGNUTLS_EXTRA_HOOKS],
23 [
24   AC_MSG_CHECKING([whether to build OpenSSL compatibility layer])
25   AC_ARG_ENABLE(openssl-compatibility,
26     AS_HELP_STRING([--enable-openssl-compatibility],
27                    [enable the OpenSSL compatibility library]),
28     enable_openssl=$enableval, enable_openssl=no)
29   AC_MSG_RESULT($enable_openssl)
30   AM_CONDITIONAL(ENABLE_OPENSSL, test "$enable_openssl" = "yes")
31
32   # We link to ../lib's gnulib, which needs -lws2_32 via LIBSOCKET in Makefile.am.
33   gl_SOCKETS
34 ])
35
36 AC_DEFUN([LIBGNUTLS_HOOKS],
37 [
38   # Library code modified:                              REVISION++
39   # Interfaces changed/added/removed:   CURRENT++       REVISION=0
40   # Interfaces added:                             AGE++
41   # Interfaces removed:                           AGE=0 (+bump all symbol versions in .map)
42   AC_SUBST(LT_CURRENT, 30)
43   AC_SUBST(LT_REVISION, 0)
44   AC_SUBST(LT_AGE, 0)
45
46   AC_SUBST(LT_SSL_CURRENT, 27)
47   AC_SUBST(LT_SSL_REVISION, 2)
48   AC_SUBST(LT_SSL_AGE, 0)
49
50   AC_SUBST(LT_DANE_CURRENT, 4)
51   AC_SUBST(LT_DANE_REVISION, 1)
52   AC_SUBST(LT_DANE_AGE, 4)
53
54   AC_SUBST(LT_XSSL_CURRENT, 0)
55   AC_SUBST(LT_XSSL_REVISION, 0)
56   AC_SUBST(LT_XSSL_AGE, 0)
57
58   AC_SUBST(CXX_LT_CURRENT, 29)
59   AC_SUBST(CXX_LT_REVISION, 0)
60   AC_SUBST(CXX_LT_AGE, 1)
61
62   AC_SUBST(CRYWRAP_PATCHLEVEL, 3)
63
64   # Used when creating the Windows libgnutls-XX.def files.
65   DLL_VERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
66   AC_SUBST(DLL_VERSION)
67
68   PKG_CHECK_MODULES(NETTLE, [nettle >= 3.0], [cryptolib="nettle"], [
69 AC_MSG_ERROR([[
70   *** 
71   *** Libnettle 3.0 was not found. 
72 ]])
73   ])
74   PKG_CHECK_MODULES(HOGWEED, [hogweed >= 3.0], [], [
75 AC_MSG_ERROR([[
76   *** 
77   *** Libhogweed (nettle's companion library) was not found. Note that you must compile nettle with gmp support.
78 ]])
79   ])
80   AM_CONDITIONAL(ENABLE_NETTLE, test "$cryptolib" = "nettle")
81   AC_DEFINE([HAVE_LIBNETTLE], 1, [nettle is enabled])
82
83   GNUTLS_REQUIRES_PRIVATE="Requires.private: nettle, hogweed"
84
85   AC_ARG_WITH(nettle-mini,
86     AS_HELP_STRING([--with-nettle-mini], [Link against a mini-nettle (that includes mini-gmp)]),
87       mini_nettle=$withval,
88       mini_nettle=no)
89
90   AC_ARG_VAR(GMP_CFLAGS, [C compiler flags for gmp])
91   AC_ARG_VAR(GMP_LIBS, [linker flags for gmp])
92   if test "$mini_nettle" != no;then
93     GMP_CLFLAGS=""
94     GMP_LIBS=""
95   else
96     if test x$GMP_LIBS = x; then
97         AC_CHECK_LIB(gmp, __gmpz_cmp, [GMP_LIBS="-lgmp"], [AC_MSG_ERROR([[
98 ***
99 *** gmp was not found.
100 ]])])
101     fi
102   fi
103   AC_SUBST(GMP_CFLAGS)
104   AC_SUBST(GMP_LIBS)
105
106   AC_ARG_WITH(included-libtasn1,
107     AS_HELP_STRING([--with-included-libtasn1], [use the included libtasn1]),
108       included_libtasn1=$withval,
109       included_libtasn1=no)
110   if test "$included_libtasn1" = "no"; then
111     PKG_CHECK_MODULES(LIBTASN1, [libtasn1 >= 3.9], [], [included_libtasn1=yes])
112     if test "$included_libtasn1" = yes; then
113       AC_MSG_WARN([[
114   *** 
115   *** Libtasn1 was not found. Will use the included one.
116   ]])
117     fi
118   fi
119   AC_MSG_CHECKING([whether to use the included minitasn1])
120   AC_MSG_RESULT($included_libtasn1)
121   AM_CONDITIONAL(ENABLE_MINITASN1, test "$included_libtasn1" = "yes")
122
123   if test "$included_libtasn1" = "no"; then
124     GNUTLS_REQUIRES_PRIVATE="${GNUTLS_REQUIRES_PRIVATE}, libtasn1"
125   fi
126
127   AC_MSG_CHECKING([whether C99 macros are supported])
128   AC_TRY_COMPILE(,
129   [
130     #define test_mac(...) 
131     int z,y,x;
132     test_mac(x,y,z);
133     return 0;
134   ], [
135     AC_DEFINE([C99_MACROS], 1, [C99 macros are supported])
136     AC_MSG_RESULT(yes)
137   ], [
138     AC_MSG_RESULT(no)
139     AC_MSG_WARN([C99 macros not supported. This may affect compiling.])
140   ])
141
142   ac_enable_srtp=yes
143   AC_MSG_CHECKING([whether to disable DTLS-SRTP extension])
144   AC_ARG_ENABLE(dtls-srtp-support,
145     AS_HELP_STRING([--disable-dtls-srtp-support],
146                    [disable support for the DTLS-SRTP extension]),
147     ac_enable_srtp=$enableval)
148   if test x$ac_enable_srtp != xno; then
149    AC_MSG_RESULT(no)
150    AC_DEFINE([ENABLE_DTLS_SRTP], 1, [enable DTLS-SRTP support])
151   else
152    ac_full=0
153    AC_MSG_RESULT(yes)
154   fi
155   AM_CONDITIONAL(ENABLE_DTLS_SRTP, test "$ac_enable_srtp" != "no")
156
157   AC_MSG_CHECKING([whether to disable ALPN extension])
158   AC_ARG_ENABLE(alpn-support,
159     AS_HELP_STRING([--disable-alpn-support],
160                    [disable support for the Application Layer Protocol Negotiation (ALPN) extension]),
161     ac_enable_alpn=$enableval,ac_enable_alpn=yes)
162   if test x$ac_enable_alpn != xno; then
163    AC_MSG_RESULT(no)
164    AC_DEFINE([ENABLE_ALPN], 1, [enable ALPN support])
165   else
166    ac_full=0
167    AC_MSG_RESULT(yes)
168   fi
169   AM_CONDITIONAL(ENABLE_ALPN, test "$ac_enable_alpn" != "no")
170
171   ac_enable_heartbeat=yes
172   AC_MSG_CHECKING([whether to disable TLS heartbeat support])
173   AC_ARG_ENABLE(heartbeat-support,
174     AS_HELP_STRING([--disable-heartbeat-support],
175                    [disable support for the heartbeat extension]),
176     ac_enable_heartbeat=$enableval)
177   if test x$ac_enable_heartbeat != xno; then
178    AC_MSG_RESULT(yes)
179    AC_DEFINE([ENABLE_HEARTBEAT], 1, [enable heartbeat support])
180   else
181    AC_MSG_RESULT(no)
182   fi
183   AM_CONDITIONAL(ENABLE_HEARTBEAT, test "$ac_enable_heartbeat" != "no")
184
185   ac_enable_srp=yes
186   AC_MSG_CHECKING([whether to disable SRP authentication support])
187   AC_ARG_ENABLE(srp-authentication,
188     AS_HELP_STRING([--disable-srp-authentication],
189                    [disable the SRP authentication support]),
190     ac_enable_srp=$enableval)
191   if test x$ac_enable_srp != xno; then
192    AC_MSG_RESULT(no)
193    AC_DEFINE([ENABLE_SRP], 1, [enable SRP authentication])
194   else
195    ac_full=0
196    AC_MSG_RESULT(yes)
197   fi
198   AM_CONDITIONAL(ENABLE_SRP, test "$ac_enable_srp" != "no")
199   
200   ac_enable_psk=yes
201   AC_MSG_CHECKING([whether to disable PSK authentication support])
202   AC_ARG_ENABLE(psk-authentication,
203     AS_HELP_STRING([--disable-psk-authentication],
204                    [disable the PSK authentication support]),
205     ac_enable_psk=$enableval)
206   if test x$ac_enable_psk != xno; then
207    AC_MSG_RESULT(no)
208    AC_DEFINE([ENABLE_PSK], 1, [enable PSK authentication])
209   else
210    ac_full=0
211    AC_MSG_RESULT(yes)
212   fi
213   AM_CONDITIONAL(ENABLE_PSK, test "$ac_enable_psk" != "no")
214   
215   ac_enable_anon=yes
216   AC_MSG_CHECKING([whether to disable anonymous authentication support])
217   AC_ARG_ENABLE(anon-authentication,
218     AS_HELP_STRING([--disable-anon-authentication],
219                    [disable the anonymous authentication support]),
220     ac_enable_anon=$enableval)
221   if test x$ac_enable_anon != xno; then
222    AC_MSG_RESULT(no)
223    AC_DEFINE([ENABLE_ANON], 1, [enable anonymous authentication])
224   else
225    ac_full=0
226    AC_MSG_RESULT(yes)
227   fi
228   AM_CONDITIONAL(ENABLE_ANON, test "$ac_enable_anon" != "no")
229
230   AC_MSG_CHECKING([whether to disable DHE support])
231   AC_ARG_ENABLE(dhe,
232     AS_HELP_STRING([--disable-dhe],
233                    [disable the DHE support]),
234     ac_enable_dhe=$enableval, ac_enable_dhe=yes)
235   if test x$ac_enable_dhe != xno; then
236    AC_MSG_RESULT(no)
237    AC_DEFINE([ENABLE_DHE], 1, [enable DHE])
238   else
239    ac_full=0
240    AC_MSG_RESULT(yes)
241   fi
242   AM_CONDITIONAL(ENABLE_DHE, test "$ac_enable_dhe" != "no")
243
244   AC_MSG_CHECKING([whether to disable ECDHE support])
245   AC_ARG_ENABLE(ecdhe,
246     AS_HELP_STRING([--disable-ecdhe],
247                    [disable the ECDHE support]),
248     ac_enable_ecdhe=$enableval, ac_enable_ecdhe=yes)
249   if test x$ac_enable_ecdhe != xno; then
250    AC_MSG_RESULT(no)
251    AC_DEFINE([ENABLE_ECDHE], 1, [enable DHE])
252   else
253    ac_full=0
254    AC_MSG_RESULT(yes)
255   fi
256   AM_CONDITIONAL(ENABLE_ECDHE, test "$ac_enable_ecdhe" != "no")
257
258   ac_enable_openpgp=yes
259   AC_MSG_CHECKING([whether to disable OpenPGP Certificate authentication support])
260   AC_ARG_ENABLE(openpgp-authentication,
261     AS_HELP_STRING([--disable-openpgp-authentication],
262                    [disable the OpenPGP authentication support]),
263     ac_enable_openpgp=$enableval)
264   if test x$ac_enable_openpgp = xno; then
265    AC_MSG_RESULT(yes)
266    ac_full=0
267   else
268    AC_DEFINE([ENABLE_OPENPGP], 1, [use openpgp authentication])
269    AC_MSG_RESULT(no)
270   fi
271   AM_CONDITIONAL(ENABLE_OPENPGP, test "$ac_enable_openpgp" = "yes")
272
273   # For cryptodev
274   AC_MSG_CHECKING([whether to add cryptodev support])
275   AC_ARG_ENABLE(cryptodev,
276     AS_HELP_STRING([--enable-cryptodev], [enable cryptodev support]),
277   enable_cryptodev=$enableval,enable_cryptodev=no)
278   AC_MSG_RESULT($enable_cryptodev)
279
280   if test "$enable_cryptodev" = "yes"; then
281     AC_DEFINE([ENABLE_CRYPTODEV], 1, [Enable cryptodev support])
282   fi
283
284   AC_MSG_CHECKING([whether to disable OCSP support])
285   AC_ARG_ENABLE(ocsp,
286     AS_HELP_STRING([--disable-ocsp],
287                    [disable OCSP support]),
288     ac_enable_ocsp=$enableval,ac_enable_ocsp=yes)
289   if test x$ac_enable_ocsp != xno; then
290    ac_enable_ocsp=yes
291    AC_MSG_RESULT(no)
292    AC_DEFINE([ENABLE_OCSP], 1, [enable OCSP support])
293   else
294    ac_full=0
295    AC_MSG_RESULT(yes)
296   fi
297   AM_CONDITIONAL(ENABLE_OCSP, test "$ac_enable_ocsp" != "no")
298
299
300   AC_MSG_CHECKING([whether to disable session tickets support])
301   AC_ARG_ENABLE(session-tickets,
302     AS_HELP_STRING([--disable-session-tickets],
303                    [disable session tickets support]),
304     ac_enable_session_tickets=$enableval,ac_enable_session_tickets=yes)
305   if test x$ac_enable_session_tickets != xno; then
306    ac_enable_session_tickets=yes
307    AC_MSG_RESULT(no)
308    AC_DEFINE([ENABLE_SESSION_TICKETS], 1, [enable session tickets support])
309   else
310    ac_full=0
311    AC_MSG_RESULT(yes)
312   fi
313   AM_CONDITIONAL(ENABLE_SESSION_TICKETS, test "$ac_enable_session_tickets" != "no")
314
315   # For storing integers in pointers without warnings
316   # http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html#desc
317   AC_CHECK_SIZEOF(void *)
318   AC_CHECK_SIZEOF(long long)
319   AC_CHECK_SIZEOF(long)
320   AC_CHECK_SIZEOF(int)
321   if test x$ac_cv_sizeof_void_p = x$ac_cv_sizeof_long;then
322       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long)],
323                 [Additional cast to bring void* to a type castable to int.])
324   elif test x$ac_cv_sizeof_void_p = x$ac_cv_sizeof_long_long;then
325       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long long)],
326                 [Additional cast to bring void* to a type castable to int.])
327    else
328       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [])
329    fi
330
331 dnl this is called from somewhere else
332 dnl #AM_ICONV
333 dnl m4_ifdef([gl_ICONV_MODULE_INDICATOR],
334 dnl  [gl_ICONV_MODULE_INDICATOR([iconv])])
335 ])