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