Don't add p11-kit to CFLAGS/LIBS globally, just where it is needed.
[gnutls:gnutls.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2 # Copyright (C) 2000-2011 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.0.7], [bug-gnutls@gnu.org])
25 AC_CONFIG_AUX_DIR([build-aux])
26 AC_CONFIG_MACRO_DIR([m4])
27
28 AM_INIT_AUTOMAKE([1.11 no-dist-gzip dist-xz -Wall -Werror -Wno-override])
29 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
30 AM_CONFIG_HEADER(config.h)
31
32 AC_MSG_RESULT([***
33 *** Checking for compilation programs...
34 ])
35
36 dnl Checks for programs.
37 AC_PROG_CC
38 AM_PROG_AS
39 AC_PROG_CXX
40 gl_EARLY
41
42 # For includes/gnutls/gnutls.h.in.
43 AC_SUBST(MAJOR_VERSION, `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
44 AC_SUBST(MINOR_VERSION, `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
45 AC_SUBST(PATCH_VERSION, `echo $PACKAGE_VERSION | sed 's/.*\..*\.\(.*\)/\1/g'`)
46 AC_SUBST(NUMBER_VERSION, `printf "0x%02x%02x%02x" $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION`)
47
48
49 dnl C and C++ capabilities
50 AC_C_INLINE
51 AC_HEADER_STDC
52 AC_DEFINE([HAVE_STRINGS_H], 1, [Hard-code for src/cfg/.])
53 AC_DEFINE([HAVE_FLOAT_H], 1, [Hard-code for src/cfg/.])
54 AC_DEFINE([HAVE_LIMITS_H], 1, [Hard-code for src/cfg/.])
55 AC_DEFINE([HAVE_MATH_H], 1, [Hard-code for src/cfg/.])
56 AC_DEFINE([HAVE_CTYPE_H], 1, [Hard-code for src/cfg/.])
57 AC_DEFINE([HAVE_ERRNO_H], 1, [Hard-code for src/cfg/.])
58
59 # For the C++ code
60 AC_ARG_ENABLE(cxx,
61   AS_HELP_STRING([--disable-cxx], [unconditionally disable the C++ library]),
62     use_cxx=$enableval, use_cxx=yes)
63 if test "$use_cxx" != "no"; then
64   AC_LANG_PUSH(C++)
65   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], use_cxx=yes, use_cxx=no)
66   AC_LANG_POP(C++)
67 fi
68 AM_CONDITIONAL(ENABLE_CXX, test "$use_cxx" != "no")
69 AM_CONDITIONAL(WANT_TEST_SUITE, [test -f tests/suite/mini-eagain2.c])
70
71 dnl Detect windows build
72 case "$host" in
73   *mingw32* | *mingw64*)
74     have_win=yes
75   ;;
76   *)
77   ;;
78 esac
79
80 AM_CONDITIONAL(WINDOWS, test "$have_win" = yes)
81
82 dnl Hardware Acceleration
83 AC_ARG_ENABLE(hardware-acceleration,
84   AS_HELP_STRING([--disable-hardware-acceleration], [unconditionally disable hardware acceleration]),
85     use_accel=$enableval, use_accel=yes)
86 hw_accel=none
87
88
89 if test "$use_accel" != "no"; then
90 case $host_cpu in
91   i?86 | x86_64 | amd64)
92 dnl    GCC_FLAG_ADD([-maes -mpclmul],[X86])
93 dnl    if test "x$X86" = "xyes";then
94       AC_CHECK_HEADERS(cpuid.h)
95       if test "$host_cpu" = "x86_64" || test "$host_cpu" = "amd64"; then
96         hw_accel="x86-64"
97       else
98         hw_accel="x86"
99       fi
100 dnl    fi
101   ;;
102   *)
103   ;;
104 esac
105
106 fi
107
108 AM_CONDITIONAL(ASM_X86_64, test x"$hw_accel" = x"x86-64")
109 AM_CONDITIONAL(ASM_X86_32, test x"$hw_accel" = x"x86")
110 AM_CONDITIONAL(ASM_X86, test x"$hw_accel" = x"x86" || test x"$hw_accel" = x"x86-64")
111 AM_CONDITIONAL(HAVE_GCC_GNU89_INLINE_OPTION, test "$gnu89_inline" = "yes"])
112 AM_CONDITIONAL(HAVE_GCC, test "$GCC" = "yes")
113
114 dnl Try the hooks.m4
115 LIBGNUTLS_HOOKS
116 LIBGNUTLS_EXTRA_HOOKS
117
118 GTK_DOC_CHECK(1.1)
119 AM_GNU_GETTEXT([external])
120 AM_GNU_GETTEXT_VERSION([0.18])
121
122 AC_C_BIGENDIAN
123
124
125
126 dnl Checks for functions
127
128 dnl No fork on MinGW, disable some self-tests until we fix them.
129 AC_CHECK_FUNCS(fork,,)
130 AM_CONDITIONAL(HAVE_FORK, test "$ac_cv_func_fork" != "no")
131 AC_CHECK_FUNCS(getrusage,,)
132 AC_LIB_HAVE_LINKFLAGS(pthread,, [#include <pthread.h>], [pthread_mutex_lock (0);])
133
134 dnl Check for p11-kit
135 AC_ARG_WITH(p11-kit,
136         AS_HELP_STRING([--without-p11-kit],
137                 [Build without p11-kit and PKCS#11 support]))
138 if test "$with_p11_kit" != "no"; then
139         PKG_CHECK_MODULES(P11_KIT, [p11-kit-1 >= 0.4], [with_p11_kit=yes], [with_p11_kit=no])
140         if test "$with_p11_kit" != "no";then
141                 AC_DEFINE([ENABLE_PKCS11], 1, [Build PKCS#11 support])
142                 if test "x$GNUTLS_REQUIRES_PRIVATE" = "x"; then
143                         GNUTLS_REQUIRES_PRIVATE="Requires.private: p11-kit-1"
144                 else
145                         GNUTLS_REQUIRES_PRIVATE="${GNUTLS_REQUIRES_PRIVATE}, p11-kit-1"
146                 fi
147         else
148                 with_p11_kit=no
149                 AC_MSG_WARN([[
150 *** 
151 *** p11-kit was not found. PKCS #11 support will be disabled.
152 *** You may get it from http://p11-glue.freedesktop.org/p11-kit.html
153 *** ]])
154         fi
155 fi
156
157 AM_CONDITIONAL(ENABLE_PKCS11, test "$with_p11_kit" != "no")
158
159 dnl Check for libcfg+
160 SAVED_LIBS=$LIBS
161 AC_ARG_WITH(included-libcfg,
162         AS_HELP_STRING([--with-included-libcfg],
163                 [use the included libcfg+ (certtool only)]),
164         libcfg_enabled=$withval, 
165         libcfg_enabled=no
166 dnl We search for libcfg+ which is used by certtool
167 dnl
168         AC_CHECK_LIB(cfg+, cfg_get_context,:,
169                      libcfg_enabled=yes
170                      AC_MSG_WARN([[
171 *** 
172 *** Libcfg+ was not found. Will use the included one.]])))
173
174 AM_CONDITIONAL(HAVE_LIBCFG, test "$libcfg_enabled" = "no")
175 LIBS=$SAVED_LIBS
176
177 AC_MSG_CHECKING([whether to use the included libcfg])
178 AC_MSG_RESULT($libcfg_enabled)
179
180 AC_CHECK_TYPE(ssize_t,
181   [
182     DEFINE_SSIZE_T="#include <sys/types.h>"
183     AC_SUBST(DEFINE_SSIZE_T)
184   ], [
185     AC_DEFINE([NO_SSIZE_T], 1, [no ssize_t type was found])
186     DEFINE_SSIZE_T="typedef int ssize_t;"
187     AC_SUBST(DEFINE_SSIZE_T)
188   ], [
189     #include <sys/types.h>
190   ])
191
192 # For minitasn1.
193 AC_CHECK_SIZEOF(unsigned long int, 4)
194 AC_CHECK_SIZEOF(unsigned int, 4)
195
196 AC_ARG_WITH(zlib, AS_HELP_STRING([--without-zlib],
197                                  [disable zlib compression support]),
198             ac_zlib=$withval, ac_zlib=yes)
199 AC_MSG_CHECKING([whether to include zlib compression support])
200 if test x$ac_zlib != xno; then
201  AC_MSG_RESULT(yes)
202  AC_LIB_HAVE_LINKFLAGS(z,, [#include <zlib.h>], [compress (0, 0, 0, 0);])
203  if test x$ac_cv_libz != xyes; then
204    AC_MSG_WARN(
205 *** 
206 *** ZLIB was not found. You will not be able to use ZLIB compression.)
207  fi
208 else
209  AC_MSG_RESULT(no)
210 fi
211
212 PKG_CHECK_EXISTS(zlib, ZLIB_HAS_PKGCONFIG=y, ZLIB_HAS_PKGCONFIG=n)
213
214 if test x$ac_zlib != xno; then
215   if test "$ZLIB_HAS_PKGCONFIG" = "y" ; then
216     if test "x$GNUTLS_REQUIRES_PRIVATE" = x; then
217       GNUTLS_REQUIRES_PRIVATE="Requires.private: zlib"
218     else
219       GNUTLS_REQUIRES_PRIVATE="$GNUTLS_REQUIRES_PRIVATE, zlib"
220     fi
221   else
222     GNUTLS_ZLIB_LIBS_PRIVATE="$LTLIBZ"
223   fi
224 fi
225 AC_SUBST(GNUTLS_REQUIRES_PRIVATE)
226 AC_SUBST(GNUTLS_ZLIB_LIBS_PRIVATE)
227
228
229 gl_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([-Werror], [WERROR_CFLAGS])
246   gl_WARN_ADD([-Wframe-larger-than=5120], [WSTACK_CFLAGS])
247
248   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
249   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
250   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
251   nw="$nw -Wtraditional"            # Warns on #elif which we use often
252   nw="$nw -Wlogical-op"             # Too many false positives
253   nw="$nw -Wold-style-definition"   # 
254   nw="$nw -Wpadded"                 # Our structs are not padded
255   nw="$nw -Wunreachable-code"       # Too many false positives
256   nw="$nw -Wtraditional-conversion" # Too many warnings for now
257   nw="$nw -Wcast-qual"              # Too many warnings for now
258   nw="$nw -Waggregate-return"       # Too many warnings for now
259   nw="$nw -Wshadow"                 # Too many warnings for now
260   nw="$nw -Wswitch-default"         # Too many warnings for now
261   nw="$nw -Wswitch-enum"            # Too many warnings for now
262   nw="$nw -Wconversion"             # Too many warnings for now
263   nw="$nw -Wsign-conversion"        # Too many warnings for now
264   nw="$nw -Wformat-y2k"             # Too many warnings for now
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
271   gl_MANYWARN_ALL_GCC([ws])
272   gl_MANYWARN_COMPLEMENT(ws, [$ws], [$nw])
273   for w in $ws; do
274     gl_WARN_ADD([$w])
275   done
276
277   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
278   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
279   gl_WARN_ADD([-Wno-pointer-sign])     # Too many warnings for now
280   gl_WARN_ADD([-Wno-unused-result]) # warnings for things we don't want to get
281   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
282   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
283   gl_WARN_ADD([-Wno-stack-protector])  # Some functions cannot be protected
284   gl_WARN_ADD([-Wno-int-to-pointer-cast])  # Some files cannot be compiled with that (gl_fd_to_handle)
285   gl_WARN_ADD([-fdiagnostics-show-option])
286 fi
287
288 AC_SUBST([WERROR_CFLAGS])
289 AC_SUBST([WSTACK_CFLAGS])
290 AC_SUBST([WARN_CFLAGS])
291
292 dnl Programs for compilation or development
293 AC_PROG_LN_S
294 AC_LIBTOOL_WIN32_DLL
295 AC_PROG_LIBTOOL
296 AC_PATH_PROG([GAA], [gaa])
297 if test "x$GAA" = "x"; then
298    AC_MSG_WARN([[***
299 *** GAA was not found.  It is only needed if you wish to modify
300 *** the source code or command-line description files.  In this case,
301 *** you may want to get it from http://gaa.sourceforge.net/ and
302 *** read doc/README.gaa.
303 ***]])
304 fi
305
306
307 dnl Guile bindings.
308 opt_guile_bindings=yes
309 AC_MSG_CHECKING([whether building Guile bindings])
310 AC_ARG_ENABLE(guile,
311         AS_HELP_STRING([--enable-guile], [build GNU Guile bindings]),
312 opt_guile_bindings=$enableval)
313 AC_MSG_RESULT($opt_guile_bindings)
314
315 AC_ARG_WITH([--with-guile-site-dir],
316   [AS_HELP_STRING([--with-guile-site-dir],
317      [use the given directory as the Guile site (use with care)])])
318
319 if test "$opt_guile_bindings" = "yes"; then
320    AC_MSG_RESULT([***
321 *** Detecting GNU Guile...
322 ])
323
324    AC_PATH_PROG([guile_snarf], [guile-snarf])
325    if test "x$guile_snarf" = "x"; then
326       AC_MSG_WARN([`guile-snarf' from Guile 1.8 not found.  Guile bindings not built.])
327       opt_guile_bindings=no
328    else
329       GUILE_PROGS
330       GUILE_FLAGS
331
332       save_CFLAGS="$CFLAGS"
333       save_LIBS="$LIBS"
334       CFLAGS="$CFLAGS $GUILE_CFLAGS"
335       LIBS="$LIBS $GUILE_LDFLAGS"
336       AC_MSG_CHECKING([whether GNU Guile is recent enough])
337       AC_LINK_IFELSE(AC_LANG_CALL([], [scm_from_locale_string]),
338         [], [opt_guile_bindings=no])
339       CFLAGS="$save_CFLAGS"
340       LIBS="$save_LIBS"
341
342       if test "$opt_guile_bindings" = "yes"; then
343         AC_MSG_RESULT([yes])
344         case "x$with_guile_site_dir" in 
345              xno)
346                 # Use the default $(GUILE_SITE).
347                 GUILE_SITE_DIR
348                 ;;
349              x|xyes)
350                 # Automatically derive $(GUILE_SITE) from $(pkgdatadir).  This
351                 # hack is used to allow `distcheck' to work (see
352                 # `DISTCHECK_CONFIGURE_FLAGS' in the top-level `Makefile.am').
353                 GUILE_SITE="\$(datadir)/guile/site"
354                 AC_SUBST(GUILE_SITE)
355                 ;;
356              *)
357                 # Use the user-specified directory as $(GUILE_SITE).
358                 GUILE_SITE="$with_guile_site_dir"
359                 AC_SUBST(GUILE_SITE)
360                 ;;
361         esac
362         AC_MSG_CHECKING([whether gcc supports -fgnu89-inline])
363         _gcc_cflags_save="$CFLAGS"
364         CFLAGS="${CFLAGS} -fgnu89-inline"
365         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
366                           gnu89_inline=yes, gnu89_inline=no)
367         AC_MSG_RESULT($gnu89_inline)
368         CFLAGS="$_gcc_cflags_save"
369
370         # Optional Guile functions.
371         save_CFLAGS="$CFLAGS"
372         save_LIBS="$LIBS"
373         CFLAGS="$CFLAGS $GUILE_CFLAGS"
374         LIBS="$LIBS $GUILE_LDFLAGS"
375         AC_CHECK_FUNCS([scm_gc_malloc_pointerless])
376         CFLAGS="$save_CFLAGS"
377         LIBS="$save_LIBS"
378
379         # The place where guile-gnutls.la will go.
380         AC_MSG_CHECKING([the Guile effective version])
381         guile_effective_version="`$GUILE -c '(display (effective-version))'`"
382         AC_MSG_RESULT([$guile_effective_version])
383         guileextensiondir="$libdir/guile/$guile_effective_version"
384         AC_SUBST([guileextensiondir])
385       else
386         AC_MSG_RESULT([no])
387         AC_MSG_WARN([A sufficiently recent GNU Guile not found.  Guile bindings not built.])
388         opt_guile_bindings=no
389       fi
390    fi
391 fi
392 AM_CONDITIONAL(HAVE_GUILE, test "$opt_guile_bindings" = "yes")
393
394 LIBGNUTLS_LIBS="-L${libdir} -lgnutls $LIBS"
395 LIBGNUTLS_CFLAGS="-I${includedir}"
396 AC_SUBST(LIBGNUTLS_LIBS)
397 AC_SUBST(LIBGNUTLS_CFLAGS)
398
399
400 AC_DEFINE([GNUTLS_COMPAT_H], 1, [Make sure we don't use old features in code.])
401 AC_DEFINE([GNUTLS_INTERNAL_BUILD], 1, [We allow temporarily usage of deprecated functions - until they are removed.])
402
403 AC_DEFINE([fread_file], [_gnutls_fread_file], [static lib rename])
404 AC_DEFINE([read_file], [_gnutls_read_file], [static lib rename])
405 AC_DEFINE([read_binary_file], [_gnutls_read_binary_file], [static lib rename])
406
407 dnl Crywrap dependencies
408    AC_MSG_RESULT([***
409 *** Checking dependencies for crywrap...
410 ])
411
412 AC_CHECK_HEADERS([arpa/inet.h netinet/in.h sys/select.h sys/types.h sys/wait.h])
413
414 dnl **********************
415 dnl * Typedefs & co
416 dnl **********************
417 AC_CACHE_CHECK([return type of signal handlers],[ac_cv_type_signal],[AC_COMPILE_IFELSE(
418 [AC_LANG_PROGRAM([#include <sys/types.h>
419 #include <signal.h>
420 ],
421                  [return *(signal (0, 0)) (0) == 1;])],
422                    [ac_cv_type_signal=int],
423                    [ac_cv_type_signal=void])])
424 AC_DEFINE_UNQUOTED([RETSIGTYPE],[$ac_cv_type_signal],[Define as the return type of signal handlers
425                     (`int' or `void').])
426
427 AC_FUNC_SELECT_ARGTYPES
428 AC_CHECK_FUNCS([alarm atexit dup2 epoll_create kqueue memchr memset munmap \
429                 putenv regcomp scandir select socket strcasecmp strchr \
430                 strdup strerror strncasecmp strrchr strstr strtoul uname])
431
432 PKG_CHECK_MODULES(LIBIDN, libidn >= 0.0.0, [libidn=yes], [libidn=no])
433
434 AM_CONDITIONAL(ENABLE_CRYWRAP, test "x$libidn" != "xno")
435
436 dnl end of crywrap requirements
437
438 AC_CONFIG_FILES([guile/pre-inst-guile], [chmod +x guile/pre-inst-guile])
439 AC_CONFIG_FILES([
440   Makefile
441   doc/Makefile
442   doc/credentials/Makefile
443   doc/credentials/openpgp/Makefile
444   doc/credentials/srp/Makefile
445   doc/credentials/x509/Makefile
446   doc/cyclo/Makefile
447   doc/latex/Makefile
448   doc/doxygen/Doxyfile
449   doc/examples/Makefile
450   doc/manpages/Makefile
451   doc/reference/Makefile
452   doc/scripts/Makefile
453   gl/Makefile
454   gl/tests/Makefile
455   guile/Makefile
456   guile/modules/Makefile
457   guile/src/Makefile
458   guile/tests/Makefile
459   src/Makefile
460   src/crywrap/Makefile
461   src/cfg/Makefile
462   src/cfg/platon/Makefile
463   src/cfg/platon/str/Makefile
464   tests/Makefile
465   tests/key-id/Makefile
466   tests/dsa/Makefile
467   tests/scripts/Makefile
468   tests/openpgp-certs/Makefile
469   tests/safe-renegotiation/Makefile
470   tests/pathlen/Makefile
471   tests/pkcs1-padding/Makefile
472   tests/pkcs12-decode/Makefile
473   tests/pkcs8-decode/Makefile
474   tests/rsa-md5-collision/Makefile
475   tests/sha2/Makefile
476   tests/userid/Makefile
477   extra/Makefile
478   extra/includes/Makefile
479   lib/Makefile
480   lib/gnutls.pc
481   lib/includes/Makefile
482   lib/includes/gnutls/gnutls.h
483   lib/minitasn1/Makefile
484   lib/opencdk/Makefile
485   lib/openpgp/Makefile
486   po/Makefile.in
487   lib/x509/Makefile
488   lib/nettle/Makefile
489   tests/suite/Makefile
490   lib/accelerated/Makefile
491   lib/accelerated/x86/Makefile
492   lib/ext/Makefile
493   lib/algorithms/Makefile
494   lib/auth/Makefile
495 ])
496
497 AC_OUTPUT
498
499 AC_MSG_NOTICE([summary of build options:
500
501   version:          ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE
502   Host type:        ${host}
503   Install prefix:   ${prefix}
504   Compiler:         ${CC}
505   CFlags:           ${CFLAGS}
506   Warning flags:    errors: ${WERROR_CFLAGS} warnings: ${WARN_CFLAGS}
507   Library types:    Shared=${enable_shared}, Static=${enable_static}
508   Valgrind:         $opt_valgrind_tests ${VALGRIND}
509   Guile wrappers:   $opt_guile_bindings
510   C++ library:      $use_cxx
511   OpenSSL compat:   $enable_openssl
512   /dev/crypto:      $enable_cryptodev
513   Hardware accel:   $hw_accel
514   Crypto library:   $cryptolib
515   PKCS#11 support:  $with_p11_kit
516   crywrap app:      $libidn
517 ])