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