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