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