summaryrefslogtreecommitdiff
path: root/lib/m4/hooks.m4
blob: ddac5f8c0bf1c810e8acb39aa438497f5ec13812 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
# 2009, 2010 Free Software Foundation, Inc.
#
# Author: Nikos Mavrogiannopoulos, Simon Josefsson
#
# This file is part of GnuTLS.
#
# The GnuTLS is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# The GnuTLS is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with GnuTLS; if not, write to the Free
# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA

AC_DEFUN([LIBGNUTLS_HOOKS],
[
  # Library code modified:                              REVISION++
  # Interfaces changed/added/removed:   CURRENT++       REVISION=0
  # Interfaces added:                             AGE++
  # Interfaces removed:                           AGE=0
  AC_SUBST(LT_CURRENT, 42)
  AC_SUBST(LT_REVISION, 6)
  AC_SUBST(LT_AGE, 16)

  AC_SUBST(CXX_LT_CURRENT, 27)
  AC_SUBST(CXX_LT_REVISION, 0)
  AC_SUBST(CXX_LT_AGE, 0)

  # Used when creating the Windows libgnutls-XX.def files.
  DLL_VERSION=`expr ${LT_CURRENT} - ${LT_AGE}`
  AC_SUBST(DLL_VERSION)

  cryptolib="nettle (unsupported)"
  AC_ARG_WITH(nettle,
    AS_HELP_STRING([--with-nettle], [use libnettle 2.x as crypto library]),
      nettle=$withval,
      nettle=no)
    if test "$nettle" = "yes"; then
    AC_LIB_HAVE_LINKFLAGS([nettle],, [#include <nettle/aes.h>],
                          [aes_set_key (0, 0, 0)])
    if test "$ac_cv_libnettle" != yes; then
      nettle=yes
      AC_MSG_WARN([[
  *** 
  *** Libnettle was not found. 
  ]])
    fi
  fi

  AC_MSG_CHECKING([whether to use nettle])
  AC_MSG_RESULT($nettle)
  AM_CONDITIONAL(ENABLE_NETTLE, test "$nettle" = "yes")

  if test "$nettle" != "yes";then
  	cryptolib=libgcrypt
	AC_LIB_HAVE_LINKFLAGS([gcrypt], [gpg-error], [#include <gcrypt.h>],
    [enum gcry_cipher_algos i = GCRY_CIPHER_CAMELLIA128])
  if test "$ac_cv_libgcrypt" != yes; then
    AC_MSG_ERROR([[
***  
*** libgcrypt was not found. You may want to get it from
*** ftp://ftp.gnupg.org/gcrypt/libgcrypt/
***
    ]])
  fi
  fi

  AC_ARG_WITH(included-libtasn1,
    AS_HELP_STRING([--with-included-libtasn1], [use the included libtasn1]),
      included_libtasn1=$withval,
      included_libtasn1=no)
  if test "$included_libtasn1" = "no"; then
    AC_LIB_HAVE_LINKFLAGS(tasn1,, [#include <libtasn1.h>],
                          [asn1_check_version (NULL)])
    if test "$ac_cv_libtasn1" != yes; then
      included_libtasn1=yes
      AC_MSG_WARN([[
  *** 
  *** Libtasn1 was not found. Will use the included one.
  ]])
    fi
  fi
  AC_MSG_CHECKING([whether to use the included minitasn1])
  AC_MSG_RESULT($included_libtasn1)
  AM_CONDITIONAL(ENABLE_MINITASN1, test "$included_libtasn1" = "yes")

  AC_ARG_WITH(included-pakchois,
    AS_HELP_STRING([--with-included-pakchois], [use the included pakchois]),
      included_pakchois=$withval,
      included_pakchois=no)
  if test "$included_pakchois" = "no"; then
    AC_LIB_HAVE_LINKFLAGS(pakchois,, [#include <pakchois/pakchois.h>],
                          [pakchois_module_load(0,0);])
    if test "$ac_cv_pakchois" != yes; then
      included_pakchois=yes
      AC_MSG_WARN([[
  *** 
  *** Pakchois was not found. Will use the included one.
  ]])
    fi
  fi
  #not other option for now. The released pakchois cannot open an arbitrary PKCS11 module,
  #and the author is reluctant to add such feature.
  included_pakchois=yes
  AC_MSG_CHECKING([whether to use the included pakchois])
  AC_MSG_RESULT($included_pakchois)
  AM_CONDITIONAL(ENABLE_LOCAL_PAKCHOIS, test "$included_pakchois" = "yes")
  if test "$included_pakchois" = "yes";then
	AC_CHECK_LIB(pthread, pthread_mutex_lock,,
	   [AC_MSG_ERROR([could not find pthread_mutex_lock])])
	AC_CHECK_LIB(dl, dlopen,,
	   [AC_MSG_ERROR([could not find dlopen])])

	module_path="${libdir}:${libdir}/pkcs11"

	CPPFLAGS="$CPPFLAGS -DPAKCHOIS_MODPATH=\\\"${module_path}\\\""
  fi

  AC_ARG_WITH(lzo,
    AS_HELP_STRING([--with-lzo], [use experimental LZO compression]),
                   use_lzo=$withval, use_lzo=no)
  AC_MSG_CHECKING([whether to include LZO compression support])
  AC_MSG_RESULT($use_lzo)
  LZO_LIBS=
  if test "$use_lzo" = "yes"; then
    AC_CHECK_LIB(lzo2, lzo1x_1_compress, LZO_LIBS=-llzo2)
    if test "$LZO_LIBS" = ""; then
      AC_CHECK_LIB(lzo, lzo1x_1_compress, LZO_LIBS=-llzo, [
        use_lzo=no
        AC_MSG_WARN(
  ***
  *** Could not find liblzo or liblzo2.  Disabling LZO compression.
  )
        ])
    fi
  fi
  AC_SUBST(LZO_LIBS)
  if test "$use_lzo" = "yes"; then
    AC_DEFINE([USE_LZO], 1, [whether to use the LZO compression])
    if test "$LZO_LIBS" = "-llzo"; then
      AC_CHECK_HEADERS(lzo1x.h)
    elif test "$LZO_LIBS" = "-llzo2"; then
      AC_CHECK_HEADERS(lzo/lzo1x.h)
    fi
  fi
  AM_CONDITIONAL(USE_LZO, test "$use_lzo" = "yes")

  AC_MSG_CHECKING([whether C99 macros are supported])
  AC_TRY_COMPILE(,
  [
    #define test_mac(...) 
    int z,y,x;
    test_mac(x,y,z);
    return 0;
  ], [
    AC_DEFINE([C99_MACROS], 1, [C99 macros are supported])
    AC_MSG_RESULT(yes)
  ], [
    AC_MSG_RESULT(no)
    AC_MSG_WARN([C99 macros not supported. This may affect compiling.])
  ])

  AC_MSG_CHECKING([whether to enable Opaque PRF input support])
  AC_ARG_ENABLE(opaque-prf-input,
    AS_HELP_STRING([--enable-opaque-prf-input=DD],
                   [enable Opaque PRF input using DD as extension type]),
    ac_opaque_prf_input=$enableval, ac_opaque_prf_input=no)
  if test "$ac_opaque_prf_input" != "no"; then
    if ! echo $ac_opaque_prf_input | egrep -q '^[[0-9]]+$'; then
      ac_opaque_prf_input=no
      AC_MSG_WARN([[
  *** Could not parse Opaque PRF Input extension type.
  *** Use --enable-opaque-prf-input=XX where XX is decimal, for example
  *** to use extension value 42 use --enable-opqaue-prf-input=42]])
    fi
  fi
  if test "$ac_opaque_prf_input" != "no"; then
   AC_MSG_RESULT([yes (extension value $ac_opaque_prf_input)])
   AC_DEFINE_UNQUOTED([ENABLE_OPRFI], $ac_opaque_prf_input,
                      [enable Opaque PRF Input])
  else
   AC_MSG_RESULT(no)
  fi
  AM_CONDITIONAL(ENABLE_OPRFI, test "$ac_opaque_prf_input" != "no")
  
  AC_MSG_CHECKING([whether to disable SRP authentication support])
  AC_ARG_ENABLE(srp-authentication,
    AS_HELP_STRING([--disable-srp-authentication],
                   [disable the SRP authentication support]),
    ac_enable_srp=no)
  if test x$ac_enable_srp != xno; then
   AC_MSG_RESULT(no)
   AC_DEFINE([ENABLE_SRP], 1, [enable SRP authentication])
  else
   ac_full=0
   AC_MSG_RESULT(yes)
  fi
  AM_CONDITIONAL(ENABLE_SRP, test "$ac_enable_srp" != "no")
  
  AC_MSG_CHECKING([whether to disable PSK authentication support])
  AC_ARG_ENABLE(psk-authentication,
    AS_HELP_STRING([--disable-psk-authentication],
                   [disable the PSK authentication support]),
    ac_enable_psk=no)
  if test x$ac_enable_psk != xno; then
   AC_MSG_RESULT(no)
   AC_DEFINE([ENABLE_PSK], 1, [enable PSK authentication])
  else
   ac_full=0
   AC_MSG_RESULT(yes)
  fi
  AM_CONDITIONAL(ENABLE_PSK, test "$ac_enable_psk" != "no")
  
  AC_MSG_CHECKING([whether to disable anonymous authentication support])
  AC_ARG_ENABLE(anon-authentication,
    AS_HELP_STRING([--disable-anon-authentication],
                   [disable the anonymous authentication support]),
    ac_enable_anon=no)
  if test x$ac_enable_anon != xno; then
   AC_MSG_RESULT(no)
   AC_DEFINE([ENABLE_ANON], 1, [enable anonymous authentication])
  else
   ac_full=0
   AC_MSG_RESULT(yes)
  fi
  AM_CONDITIONAL(ENABLE_ANON, test "$ac_enable_anon" != "no")
  
  # Allow disabling Camellia
  if test "$nettle" != "yes";then
  AC_ARG_ENABLE(camellia,
    AS_HELP_STRING([--disable-camellia], [disable Camellia cipher]),
    enable_camellia=$enableval, enable_camellia=yes)
  else
    enable_camellia=no
  fi

  AC_MSG_CHECKING([whether to disable Camellia cipher])
  if test "$enable_camellia" != "no"; then
   AC_MSG_RESULT([no])
   AC_DEFINE([ENABLE_CAMELLIA], 1, [enable camellia block cipher])
  else
   AC_MSG_RESULT([yes])
  fi
  
  AC_MSG_CHECKING([whether to disable extra PKI stuff])
  AC_ARG_ENABLE(extra-pki,
    AS_HELP_STRING([--disable-extra-pki],
                   [only enable the basic PKI stuff]),
    enable_pki=$enableval, enable_pki=yes)
  if test "$enable_pki" != "yes"; then
   ac_full=0
   AC_MSG_RESULT(yes)
  else
   AC_MSG_RESULT(no)
   AC_DEFINE([ENABLE_PKI], 1, [whether to include all the PKCS/PKI stuff])
  fi
  AM_CONDITIONAL(ENABLE_PKI, test "$enable_pki" = "yes")
  
  ac_enable_openpgp=yes
  AC_MSG_CHECKING([whether to disable OpenPGP Certificate authentication support])
  AC_ARG_ENABLE(openpgp-authentication,
    AS_HELP_STRING([--disable-openpgp-authentication],
                   [disable the OpenPGP authentication support]),
    ac_enable_openpgp=no)
  if test x$ac_enable_openpgp = xno; then
   AC_MSG_RESULT(yes)
   ac_full=0
  else
   AC_DEFINE([ENABLE_OPENPGP], 1, [use openpgp authentication])
   AC_MSG_RESULT(no)
  fi
  AM_CONDITIONAL(ENABLE_OPENPGP, test "$ac_enable_openpgp" = "yes")

  AC_MSG_CHECKING([whether to disable SessionTicket extension support])
  AC_ARG_ENABLE(session-ticket,
    AS_HELP_STRING([--disable-session-ticket],
                   [disable the SessionTicket extension support]),
    ac_session_ticket=no)
  if test x$ac_session_ticket != xno; then
   AC_MSG_RESULT(no)
   AC_DEFINE([ENABLE_SESSION_TICKET], 1, [enable SessionTicket extension])
  else
   ac_full=0
   AC_MSG_RESULT(yes)
  fi
  AM_CONDITIONAL(ENABLE_SESSION_TICKET, test "$ac_enable_session_ticket" != "no")

  # For cryptodev
  AC_MSG_CHECKING([whether to add cryptodev support])
  AC_ARG_ENABLE(cryptodev,
    AS_HELP_STRING([--enable-cryptodev], [enable cryptodev support]),
  enable_cryptodev=yes,enable_cryptodev=no)
  AC_MSG_RESULT($enable_cryptodev)

  if test "$enable_cryptodev" = "yes"; then
    AC_DEFINE([ENABLE_CRYPTODEV], 1, [Enable cryptodev support])
  fi

  # For storing integers in pointers without warnings
  # http://developer.gnome.org/doc/API/2.0/glib/glib-Type-Conversion-Macros.html#desc
  AC_CHECK_SIZEOF(void *)
  AC_CHECK_SIZEOF(long)
  AC_CHECK_SIZEOF(int)
  case $ac_cv_sizeof_void_p in
    $ac_cv_sizeof_long)
      AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [(long)],
                [Additional cast to bring void* to a type castable to int.])
      ;;
    *)
      AC_DEFINE([GNUTLS_POINTER_TO_INT_CAST], [])
      ;;
  esac
])