Added support for RFC7366 (encrypt then authenticate)
[gnutls:gnutls.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 # Copyright (C) 2000-2012 Free Software Foundation, Inc.
3 #
4 # Author: Nikos Mavrogiannopoulos, Simon Josefsson
5 #
6 # This file is part of GnuTLS.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
21 # USA
22
23 AC_PREREQ(2.61)
24 AC_INIT([GnuTLS], [3.4.0], [bugs@gnutls.org])
25 AC_CONFIG_AUX_DIR([build-aux])
26 AC_CONFIG_MACRO_DIR([m4])
27 AC_CANONICAL_HOST
28
29 AM_INIT_AUTOMAKE([1.12.2 subdir-objects no-dist-gzip dist-xz dist-lzip -Wall -Wno-override])
30 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
31 AC_CONFIG_HEADERS([config.h])
32
33 AC_MSG_RESULT([***
34 *** Checking for compilation programs...
35 ])
36
37 dnl Checks for programs.
38 PKG_PROG_PKG_CONFIG
39 AC_PROG_CC
40 gl_EARLY
41 ggl_EARLY
42 AM_PROG_AS
43 AM_PROG_AR
44 AC_PROG_CXX
45 AM_PROG_CC_C_O
46 AC_PROG_YACC
47 AC_PROG_SED
48 AC_CHECK_PROG([AUTOGEN], [autogen], [autogen], [/bin/true])
49
50 if test x"$AUTOGEN" = "x/bin/true"; then
51   AC_MSG_WARN([[
52 ***
53 *** autogen not found. Will not link against libopts.
54 *** ]])
55 enable_local_libopts=yes
56 fi
57
58 # For includes/gnutls/gnutls.h.in.
59 AC_SUBST(MAJOR_VERSION, `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
60 AC_SUBST(MINOR_VERSION, `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
61 AC_SUBST(PATCH_VERSION, [[`echo $PACKAGE_VERSION | sed 's/.*\..*\.\([0-9]*\).*/\1/g'`]])
62 AC_SUBST(NUMBER_VERSION, `printf "0x%02x%02x%02x" $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION`)
63
64 touch suppressions.valgrind
65 dnl C and C++ capabilities
66 AC_C_INLINE
67 AC_HEADER_STDC
68
69 # For the C++ code
70 AC_ARG_ENABLE(cxx,
71   AS_HELP_STRING([--disable-cxx], [unconditionally disable the C++ library]),
72     use_cxx=$enableval, use_cxx=yes)
73 if test "$use_cxx" != "no"; then
74   AC_LANG_PUSH(C++)
75   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], use_cxx=yes, use_cxx=no)
76   AC_LANG_POP(C++)
77 fi
78 AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no")
79 AM_CONDITIONAL(WANT_TEST_SUITE, [test -f tests/suite/mini-eagain2.c])
80
81 dnl Detect windows build
82 case "$host" in
83   *mingw32* | *mingw64*)
84     have_win=yes
85   ;;
86   *darwin*)
87     have_macosx=yes
88   ;;
89   *)
90     have_elf=yes
91   ;;
92 esac
93
94 AM_CONDITIONAL(WINDOWS, test "$have_win" = yes)
95 AM_CONDITIONAL(MACOSX, test "$have_macosx" = yes)
96 AM_CONDITIONAL(ELF, test "$have_elf" = yes)
97
98 dnl Hardware Acceleration
99 AC_ARG_ENABLE(hardware-acceleration,
100   AS_HELP_STRING([--disable-hardware-acceleration], [unconditionally disable hardware acceleration]),
101     use_accel=$enableval, use_accel=yes)
102 hw_accel=none
103
104
105 use_padlock=no
106 if test "$use_accel" != "no"; then
107 case $host_cpu in
108   i?86 | x86_64 | amd64)
109       AC_CHECK_HEADERS(cpuid.h)
110       if test "$host_cpu" = "x86_64" || test "$host_cpu" = "amd64"; then
111         hw_accel="x86-64"
112       else
113         hw_accel="x86"
114       fi
115       use_padlock=yes
116   ;;
117   *)
118   ;;
119 esac
120
121 fi
122
123 AC_ARG_ENABLE(padlock,
124   AS_HELP_STRING([--disable-padlock], [unconditionally disable padlock acceleration]),
125     use_padlock=$enableval)
126
127 if test "$use_padlock" != "no"; then
128     AC_DEFINE([ENABLE_PADLOCK], 1, [Enable padlock acceleration])
129     AC_SUBST([ENABLE_PADLOCK])
130 fi
131 AM_CONDITIONAL(ENABLE_PADLOCK, test "$use_padlock" = "yes")
132 AM_CONDITIONAL(ASM_X86_64, test x"$hw_accel" = x"x86-64")
133 AM_CONDITIONAL(ASM_X86_32, test x"$hw_accel" = x"x86")
134 AM_CONDITIONAL(ASM_X86, test x"$hw_accel" = x"x86" || test x"$hw_accel" = x"x86-64")
135 AM_CONDITIONAL(HAVE_GCC_GNU89_INLINE_OPTION, test "$gnu89_inline" = "yes"])
136 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = "yes")
137
138
139 dnl Try the hooks.m4
140 LIBGNUTLS_HOOKS
141 LIBGNUTLS_EXTRA_HOOKS
142
143 AC_ARG_ENABLE(doc,
144   AS_HELP_STRING([--disable-doc], [don't generate any documentation]),
145     enable_doc=$enableval, enable_doc=yes)
146 AM_CONDITIONAL(ENABLE_DOC, test "$enable_doc" != "no")
147
148 AC_ARG_ENABLE(tests,
149   AS_HELP_STRING([--disable-tests], [don't compile or run any tests]),
150     enable_tests=$enableval, enable_tests=yes)
151 AM_CONDITIONAL(ENABLE_TESTS, test "$enable_tests" != "no")
152
153 GTK_DOC_CHECK(1.1)
154 AM_GNU_GETTEXT([external])
155 AM_GNU_GETTEXT_VERSION([0.18])
156
157 AC_C_BIGENDIAN
158
159 dnl No fork on MinGW, disable some self-tests until we fix them.
160 dnl Check clock_gettime and pthread_mutex_lock in libc (avoid linking to other libs)
161 AC_CHECK_FUNCS([fork inet_ntop inet_pton getrusage getpwuid_r nanosleep daemon getpid clock_gettime iconv localtime vasprintf],,)
162 if test "$ac_cv_func_vasprintf" != "yes";then
163   AC_MSG_CHECKING([for va_copy])
164   AC_LINK_IFELSE([AC_LANG_PROGRAM([
165         #include <stdarg.h>
166         va_list a;],[
167         va_list b;
168         va_copy(b,a);
169         va_end(b);])],
170         [AC_DEFINE(HAVE_VA_COPY, 1, [Have va_copy()])
171         AC_MSG_RESULT(va_copy)],
172         [AC_LINK_IFELSE([AC_LANG_PROGRAM([
173                 #include <stdarg.h>
174                 va_list a;],[
175                 va_list b;
176                 __va_copy(b,a);
177                 va_end(b);])],
178                 [AC_DEFINE(HAVE___VA_COPY, 1, [Have __va_copy()])
179                 AC_MSG_RESULT(__va_copy)],
180                 [AC_MSG_RESULT(no)
181                 AC_MSG_ERROR([Your system lacks vasprintf() and va_copy()])])
182         ])
183 fi
184
185 AM_CONDITIONAL(HAVE_FORK, test "$ac_cv_func_fork" != "no")
186
187 AC_CHECK_FUNCS([pthread_atfork __register_atfork],,)
188
189 AC_LIB_HAVE_LINKFLAGS(rt,, [#include <time.h>
190 #include <signal.h>
191 ], [timer_create (0,0,0);])
192
193 if test "$have_win" != "yes";then
194   AC_CHECK_FUNCS([pthread_mutex_lock],,)
195   if test "$ac_cv_func_pthread_mutex_lock" != "yes";then
196     AC_LIB_HAVE_LINKFLAGS(pthread,, [#include <pthread.h>], [pthread_mutex_lock (0);])
197   fi
198 fi
199
200 if test "$ac_cv_func_nanosleep" != "yes";then
201   AC_LIB_HAVE_LINKFLAGS(rt,, [#include <time.h>], [nanosleep (0, 0);])
202   gnutls_needs_librt=yes
203 fi
204
205 if test "$ac_cv_func_inet_pton" != "yes";then
206   AC_LIB_HAVE_LINKFLAGS(nsl,, [#include <arpa/inet.h>], [inet_pton(0,0,0);])
207 fi
208
209 if test "$ac_cv_func_clock_gettime" != "yes";then
210   AC_LIB_HAVE_LINKFLAGS(rt,, [#include <time.h>], [clock_gettime (0, 0);])
211   gnutls_needs_librt=yes
212 fi
213
214 ac_have_unicode=no
215 if test "$ac_cv_func_iconv" != "yes";then
216   AC_LIB_HAVE_LINKFLAGS(iconv,, [#include <iconv.h>], [iconv (0, 0, 0, 0, 0);])
217   if test "$HAVE_LIBICONV" = "yes";then
218     ac_have_unicode=yes
219   fi
220 else
221   ac_have_unicode=yes
222 fi
223
224 if test "$ac_have_unicode" != "yes";then
225   if test "$have_win" = "yes";then
226     ac_have_unicode=yes
227   fi
228 fi
229
230 dnl Note that g*l_INIT are run after we check for library capabilities,
231 dnl to prevent issues from caching lib dependencies. See discussion
232 dnl in https://bugs.gentoo.org/show_bug.cgi?id=494940 and
233 dnl http://gnu-autoconf.7623.n7.nabble.com/Correct-way-to-check-for-clock-gettime-td12276.html
234 gl_INIT
235 ggl_INIT
236
237 dnl GCC warnings to enable
238
239 AC_ARG_ENABLE([gcc-warnings],
240   [AS_HELP_STRING([--disable-gcc-warnings],
241                   [turn off lots of GCC warnings (for developers)])],
242   [case $enableval in
243      yes|no) ;;
244      *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
245    esac
246    gl_gcc_warnings=$enableval],
247   [gl_gcc_warnings=yes]
248 )
249
250 if test "$gl_gcc_warnings" = yes; then
251   gl_WARN_ADD([-Wframe-larger-than=1024], [WSTACK_CFLAGS])
252
253   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
254   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
255   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
256   nw="$nw -Wtraditional"            # Warns on #elif which we use often
257   nw="$nw -Wpadded"                 # Our structs are not padded
258   nw="$nw -Wtraditional-conversion" # Too many warnings for now
259   nw="$nw -Wswitch-default"         # Too many warnings for now
260   nw="$nw -Wformat-y2k"             # Too many warnings for now
261   nw="$nw -Woverlength-strings"     # We use some in tests/
262   nw="$nw -Wvla"                    # There is no point to avoid C99 variable length arrays
263   nw="$nw -Wformat-nonliteral"      # Incompatible with gettext _()
264   nw="$nw -Wstrict-overflow"
265   nw="$nw -Wmissing-noreturn"
266   nw="$nw -Winline"                 # Too compiler dependent
267   nw="$nw -Wsuggest-attribute=pure" # Is it worth using attributes?
268   nw="$nw -Wsuggest-attribute=const" # Is it worth using attributes?
269   nw="$nw -Wsuggest-attribute=noreturn" # Is it worth using attributes?
270   nw="$nw -Wstack-protector"        # Some functions cannot be protected
271   nw="$nw -Wredundant-decls"        # Some files cannot be compiled with that (gl_fd_to_handle)
272
273   gl_MANYWARN_ALL_GCC([ws])
274   gl_MANYWARN_COMPLEMENT(ws, [$ws], [$nw])
275   for w in $ws; do
276     gl_WARN_ADD([$w])
277   done
278
279   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
280   gl_WARN_ADD([-Wno-format-y2k])     # Too many warnings for now
281   gl_WARN_ADD([-Wno-unused-value]) # warnings for things we don't want to get
282   gl_WARN_ADD([-Wno-unused-result]) # warnings for things we don't want to get
283   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
284   gl_WARN_ADD([-Wno-stack-protector])  # Some functions cannot be protected
285   gl_WARN_ADD([-Wno-int-to-pointer-cast])  # Some files cannot be compiled with that (gl_fd_to_handle)
286   gl_WARN_ADD([-fdiagnostics-show-option])
287 fi
288
289 AC_SUBST([WERROR_CFLAGS])
290 AC_SUBST([WSTACK_CFLAGS])
291 AC_SUBST([WARN_CFLAGS])
292
293 dnl Programs for compilation or development
294 AC_PROG_LN_S
295 LT_INIT([disable-static,win32-dll,shared])
296
297
298
299 AC_ARG_ENABLE(self-checks,
300   AS_HELP_STRING([--enable-self-checks], [enable self checking functionality]),
301     enable_self_checks=$enableval, enable_self_checks=no)
302
303 AC_ARG_ENABLE(fips140-mode,
304   AS_HELP_STRING([--enable-fips140-mode], [enable FIPS140-2 mode (implies self checks)]),
305     enable_fips=$enableval, enable_fips=no)
306 AM_CONDITIONAL(ENABLE_FIPS140, test "$enable_fips" = "yes")
307 if [ test "$enable_fips" = "yes" ];then
308   AC_LIB_HAVE_LINKFLAGS(dl,, [#include <dlfcn.h>], [dladdr (0, 0);])
309   if test "x$HAVE_LIBDL" = "xyes";then
310     enable_self_checks=yes
311
312     AC_DEFINE([ENABLE_FIPS140], 1, [Enable FIPS140-2 mode])
313
314     AC_SUBST([FIPS140_LIBS], $LIBDL)
315   else
316     enable_fips=no
317     AC_MSG_WARN([[
318 *** 
319 *** This system is not supported in FIPS140 mode.
320 *** libdl and dladdr() are required.
321 *** ]])
322   fi
323 fi
324
325 PKG_CHECK_MODULES(LIBIDN, libidn >= 0.5.6, [with_libidn=yes], [with_libidn=no])
326 if test "$with_libidn" != "no";then
327         AC_DEFINE([HAVE_LIBIDN], 1, [Build IDNA support])
328         if test "x$GNUTLS_REQUIRES_PRIVATE" = "x"; then
329                 GNUTLS_REQUIRES_PRIVATE="Requires.private: libidn"
330         else
331                 GNUTLS_REQUIRES_PRIVATE="${GNUTLS_REQUIRES_PRIVATE}, libidn"
332         fi
333 else
334         with_libidn=no
335         AC_MSG_WARN([[
336 *** 
337 *** libidn was not found. IDNA support will be disabled.
338 *** ]])
339 fi
340
341 AM_CONDITIONAL(HAVE_LIBIDN, test "$with_libidn" != "no")
342
343 AC_ARG_ENABLE(non-suiteb-curves,
344   AS_HELP_STRING([--disable-non-suiteb-curves], [disable curves not in SuiteB]),
345     enable_non_suiteb=$enableval, enable_non_suiteb=yes)
346 if [ test "$enable_non_suiteb" = "yes" ];then
347   AC_DEFINE([ENABLE_NON_SUITEB_CURVES], 1, [Enable all curves])
348 fi
349
350 AM_CONDITIONAL(ENABLE_SELF_CHECKS, test "$enable_self_checks" = "yes")
351 if [ test "$enable_self_checks" = "yes" ];then
352    AC_DEFINE([ENABLE_SELF_CHECKS], 1, [Self checks are included in the library])
353 fi
354
355 AC_MSG_CHECKING([whether to build libdane])
356 AC_ARG_ENABLE(libdane,
357     AS_HELP_STRING([--disable-libdane],
358                    [disable the built of libdane]),
359     enable_dane=$enableval, enable_dane=yes)
360 AC_MSG_RESULT($enable_dane)
361
362 if test "$enable_dane" != "no"; then
363     LIBS="$oldlibs -lunbound"
364     AC_MSG_CHECKING([for unbound library])
365     AC_LINK_IFELSE([AC_LANG_PROGRAM([
366                    #include <unbound.h>],[
367                    struct ub_ctx* ctx;
368                    ctx = ub_ctx_create();])],
369                   [AC_MSG_RESULT(yes)
370                    AC_SUBST([UNBOUND_LIBS], [-lunbound])
371                    AC_SUBST([UNBOUND_CFLAGS], [])
372                    AC_DEFINE([HAVE_DANE], 1, [Enable the DANE library])
373                    enable_dane=yes],
374                   [AC_MSG_RESULT(no)
375                    AC_MSG_WARN([[
376 *** 
377 *** libunbound was not found. Libdane will not be built.
378 *** ]])
379                   enable_dane=no])
380     LIBS="$oldlibs"
381 fi
382
383 AM_CONDITIONAL(ENABLE_DANE, test "$enable_dane" = "yes")
384
385 AC_ARG_WITH(unbound-root-key-file, AS_HELP_STRING([--with-unbound-root-key-file],
386                                  [specify the unbound root key file]),
387             unbound_root_key_file="$withval", 
388 if test "$have_win" = yes; then
389     unbound_root_key_file="C:\\Program Files\\Unbound\\root.key"
390 else
391     if test -f /var/lib/unbound/root.key;then
392         unbound_root_key_file="/var/lib/unbound/root.key"
393     else
394         unbound_root_key_file="/etc/unbound/root.key"
395     fi
396 fi
397 )
398
399 AC_DEFINE_UNQUOTED([UNBOUND_ROOT_KEY_FILE],
400   ["$unbound_root_key_file"], [The DNSSEC root key file])
401
402 AC_ARG_WITH(system-priority-file, AS_HELP_STRING([--with-system-priority-file],
403                                  [specify the system priority file]),
404             system_priority_file="$withval", 
405 system_priority_file="/etc/gnutls/default-priorities"
406 )
407
408 AC_DEFINE_UNQUOTED([SYSTEM_PRIORITY_FILE],
409   ["$system_priority_file"], [The system priority file])
410
411
412 dnl Check for p11-kit
413 P11_KIT_MINIMUM=0.20.7
414 AC_ARG_WITH(p11-kit,
415         AS_HELP_STRING([--without-p11-kit],
416                 [Build without p11-kit and PKCS#11 support]))
417 if test "$with_p11_kit" != "no"; then
418         PKG_CHECK_MODULES(P11_KIT, [p11-kit-1 >= $P11_KIT_MINIMUM], [with_p11_kit=yes], [with_p11_kit=no])
419         if test "$with_p11_kit" != "no";then
420                 AC_DEFINE([ENABLE_PKCS11], 1, [Build PKCS#11 support])
421                 if test "x$GNUTLS_REQUIRES_PRIVATE" = "x"; then
422                         GNUTLS_REQUIRES_PRIVATE="Requires.private: p11-kit-1"
423                 else
424                         GNUTLS_REQUIRES_PRIVATE="${GNUTLS_REQUIRES_PRIVATE}, p11-kit-1"
425                 fi
426         else
427                 with_p11_kit=no
428                 AC_MSG_ERROR([[
429 *** 
430 *** p11-kit >= $P11_KIT_MINIMUM was not found. To disable PKCS #11 support 
431 *** use --without-p11-kit, otherwise you may get p11-kit from
432 *** http://p11-glue.freedesktop.org/p11-kit.html
433 *** ]])
434         fi
435 fi
436
437 AM_CONDITIONAL(ENABLE_PKCS11, test "$with_p11_kit" != "no")
438
439 AC_ARG_WITH(tpm,
440         AS_HELP_STRING([--without-tpm],
441                 [Disable TPM (trousers) support.]),
442                 [with_tpm=$withval], [with_tpm=yes])
443 if test "$with_tpm" != "no"; then
444     LIBS="$oldlibs -ltspi"
445     AC_MSG_CHECKING([for tss library])
446     AC_LINK_IFELSE([AC_LANG_PROGRAM([
447                    #include <trousers/tss.h>
448                    #include <trousers/trousers.h>],[
449                    int err = Tspi_Context_Create((void *)0);
450                    Trspi_Error_String(err);])],
451                   [AC_MSG_RESULT(yes)
452                    AC_SUBST([TSS_LIBS], [-ltspi])
453                    AC_SUBST([TSS_CFLAGS], [])
454                    AC_DEFINE([HAVE_TROUSERS], 1, [Enable TPM])
455                    with_tpm=yes],
456                   [AC_MSG_RESULT(no)
457                    AC_MSG_WARN([[
458 *** 
459 *** trousers was not found. TPM support will be disabled.
460 *** ]])
461                   with_tpm=no])
462     LIBS="$oldlibs"
463 fi
464
465 AM_CONDITIONAL(ENABLE_TROUSERS, test "$with_tpm" != "no")
466
467 LIBOPTS_CHECK([src/libopts])
468 if test "$NEED_LIBOPTS_DIR" = "true";then
469         dnl replace libopts-generated files with distributed backups, if present
470         missing_baks=
471         for i in ${srcdir}/src/*-args.c.bak ${srcdir}/src/*-args.h.bak; do
472                 nam=`echo $i|sed 's/.bak//g'`
473                 if test -f $i;then
474                         cp -f $i $nam
475                 else
476                         missing_baks=true
477                 fi
478         done
479         if test -z "$missing_baks"; then
480                 AC_SUBST([AUTOGEN], [/bin/true])
481         fi
482         enable_local_libopts=yes
483 else
484         enable_local_libopts=no
485 fi
486 AM_CONDITIONAL(NEED_LIBOPTS, test "$enable_local_libopts" = "yes")
487
488 AC_CHECK_TYPE(ssize_t,
489   [
490     DEFINE_SSIZE_T="#include <sys/types.h>"
491     AC_SUBST(DEFINE_SSIZE_T)
492   ], [
493     AC_DEFINE([NO_SSIZE_T], 1, [no ssize_t type was found])
494     DEFINE_SSIZE_T="typedef int ssize_t;"
495     AC_SUBST(DEFINE_SSIZE_T)
496   ], [
497     #include <sys/types.h>
498   ])
499
500 # For minitasn1.
501 AC_CHECK_SIZEOF(unsigned long int, 4)
502 AC_CHECK_SIZEOF(unsigned int, 4)
503
504 AC_ARG_WITH(zlib, AS_HELP_STRING([--without-zlib],
505                                  [disable zlib compression support]),
506             ac_zlib=$withval, ac_zlib=yes)
507 AC_MSG_CHECKING([whether to include zlib compression support])
508 if test x$ac_zlib != xno; then
509  AC_MSG_RESULT(yes)
510  AC_LIB_HAVE_LINKFLAGS(z,, [#include <zlib.h>], [compress (0, 0, 0, 0);])
511  if test x$ac_cv_libz != xyes; then
512    AC_MSG_WARN(
513 *** 
514 *** ZLIB was not found. You will not be able to use ZLIB compression.)
515  fi
516 else
517  AC_MSG_RESULT(no)
518 fi
519
520 PKG_CHECK_EXISTS(zlib, ZLIB_HAS_PKGCONFIG=y, ZLIB_HAS_PKGCONFIG=n)
521
522 if test x$ac_zlib != xno; then
523   if test "$ZLIB_HAS_PKGCONFIG" = "y" ; then
524     if test "x$GNUTLS_REQUIRES_PRIVATE" = x; then
525       GNUTLS_REQUIRES_PRIVATE="Requires.private: zlib"
526     else
527       GNUTLS_REQUIRES_PRIVATE="$GNUTLS_REQUIRES_PRIVATE, zlib"
528     fi
529   fi
530 fi
531 AC_SUBST(GNUTLS_REQUIRES_PRIVATE)
532
533
534
535 AC_ARG_WITH([default-trust-store-pkcs11],
536   [AS_HELP_STRING([--with-default-trust-store-pkcs11=URI],
537     [use the given pkcs11 uri as default trust store])])
538
539 if test "x$with_default_trust_store_pkcs11" != x; then
540   if test "x$with_p11_kit" = xno; then
541     AC_MSG_ERROR([cannot use pkcs11 store without p11-kit])
542   fi
543   AC_DEFINE_UNQUOTED([DEFAULT_TRUST_STORE_PKCS11],
544     ["$with_default_trust_store_pkcs11"], [use the given pkcs11 uri as default trust store])
545 fi
546
547 AC_ARG_WITH([default-trust-store-dir],
548   [AS_HELP_STRING([--with-default-trust-store-dir=DIR],
549     [use the given directory as default trust store])])
550
551 if test "x$with_default_trust_store_dir" != x; then
552   AC_DEFINE_UNQUOTED([DEFAULT_TRUST_STORE_DIR],
553     ["$with_default_trust_store_dir"], [use the given directory as default trust store])
554 fi
555
556 dnl auto detect http://lists.gnu.org/archive/html/help-gnutls/2012-05/msg00004.html
557 AC_ARG_WITH([default-trust-store-file],
558   [AS_HELP_STRING([--with-default-trust-store-file=FILE],
559     [use the given file default trust store])], with_default_trust_store_file="$withval",
560   [if test "$build" = "$host" && test x$with_default_trust_store_pkcs11 = x && test x$with_default_trust_store_dir = x;then
561   for i in \
562     /etc/ssl/ca-bundle.pem \
563     /etc/ssl/certs/ca-certificates.crt \
564     /etc/pki/tls/cert.pem \
565     /usr/local/share/certs/ca-root-nss.crt \
566     /etc/ssl/cert.pem
567     do
568     if test -e "$i"; then
569       with_default_trust_store_file="$i"
570       break
571     fi
572   done
573   fi]
574 )
575
576 if test "$with_default_trust_store_file" = "no";then
577   with_default_trust_store_file=""
578 fi
579
580 AC_ARG_WITH([default-crl-file],
581   [AS_HELP_STRING([--with-default-crl-file=FILE],
582     [use the given CRL file as default])])
583
584 AC_ARG_WITH([default-blacklist-file],
585   [AS_HELP_STRING([--with-default-blacklist-file=FILE],
586     [use the given certificate blacklist file as default])])
587
588 if test "x$with_default_trust_store_file" != x; then
589   AC_DEFINE_UNQUOTED([DEFAULT_TRUST_STORE_FILE],
590     ["$with_default_trust_store_file"], [use the given file default trust store])
591 fi
592
593 if test "x$with_default_crl_file" != x; then
594   AC_DEFINE_UNQUOTED([DEFAULT_CRL_FILE],
595     ["$with_default_crl_file"], [use the given CRL file])
596 fi
597
598 if test "x$with_default_blacklist_file" != x; then
599   AC_DEFINE_UNQUOTED([DEFAULT_BLACKLIST_FILE],
600     ["$with_default_blacklist_file"], [use the given certificate blacklist file])
601 fi
602
603 dnl Guile bindings.
604 opt_guile_bindings=yes
605 AC_MSG_CHECKING([whether building Guile bindings])
606 AC_ARG_ENABLE(guile,
607         AS_HELP_STRING([--enable-guile], [build GNU Guile bindings]),
608 opt_guile_bindings=$enableval)
609 AC_MSG_RESULT($opt_guile_bindings)
610
611 AC_ARG_WITH([guile-site-dir],
612   [AS_HELP_STRING([--with-guile-site-dir],
613      [use the given directory as the Guile site (use with care)])])
614
615 if test "$opt_guile_bindings" = "yes"; then
616    AC_MSG_RESULT([***
617 *** Detecting GNU Guile...
618 ])
619
620    AC_PATH_PROG([guile_snarf], [guile-snarf])
621    if test "x$guile_snarf" = "x"; then
622       AC_MSG_WARN([`guile-snarf' from Guile 1.8 not found.  Guile bindings not built.])
623       opt_guile_bindings=no
624    else
625       GUILE_PROGS
626       GUILE_FLAGS
627
628       save_CFLAGS="$CFLAGS"
629       save_LIBS="$LIBS"
630       CFLAGS="$CFLAGS $GUILE_CFLAGS"
631       LIBS="$LIBS $GUILE_LDFLAGS"
632       AC_MSG_CHECKING([whether GNU Guile is recent enough])
633       AC_LINK_IFELSE([AC_LANG_PROGRAM([], [scm_from_locale_string ("")])],
634         [], [opt_guile_bindings=no])
635       CFLAGS="$save_CFLAGS"
636       LIBS="$save_LIBS"
637
638       if test "$opt_guile_bindings" = "yes"; then
639         AC_MSG_RESULT([yes])
640         case "x$with_guile_site_dir" in 
641              xno)
642                 # Use the default $(GUILE_SITE).
643                 GUILE_SITE_DIR
644                 ;;
645              x|xyes)
646                 # Automatically derive $(GUILE_SITE) from $(pkgdatadir).  This
647                 # hack is used to allow `distcheck' to work (see
648                 # `DISTCHECK_CONFIGURE_FLAGS' in the top-level `Makefile.am').
649                 GUILE_SITE="\$(datadir)/guile/site"
650                 AC_SUBST(GUILE_SITE)
651                 ;;
652              *)
653                 # Use the user-specified directory as $(GUILE_SITE).
654                 GUILE_SITE="$with_guile_site_dir"
655                 AC_SUBST(GUILE_SITE)
656                 ;;
657         esac
658         AC_MSG_CHECKING([whether gcc supports -fgnu89-inline])
659         _gcc_cflags_save="$CFLAGS"
660         CFLAGS="${CFLAGS} -fgnu89-inline"
661         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
662                           gnu89_inline=yes, gnu89_inline=no)
663         AC_MSG_RESULT($gnu89_inline)
664         CFLAGS="$_gcc_cflags_save"
665
666         # Optional Guile functions.
667         save_CFLAGS="$CFLAGS"
668         save_LIBS="$LIBS"
669         CFLAGS="$CFLAGS $GUILE_CFLAGS"
670         LIBS="$LIBS $GUILE_LDFLAGS"
671         AC_CHECK_FUNCS([scm_gc_malloc_pointerless])
672         CFLAGS="$save_CFLAGS"
673         LIBS="$save_LIBS"
674
675         # The place where guile-gnutls.la will go.
676         AC_MSG_CHECKING([the Guile effective version])
677         guile_effective_version="`$GUILE -c '(display (effective-version))'`"
678         AC_MSG_RESULT([$guile_effective_version])
679         guileextensiondir="$libdir/guile/$guile_effective_version"
680         AC_SUBST([guileextensiondir])
681       else
682         AC_MSG_RESULT([no])
683         AC_MSG_WARN([A sufficiently recent GNU Guile not found.  Guile bindings not built.])
684         opt_guile_bindings=no
685       fi
686    fi
687 fi
688 AM_CONDITIONAL(HAVE_GUILE, test "$opt_guile_bindings" = "yes")
689
690 LIBGNUTLS_LIBS="-L${libdir} -lgnutls $LIBS"
691 LIBGNUTLS_CFLAGS="-I${includedir}"
692 AC_SUBST(LIBGNUTLS_LIBS)
693 AC_SUBST(LIBGNUTLS_CFLAGS)
694
695 AM_CONDITIONAL(NEEDS_LIBRT, test "$gnutls_needs_librt" = "yes")
696
697 AC_DEFINE([GNUTLS_COMPAT_H], 1, [Make sure we don't use old features in code.])
698 AC_DEFINE([GNUTLS_INTERNAL_BUILD], 1, [We allow temporarily usage of deprecated functions - until they are removed.])
699
700 AC_DEFINE([fread_file], [_gnutls_fread_file], [static lib rename])
701 AC_DEFINE([read_file], [_gnutls_read_file], [static lib rename])
702 AC_DEFINE([read_binary_file], [_gnutls_read_binary_file], [static lib rename])
703
704 dnl Crywrap dependencies
705    AC_MSG_RESULT([***
706 *** Checking dependencies for crywrap...
707 ])
708
709 crywrap=no
710
711 if test "$have_win" != "yes"; then
712
713 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/select.h sys/types.h sys/wait.h])
714
715 dnl **********************
716 dnl * Typedefs & co
717 dnl **********************
718 AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
719 [AC_LANG_PROGRAM([#include <sys/types.h>
720 #include <signal.h>
721 ],
722                  [return *(signal (0, 0)) (0) == 1;])],
723                    [ac_cv_type_signal=int],
724                    [ac_cv_type_signal=void])])
725 AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
726                     (`int' or `void').])
727
728 AC_FUNC_SELECT_ARGTYPES
729 AC_CHECK_FUNCS([alarm atexit dup2 epoll_create kqueue memchr memset munmap \
730                 putenv regcomp scandir select socket strcasecmp strchr \
731                 strdup strerror strncasecmp strrchr strstr strtoul uname])
732
733 AC_ARG_ENABLE(crywrap,
734         AS_HELP_STRING([--disable-crywrap], [unconditionally disable the crywrap TLS proxy service]))
735
736
737  if test "x$enable_crywrap" != "xno" ; then
738         AC_CHECK_FUNCS([argp_usage],[ac_argp=yes],[ac_argp=no])
739  fi
740
741  if test "$ac_cv_func_daemon" != "no" && test "$ac_argp" != "no" && test "$with_libidn" != "no";then
742   crywrap=yes
743  fi
744
745 fi
746
747 AM_CONDITIONAL(ENABLE_CRYWRAP, test "x$crywrap" != "xno")
748
749 dnl end of crywrap requirements
750
751 dnl Some variables needed in makefiles
752 YEAR=`date +%Y`
753 AC_SUBST([YEAR], $YEAR)
754
755 AC_CONFIG_FILES([guile/pre-inst-guile], [chmod +x guile/pre-inst-guile])
756 AC_CONFIG_FILES([
757   Makefile
758   doc/Makefile
759   doc/credentials/Makefile
760   doc/credentials/openpgp/Makefile
761   doc/credentials/srp/Makefile
762   doc/credentials/x509/Makefile
763   doc/cyclo/Makefile
764   doc/doxygen/Doxyfile
765   doc/examples/Makefile
766   doc/latex/Makefile
767   doc/manpages/Makefile
768   doc/reference/Makefile
769   doc/reference/version.xml
770   doc/scripts/Makefile
771   extra/Makefile
772   extra/includes/Makefile
773   libdane/Makefile
774   libdane/includes/Makefile
775   libdane/gnutls-dane.pc
776   gl/Makefile
777   gl/tests/Makefile
778   guile/Makefile
779   guile/modules/Makefile
780   guile/src/Makefile
781   guile/tests/Makefile
782   lib/Makefile
783   lib/accelerated/Makefile
784   lib/accelerated/x86/Makefile
785   lib/algorithms/Makefile
786   lib/auth/Makefile
787   lib/ext/Makefile
788   lib/extras/Makefile
789   lib/gnutls.pc
790   lib/includes/Makefile
791   lib/includes/gnutls/gnutls.h
792   lib/minitasn1/Makefile
793   lib/nettle/Makefile
794   lib/opencdk/Makefile
795   lib/openpgp/Makefile
796   lib/x509/Makefile
797   po/Makefile.in
798   src/Makefile
799   src/crywrap/Makefile
800   src/gl/Makefile
801   tests/Makefile
802   tests/cert-tests/Makefile
803   tests/dsa/Makefile
804   tests/dtls/Makefile
805   tests/srp/Makefile
806   tests/ecdsa/Makefile
807   tests/key-tests/Makefile
808   tests/openpgp-certs/Makefile
809   tests/pkcs1-padding/Makefile
810   tests/pkcs12-decode/Makefile
811   tests/pkcs8-decode/Makefile
812   tests/rsa-md5-collision/Makefile
813   tests/safe-renegotiation/Makefile
814   tests/scripts/Makefile
815   tests/sha2/Makefile
816   tests/slow/Makefile
817   tests/suite/Makefile
818   tests/userid/Makefile
819 ])
820
821 AC_OUTPUT
822
823 dnl  Warning flags:        errors: ${WERROR_CFLAGS} warnings: ${WARN_CFLAGS}
824 dnl  Valgrind:             $opt_valgrind_tests ${VALGRIND}
825 AC_MSG_NOTICE([summary of build options:
826
827   version:              ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE
828   Host/Target system:   ${host}
829   Build system:         ${build}
830   Install prefix:       ${prefix}
831   Compiler:             ${CC}
832   CFlags:               ${CFLAGS}
833   Library types:        Shared=${enable_shared}, Static=${enable_static}
834   Local libopts:        ${enable_local_libopts}
835   Local libtasn1:       ${included_libtasn1}
836   Use nettle-mini:      ${mini_nettle}
837 ])
838
839 AC_MSG_NOTICE([External hardware support:
840
841   /dev/crypto:          $enable_cryptodev
842   Hardware accel:       $hw_accel
843   Padlock accel:        $use_padlock
844   PKCS#11 support:      $with_p11_kit
845   TPM support:          $with_tpm
846 ])
847
848 AC_MSG_NOTICE([Optional features:
849 (note that included applications might not compile properly
850 if features are disabled)
851
852   DTLS-SRTP support:    $ac_enable_srtp
853   ALPN support:         $ac_enable_alpn
854   OCSP support:         $ac_enable_ocsp
855   Ses. ticket support:  $ac_enable_session_tickets
856   OpenPGP support:      $ac_enable_openpgp
857   SRP support:          $ac_enable_srp
858   PSK support:          $ac_enable_psk
859   DHE support:          $ac_enable_dhe
860   ECDHE support:        $ac_enable_ecdhe
861   RSA-EXPORT support:   $ac_enable_rsa_export
862   Anon auth support:    $ac_enable_anon
863   Heartbeat support:    $ac_enable_heartbeat
864   IDNA support:         $libidn
865   Unicode support:      $ac_have_unicode
866   Self checks:          $enable_self_checks
867   Non-SuiteB curves:    $enable_non_suiteb
868   FIPS140 mode:         $enable_fips
869 ])
870
871 AC_MSG_NOTICE([Optional applications:
872
873   crywrap app:          $crywrap
874 ])
875
876 AC_MSG_NOTICE([Optional libraries:
877
878   Guile wrappers:       $opt_guile_bindings
879   C++ library:          $use_cxx
880   DANE library:         $enable_dane
881   OpenSSL compat:       $enable_openssl
882 ])
883
884 AC_MSG_NOTICE([System files:
885
886   Trust store pkcs11:   $with_default_trust_store_pkcs11
887   Trust store dir:      $with_default_trust_store_dir
888   Trust store file:     $with_default_trust_store_file
889   Blacklist file:       $with_default_blacklist_file
890   CRL file:             $with_default_crl_file
891   Priority file:        $system_priority_file
892   DNSSEC root key file: $unbound_root_key_file
893 ])
894
895 if test ! -f "$unbound_root_key_file"; then
896 AC_MSG_WARN([[
897 *** 
898 *** The DNSSEC root key file in $unbound_root_key_file was not found. 
899 *** This file is needed for the verification of DNSSEC responses.
900 *** Use the command: unbound-anchor -a "$unbound_root_key_file"
901 *** to generate or update it.
902 *** ]])
903 fi