Imported Upstream version 3.3.27
[platform/upstream/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([--disable-openssl-compatibility],
27                    [disable the OpenSSL compatibility support]),
28     enable_openssl=$enableval, enable_openssl=yes)
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, 71)
43   AC_SUBST(LT_REVISION, 1)
44   AC_SUBST(LT_AGE, 43)
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, 5)
51   AC_SUBST(LT_DANE_REVISION, 0)
52   AC_SUBST(LT_DANE_AGE, 5)
53
54   AC_SUBST(CXX_LT_CURRENT, 29)
55   AC_SUBST(CXX_LT_REVISION, 0)
56   AC_SUBST(CXX_LT_AGE, 1)
57
58   AC_SUBST(CRYWRAP_PATCHLEVEL, 3)
59
60   # Used when creating the Windows libgnutls-XX.def files.
61   DLL_VERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
62   AC_SUBST(DLL_VERSION)
63
64   PKG_CHECK_MODULES(NETTLE, [nettle >= 2.7], [cryptolib="nettle"], [
65 AC_MSG_ERROR([[
66   *** 
67   *** Libnettle 2.7.1 was not found.
68 ]])
69   ])
70   PKG_CHECK_MODULES(HOGWEED, [hogweed >= 2.7], [], [
71 AC_MSG_ERROR([[
72   *** 
73   *** Libhogweed (nettle's companion library) was not found. Note that you must compile nettle with gmp support.
74 ]])
75   ])
76   AM_CONDITIONAL(ENABLE_NETTLE, test "$cryptolib" = "nettle")
77   AC_DEFINE([HAVE_LIBNETTLE], 1, [nettle is enabled])
78   nettle_version=`$PKG_CONFIG --modversion nettle`
79
80   if $PKG_CONFIG --atleast-version=3.0 nettle; then
81         AC_DEFINE([USE_NETTLE3], 1, [nettle 3.0 or later])
82         use_nettle3=yes
83   else
84         use_nettle3=no
85   fi
86   AM_CONDITIONAL(USE_NETTLE3, test "$use_nettle3" = "yes")
87
88   GNUTLS_REQUIRES_PRIVATE="Requires.private: nettle, hogweed"
89
90   AC_ARG_WITH(nettle-mini,
91     AS_HELP_STRING([--with-nettle-mini], [Link against a mini-nettle (that includes mini-gmp)]),
92       mini_nettle=$withval,
93       mini_nettle=no)
94
95   AC_ARG_VAR(GMP_CFLAGS, [C compiler flags for gmp])
96   AC_ARG_VAR(GMP_LIBS, [linker flags for gmp])
97   if test "$mini_nettle" != no;then
98     GMP_CLFLAGS=""
99     GMP_LIBS=""
100   else
101     if test x$GMP_LIBS = x; then
102         AC_CHECK_LIB(gmp, __gmpz_cmp, [GMP_LIBS="-lgmp"], [AC_MSG_ERROR([[
103 ***
104 *** gmp was not found.
105 ]])])
106     fi
107   fi
108   AC_SUBST(GMP_CFLAGS)
109   AC_SUBST(GMP_LIBS)
110
111   AC_ARG_WITH(included-libtasn1,
112     AS_HELP_STRING([--with-included-libtasn1], [use the included libtasn1]),
113       included_libtasn1=$withval,
114       included_libtasn1=no)
115   if test "$included_libtasn1" = "no"; then
116     PKG_CHECK_MODULES(LIBTASN1, [libtasn1 >= 3.9], [], [included_libtasn1=yes])
117     if test "$included_libtasn1" = yes; then
118       AC_MSG_WARN([[
119   *** 
120   *** Libtasn1 was not found. Will use the included one.
121   ]])
122     fi
123   fi
124   AC_MSG_CHECKING([whether to use the included minitasn1])
125   AC_MSG_RESULT($included_libtasn1)
126   AM_CONDITIONAL(ENABLE_MINITASN1, test "$included_libtasn1" = "yes")
127
128   if test "$included_libtasn1" = "no"; then
129     GNUTLS_REQUIRES_PRIVATE="${GNUTLS_REQUIRES_PRIVATE}, libtasn1"
130     oldlibs="$LIBS"
131     LIBS="$LIBS $LIBTASN1_LIBS"
132     oldcflags="$CFLAGS"
133     CFLAGS="$CFLAGS $LIBTASN1_CFLAGS"
134     AC_CHECK_FUNC(asn1_decode_simple_ber,
135                 [AC_DEFINE(HAVE_ASN1_DECODE_SIMPLE_BER, 1, [Have this function])], [])
136     LIBS="$oldlibs"
137   else
138                 AC_DEFINE(HAVE_ASN1_DECODE_SIMPLE_BER, 1, [Have this function])
139   fi
140
141   AC_MSG_CHECKING([whether C99 macros are supported])
142   AC_TRY_COMPILE(,
143   [
144     #define test_mac(...) 
145     int z,y,x;
146     test_mac(x,y,z);
147     return 0;
148   ], [
149     AC_DEFINE([C99_MACROS], 1, [C99 macros are supported])
150     AC_MSG_RESULT(yes)
151   ], [
152     AC_MSG_RESULT(no)
153     AC_MSG_WARN([C99 macros not supported. This may affect compiling.])
154   ])
155
156   ac_enable_srtp=yes
157   AC_MSG_CHECKING([whether to disable DTLS-SRTP extension])
158   AC_ARG_ENABLE(dtls-srtp-support,
159     AS_HELP_STRING([--disable-dtls-srtp-support],
160                    [disable support for the DTLS-SRTP extension]),
161     ac_enable_srtp=$enableval)
162   if test x$ac_enable_srtp != xno; then
163    AC_MSG_RESULT(no)
164    AC_DEFINE([ENABLE_DTLS_SRTP], 1, [enable DTLS-SRTP support])
165   else
166    ac_full=0
167    AC_MSG_RESULT(yes)
168   fi
169   AM_CONDITIONAL(ENABLE_DTLS_SRTP, test "$ac_enable_srtp" != "no")
170
171   AC_MSG_CHECKING([whether to disable ALPN extension])
172   AC_ARG_ENABLE(alpn-support,
173     AS_HELP_STRING([--disable-alpn-support],
174                    [disable support for the Application Layer Protocol Negotiation (ALPN) extension]),
175     ac_enable_alpn=$enableval,ac_enable_alpn=yes)
176   if test x$ac_enable_alpn != xno; then
177    AC_MSG_RESULT(no)
178    AC_DEFINE([ENABLE_ALPN], 1, [enable ALPN support])
179   else
180    ac_full=0
181    AC_MSG_RESULT(yes)
182   fi
183   AM_CONDITIONAL(ENABLE_ALPN, test "$ac_enable_alpn" != "no")
184
185   AC_MSG_CHECKING([whether to disable RSA-EXPORT support])
186   AC_ARG_ENABLE(rsa-export,
187     AS_HELP_STRING([--disable-rsa-export],
188                    [disable the RSA-EXPORT support]),
189     ac_enable_rsa_export=$enableval, ac_enable_rsa_export=yes)
190   if test x$ac_enable_rsa_export != xno; then
191    AC_MSG_RESULT(no)
192    AC_DEFINE([ENABLE_RSA_EXPORT], 1, [enable RSA-EXPORT])
193   else
194    ac_full=0
195    AC_MSG_RESULT(yes)
196   fi
197   AM_CONDITIONAL(ENABLE_RSA_EXPORT, test "$ac_enable_rsa_export" != "no")
198
199   ac_enable_heartbeat=yes
200   AC_MSG_CHECKING([whether to disable TLS heartbeat support])
201   AC_ARG_ENABLE(heartbeat-support,
202     AS_HELP_STRING([--disable-heartbeat-support],
203                    [disable support for the heartbeat extension]),
204     ac_enable_heartbeat=$enableval)
205   if test x$ac_enable_heartbeat != xno; then
206    AC_MSG_RESULT(yes)
207    AC_DEFINE([ENABLE_HEARTBEAT], 1, [enable heartbeat support])
208   else
209    AC_MSG_RESULT(no)
210   fi
211   AM_CONDITIONAL(ENABLE_HEARTBEAT, test "$ac_enable_heartbeat" != "no")
212
213   ac_enable_srp=yes
214   AC_MSG_CHECKING([whether to disable SRP authentication support])
215   AC_ARG_ENABLE(srp-authentication,
216     AS_HELP_STRING([--disable-srp-authentication],
217                    [disable the SRP authentication support]),
218     ac_enable_srp=$enableval)
219   if test x$ac_enable_srp != xno; then
220    AC_MSG_RESULT(no)
221    AC_DEFINE([ENABLE_SRP], 1, [enable SRP authentication])
222   else
223    ac_full=0
224    AC_MSG_RESULT(yes)
225   fi
226   AM_CONDITIONAL(ENABLE_SRP, test "$ac_enable_srp" != "no")
227   
228   ac_enable_psk=yes
229   AC_MSG_CHECKING([whether to disable PSK authentication support])
230   AC_ARG_ENABLE(psk-authentication,
231     AS_HELP_STRING([--disable-psk-authentication],
232                    [disable the PSK authentication support]),
233     ac_enable_psk=$enableval)
234   if test x$ac_enable_psk != xno; then
235    AC_MSG_RESULT(no)
236    AC_DEFINE([ENABLE_PSK], 1, [enable PSK authentication])
237   else
238    ac_full=0
239    AC_MSG_RESULT(yes)
240   fi
241   AM_CONDITIONAL(ENABLE_PSK, test "$ac_enable_psk" != "no")
242   
243   ac_enable_anon=yes
244   AC_MSG_CHECKING([whether to disable anonymous authentication support])
245   AC_ARG_ENABLE(anon-authentication,
246     AS_HELP_STRING([--disable-anon-authentication],
247                    [disable the anonymous authentication support]),
248     ac_enable_anon=$enableval)
249   if test x$ac_enable_anon != xno; then
250    AC_MSG_RESULT(no)
251    AC_DEFINE([ENABLE_ANON], 1, [enable anonymous authentication])
252   else
253    ac_full=0
254    AC_MSG_RESULT(yes)
255   fi
256   AM_CONDITIONAL(ENABLE_ANON, test "$ac_enable_anon" != "no")
257
258   AC_MSG_CHECKING([whether to disable DHE support])
259   AC_ARG_ENABLE(dhe,
260     AS_HELP_STRING([--disable-dhe],
261                    [disable the DHE support]),
262     ac_enable_dhe=$enableval, ac_enable_dhe=yes)
263   if test x$ac_enable_dhe != xno; then
264    AC_MSG_RESULT(no)
265    AC_DEFINE([ENABLE_DHE], 1, [enable DHE])
266   else
267    ac_full=0
268    AC_MSG_RESULT(yes)
269   fi
270   AM_CONDITIONAL(ENABLE_DHE, test "$ac_enable_dhe" != "no")
271
272   AC_MSG_CHECKING([whether to disable ECDHE support])
273   AC_ARG_ENABLE(ecdhe,
274     AS_HELP_STRING([--disable-ecdhe],
275                    [disable the ECDHE support]),
276     ac_enable_ecdhe=$enableval, ac_enable_ecdhe=yes)
277   if test x$ac_enable_ecdhe != xno; then
278    AC_MSG_RESULT(no)
279    AC_DEFINE([ENABLE_ECDHE], 1, [enable DHE])
280   else
281    ac_full=0
282    AC_MSG_RESULT(yes)
283   fi
284   AM_CONDITIONAL(ENABLE_ECDHE, test "$ac_enable_ecdhe" != "no")
285
286   ac_enable_openpgp=yes
287   AC_MSG_CHECKING([whether to disable OpenPGP Certificate authentication support])
288   AC_ARG_ENABLE(openpgp-authentication,
289     AS_HELP_STRING([--disable-openpgp-authentication],
290                    [disable the OpenPGP authentication support]),
291     ac_enable_openpgp=$enableval)
292   if test x$ac_enable_openpgp = xno; then
293    AC_MSG_RESULT(yes)
294    ac_full=0
295   else
296    AC_DEFINE([ENABLE_OPENPGP], 1, [use openpgp authentication])
297    AC_MSG_RESULT(no)
298   fi
299   AM_CONDITIONAL(ENABLE_OPENPGP, test "$ac_enable_openpgp" = "yes")
300
301   # For cryptodev
302   AC_MSG_CHECKING([whether to add cryptodev support])
303   AC_ARG_ENABLE(cryptodev,
304     AS_HELP_STRING([--enable-cryptodev], [enable cryptodev support]),
305   enable_cryptodev=$enableval,enable_cryptodev=no)
306   AC_MSG_RESULT($enable_cryptodev)
307
308   if test "$enable_cryptodev" = "yes"; then
309     AC_DEFINE([ENABLE_CRYPTODEV], 1, [Enable cryptodev support])
310   fi
311
312   AC_MSG_CHECKING([whether to disable OCSP support])
313   AC_ARG_ENABLE(ocsp,
314     AS_HELP_STRING([--disable-ocsp],
315                    [disable OCSP support]),
316     ac_enable_ocsp=$enableval,ac_enable_ocsp=yes)
317   if test x$ac_enable_ocsp != xno; then
318    ac_enable_ocsp=yes
319    AC_MSG_RESULT(no)
320    AC_DEFINE([ENABLE_OCSP], 1, [enable OCSP support])
321   else
322    ac_full=0
323    AC_MSG_RESULT(yes)
324   fi
325   AM_CONDITIONAL(ENABLE_OCSP, test "$ac_enable_ocsp" != "no")
326
327
328   AC_MSG_CHECKING([whether to disable session tickets support])
329   AC_ARG_ENABLE(session-tickets,
330     AS_HELP_STRING([--disable-session-tickets],
331                    [disable session tickets support]),
332     ac_enable_session_tickets=$enableval,ac_enable_session_tickets=yes)
333   if test x$ac_enable_session_tickets != xno; then
334    ac_enable_session_tickets=yes
335    AC_MSG_RESULT(no)
336    AC_DEFINE([ENABLE_SESSION_TICKETS], 1, [enable session tickets support])
337   else
338    ac_full=0
339    AC_MSG_RESULT(yes)
340   fi
341   AM_CONDITIONAL(ENABLE_SESSION_TICKETS, test "$ac_enable_session_tickets" != "no")
342
343   # For storing integers in pointers without warnings
344   # http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html#desc
345   AC_CHECK_SIZEOF(void *)
346   AC_CHECK_SIZEOF(long long)
347   AC_CHECK_SIZEOF(long)
348   AC_CHECK_SIZEOF(int)
349   if test x$ac_cv_sizeof_void_p = x$ac_cv_sizeof_long;then
350       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long)],
351                 [Additional cast to bring void* to a type castable to int.])
352   elif test x$ac_cv_sizeof_void_p = x$ac_cv_sizeof_long_long;then
353       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long long)],
354                 [Additional cast to bring void* to a type castable to int.])
355    else
356       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [])
357    fi
358
359 dnl this is called from somewhere else
360 dnl #AM_ICONV
361 dnl m4_ifdef([gl_ICONV_MODULE_INDICATOR],
362 dnl  [gl_ICONV_MODULE_INDICATOR([iconv])])
363 ])