Tizen 2.0 Release
[external/libgnutls26.git] / lib / m4 / hooks.m4
1 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2 # 2009, 2010, 2011 Free Software Foundation, Inc.
3 #
4 # Author: Nikos Mavrogiannopoulos, Simon Josefsson
5 #
6 # This file is part of GnuTLS.
7 #
8 # The GnuTLS is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public License
10 # as published by the Free Software Foundation; either version 2.1 of
11 # the License, or (at your option) any later version.
12 #
13 # The GnuTLS is distributed in the hope that it will be
14 # useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with GnuTLS; if not, write to the Free
20 # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 # MA 02110-1301, USA
22
23 AC_DEFUN([LIBGNUTLS_HOOKS],
24 [
25   # Library code modified:                              REVISION++
26   # Interfaces changed/added/removed:   CURRENT++       REVISION=0
27   # Interfaces added:                             AGE++
28   # Interfaces removed:                           AGE=0
29   AC_SUBST(LT_CURRENT, 48)
30   AC_SUBST(LT_REVISION, 4)
31   AC_SUBST(LT_AGE, 22)
32
33   AC_SUBST(LT_SSL_CURRENT, 27)
34   AC_SUBST(LT_SSL_REVISION, 0)
35   AC_SUBST(LT_SSL_AGE, 0)
36
37   AC_SUBST(CXX_LT_CURRENT, 27)
38   AC_SUBST(CXX_LT_REVISION, 0)
39   AC_SUBST(CXX_LT_AGE, 0)
40
41   # Used when creating the Windows libgnutls-XX.def files.
42   DLL_VERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
43   AC_SUBST(DLL_VERSION)
44
45   cryptolib="nettle"
46
47   AC_ARG_WITH(libgcrypt,
48     AS_HELP_STRING([--with-libgcrypt], [use libgcrypt as crypto library]),
49       libgcrypt=$withval,
50       libgcrypt=no)
51     if test "$libgcrypt" = "yes"; then
52         cryptolib=libgcrypt
53         AC_DEFINE([HAVE_GCRYPT], 1, [whether the gcrypt library is in use])
54         AC_LIB_HAVE_LINKFLAGS([gcrypt], [gpg-error], [#include <gcrypt.h>],
55                       [enum gcry_cipher_algos i = GCRY_CIPHER_CAMELLIA128])
56       if test "$ac_cv_libgcrypt" != yes; then
57         AC_MSG_ERROR([[
58 ***  
59 *** Libgcrypt v1.4.0 or later was not found. You may want to get it from
60 *** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
61 ***
62     ]])
63       fi
64     fi
65
66   AC_MSG_CHECKING([whether to use nettle])
67 if test "$cryptolib" = "nettle";then
68   AC_MSG_RESULT(yes)
69     AC_LIB_HAVE_LINKFLAGS([nettle],, [#include <nettle/aes.h>],
70                           [nettle_aes_invert_key (0, 0)])
71     if test "$ac_cv_libnettle" != yes; then
72       AC_MSG_ERROR([[
73   *** 
74   *** Libnettle 2.1 was not found. 
75   ]])
76     fi
77     NETTLE_LIBS="-lgmp -lhogweed"
78 else
79   AC_MSG_RESULT(no)
80 fi
81     AC_SUBST(NETTLE_LIBS)
82   AM_CONDITIONAL(ENABLE_NETTLE, test "$cryptolib" = "nettle")
83
84   AC_ARG_WITH(included-libtasn1,
85     AS_HELP_STRING([--with-included-libtasn1], [use the included libtasn1]),
86       included_libtasn1=$withval,
87       included_libtasn1=no)
88   if test "$included_libtasn1" = "no"; then
89     AC_LIB_HAVE_LINKFLAGS(tasn1,, [#include <libtasn1.h>],
90                           [asn1_check_version (NULL)])
91     if test "$ac_cv_libtasn1" != yes; then
92       included_libtasn1=yes
93       AC_MSG_WARN([[
94   *** 
95   *** Libtasn1 was not found. Will use the included one.
96   ]])
97     fi
98   fi
99   AC_MSG_CHECKING([whether to use the included minitasn1])
100   AC_MSG_RESULT($included_libtasn1)
101   AM_CONDITIONAL(ENABLE_MINITASN1, test "$included_libtasn1" = "yes")
102
103   if test "$included_libtasn1" = "no"; then
104     GNUTLS_REQUIRES_PRIVATE="Requires.private: libtasn1"
105   fi
106
107   AC_ARG_WITH(lzo,
108     AS_HELP_STRING([--with-lzo], [use experimental LZO compression]),
109                    use_lzo=$withval, use_lzo=no)
110   AC_MSG_CHECKING([whether to include LZO compression support])
111   AC_MSG_RESULT($use_lzo)
112   LZO_LIBS=
113   if test "$use_lzo" = "yes"; then
114     AC_CHECK_LIB(lzo2, lzo1x_1_compress, LZO_LIBS=-llzo2)
115     if test "$LZO_LIBS" = ""; then
116       AC_CHECK_LIB(lzo, lzo1x_1_compress, LZO_LIBS=-llzo, [
117         use_lzo=no
118         AC_MSG_WARN(
119   ***
120   *** Could not find liblzo or liblzo2.  Disabling LZO compression.
121   )
122         ])
123     fi
124   fi
125   AC_SUBST(LZO_LIBS)
126   if test "$use_lzo" = "yes"; then
127     AC_DEFINE([USE_LZO], 1, [whether to use the LZO compression])
128     if test "$LZO_LIBS" = "-llzo"; then
129       AC_CHECK_HEADERS(lzo1x.h)
130     elif test "$LZO_LIBS" = "-llzo2"; then
131       AC_CHECK_HEADERS(lzo/lzo1x.h)
132     fi
133   fi
134   AM_CONDITIONAL(USE_LZO, test "$use_lzo" = "yes")
135
136   AC_MSG_CHECKING([whether C99 macros are supported])
137   AC_TRY_COMPILE(,
138   [
139     #define test_mac(...) 
140     int z,y,x;
141     test_mac(x,y,z);
142     return 0;
143   ], [
144     AC_DEFINE([C99_MACROS], 1, [C99 macros are supported])
145     AC_MSG_RESULT(yes)
146   ], [
147     AC_MSG_RESULT(no)
148     AC_MSG_WARN([C99 macros not supported. This may affect compiling.])
149   ])
150
151   AC_MSG_CHECKING([whether to enable Opaque PRF input support])
152   AC_ARG_ENABLE(opaque-prf-input,
153     AS_HELP_STRING([--enable-opaque-prf-input=DD],
154                    [enable Opaque PRF input using DD as extension type]),
155     ac_opaque_prf_input=$enableval, ac_opaque_prf_input=no)
156   if test "$ac_opaque_prf_input" != "no"; then
157     if ! echo $ac_opaque_prf_input | egrep -q '^[[0-9]]+$'; then
158       ac_opaque_prf_input=no
159       AC_MSG_WARN([[
160   *** Could not parse Opaque PRF Input extension type.
161   *** Use --enable-opaque-prf-input=XX where XX is decimal, for example
162   *** to use extension value 42 use --enable-opqaue-prf-input=42]])
163     fi
164   fi
165   if test "$ac_opaque_prf_input" != "no"; then
166    AC_MSG_RESULT([yes (extension value $ac_opaque_prf_input)])
167    AC_DEFINE_UNQUOTED([ENABLE_OPRFI], $ac_opaque_prf_input,
168                       [enable Opaque PRF Input])
169   else
170    AC_MSG_RESULT(no)
171   fi
172   AM_CONDITIONAL(ENABLE_OPRFI, test "$ac_opaque_prf_input" != "no")
173   
174   AC_MSG_CHECKING([whether to disable SRP authentication support])
175   AC_ARG_ENABLE(srp-authentication,
176     AS_HELP_STRING([--disable-srp-authentication],
177                    [disable the SRP authentication support]),
178     ac_enable_srp=no)
179   if test x$ac_enable_srp != xno; then
180    AC_MSG_RESULT(no)
181    AC_DEFINE([ENABLE_SRP], 1, [enable SRP authentication])
182   else
183    ac_full=0
184    AC_MSG_RESULT(yes)
185   fi
186   AM_CONDITIONAL(ENABLE_SRP, test "$ac_enable_srp" != "no")
187   
188   AC_MSG_CHECKING([whether to disable PSK authentication support])
189   AC_ARG_ENABLE(psk-authentication,
190     AS_HELP_STRING([--disable-psk-authentication],
191                    [disable the PSK authentication support]),
192     ac_enable_psk=no)
193   if test x$ac_enable_psk != xno; then
194    AC_MSG_RESULT(no)
195    AC_DEFINE([ENABLE_PSK], 1, [enable PSK authentication])
196   else
197    ac_full=0
198    AC_MSG_RESULT(yes)
199   fi
200   AM_CONDITIONAL(ENABLE_PSK, test "$ac_enable_psk" != "no")
201   
202   AC_MSG_CHECKING([whether to disable anonymous authentication support])
203   AC_ARG_ENABLE(anon-authentication,
204     AS_HELP_STRING([--disable-anon-authentication],
205                    [disable the anonymous authentication support]),
206     ac_enable_anon=no)
207   if test x$ac_enable_anon != xno; then
208    AC_MSG_RESULT(no)
209    AC_DEFINE([ENABLE_ANON], 1, [enable anonymous authentication])
210   else
211    ac_full=0
212    AC_MSG_RESULT(yes)
213   fi
214   AM_CONDITIONAL(ENABLE_ANON, test "$ac_enable_anon" != "no")
215   
216   # Allow disabling Camellia
217   if test "$nettle" != "yes";then
218   AC_ARG_ENABLE(camellia,
219     AS_HELP_STRING([--disable-camellia], [disable Camellia cipher]),
220     enable_camellia=$enableval, enable_camellia=yes)
221   else
222     enable_camellia=no
223   fi
224
225   AC_MSG_CHECKING([whether to disable Camellia cipher])
226   if test "$enable_camellia" != "no"; then
227    AC_MSG_RESULT([no])
228    AC_DEFINE([ENABLE_CAMELLIA], 1, [enable camellia block cipher])
229   else
230    AC_MSG_RESULT([yes])
231   fi
232   
233   AC_MSG_CHECKING([whether to disable extra PKI stuff])
234   AC_ARG_ENABLE(extra-pki,
235     AS_HELP_STRING([--disable-extra-pki],
236                    [only enable the basic PKI stuff]),
237     enable_pki=$enableval, enable_pki=yes)
238   if test "$enable_pki" != "yes"; then
239    ac_full=0
240    AC_MSG_RESULT(yes)
241   else
242    AC_MSG_RESULT(no)
243    AC_DEFINE([ENABLE_PKI], 1, [whether to include all the PKCS/PKI stuff])
244   fi
245   AM_CONDITIONAL(ENABLE_PKI, test "$enable_pki" = "yes")
246   
247   ac_enable_openpgp=yes
248   AC_MSG_CHECKING([whether to disable OpenPGP Certificate authentication support])
249   AC_ARG_ENABLE(openpgp-authentication,
250     AS_HELP_STRING([--disable-openpgp-authentication],
251                    [disable the OpenPGP authentication support]),
252     ac_enable_openpgp=no)
253   if test x$ac_enable_openpgp = xno; then
254    AC_MSG_RESULT(yes)
255    ac_full=0
256   else
257    AC_DEFINE([ENABLE_OPENPGP], 1, [use openpgp authentication])
258    AC_MSG_RESULT(no)
259   fi
260   AM_CONDITIONAL(ENABLE_OPENPGP, test "$ac_enable_openpgp" = "yes")
261
262   AC_MSG_CHECKING([whether to disable SessionTicket extension support])
263   AC_ARG_ENABLE(session-ticket,
264     AS_HELP_STRING([--disable-session-ticket],
265                    [disable the SessionTicket extension support]),
266     ac_session_ticket=no)
267   if test x$ac_session_ticket != xno; then
268    AC_MSG_RESULT(no)
269    AC_DEFINE([ENABLE_SESSION_TICKET], 1, [enable SessionTicket extension])
270   else
271    ac_full=0
272    AC_MSG_RESULT(yes)
273   fi
274   AM_CONDITIONAL(ENABLE_SESSION_TICKET, test "$ac_enable_session_ticket" != "no")
275
276   # For cryptodev
277   AC_MSG_CHECKING([whether to add cryptodev support])
278   AC_ARG_ENABLE(cryptodev,
279     AS_HELP_STRING([--enable-cryptodev], [enable cryptodev support]),
280   enable_cryptodev=yes,enable_cryptodev=no)
281   AC_MSG_RESULT($enable_cryptodev)
282
283   if test "$enable_cryptodev" = "yes"; then
284     AC_DEFINE([ENABLE_CRYPTODEV], 1, [Enable cryptodev support])
285   fi
286
287   # For storing integers in pointers without warnings
288   # http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html#desc
289   AC_CHECK_SIZEOF(void *)
290   AC_CHECK_SIZEOF(long)
291   AC_CHECK_SIZEOF(int)
292   case $ac_cv_sizeof_void_p in
293     $ac_cv_sizeof_long)
294       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long)],
295                 [Additional cast to bring void* to a type castable to int.])
296       ;;
297     *)
298       AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [])
299       ;;
300   esac
301 ])