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