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