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