agent/
[gnupg.git] / configure.ac
blob42f4857daec7f84e54516a59723c2b7737c68805
1 # configure.ac - for GnuPG 2.1
2 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 #               2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4
5 # This file is part of GnuPG.
6
7 # GnuPG is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11
12 # GnuPG is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, see <http://www.gnu.org/licenses/>.
20 # Process this file with autoconf to produce a configure script.
21 AC_PREREQ(2.61)
22 min_automake_version="1.10"
24 # Remember to change the version number immediately *after* a release.
25 # Set my_issvn to "yes" for non-released code.  Remember to run an
26 # "svn up" and "autogen.sh" right before creating a distribution.
27 m4_define([my_version], [2.1.0])
28 m4_define([my_issvn], [yes])
30 m4_define([svn_revision], m4_esyscmd([printf "%d" $(svn info 2>/dev/null \
31           | sed -n '/^Revision:/ s/[^0-9]//gp'|head -1)]))
32 AC_INIT([gnupg], 
33         [my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision])],
34         [http://bugs.gnupg.org])
35 # Set development_version to yes if the minor number is odd or you
36 # feel that the default check for a development version is not
37 # sufficient.
38 development_version=no
40 NEED_GPG_ERROR_VERSION=1.4
42 NEED_LIBGCRYPT_API=1
43 NEED_LIBGCRYPT_VERSION=1.4.0
45 NEED_LIBASSUAN_API=2
46 NEED_LIBASSUAN_VERSION=1.1.0
48 NEED_KSBA_API=1
49 NEED_KSBA_VERSION=1.0.2
52 PACKAGE=$PACKAGE_NAME
53 PACKAGE_GT=${PACKAGE_NAME}2
54 VERSION=$PACKAGE_VERSION
56 AC_CONFIG_AUX_DIR(scripts)
57 AC_CONFIG_SRCDIR(sm/gpgsm.c)
58 AM_CONFIG_HEADER(config.h)
59 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
60 AC_CANONICAL_HOST
61 AB_INIT
63 AC_GNU_SOURCE
65 # Some status variables.
66 have_gpg_error=no
67 have_libgcrypt=no 
68 have_libassuan=no
69 have_ksba=no
70 have_pth=no
71 have_libusb=no
72 have_adns=no
74 use_bzip2=yes
75 use_exec=yes
76 disable_keyserver_path=no
79 GNUPG_BUILD_PROGRAM(gpg, yes)
80 GNUPG_BUILD_PROGRAM(gpgsm, yes)
81 GNUPG_BUILD_PROGRAM(agent, yes)
82 GNUPG_BUILD_PROGRAM(scdaemon, yes)
83 GNUPG_BUILD_PROGRAM(g13, yes)
84 GNUPG_BUILD_PROGRAM(tools, yes)
85 GNUPG_BUILD_PROGRAM(doc, yes)
86 GNUPG_BUILD_PROGRAM(symcryptrun, no)
88 AC_SUBST(PACKAGE)
89 AC_SUBST(PACKAGE_GT)
90 AC_SUBST(VERSION)
91 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
92 AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT",
93                                 [Name of this package for gettext])
94 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
95 AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
96                                         [Bug report address])
97 AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION",
98                                        [Required version of Libgcrypt])
99 AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION",
100                                        [Required version of Libksba])
104 # The default is to use the modules from this package and the few
105 # other packages in a standard place; i.e where this package gets
106 # installed.  With these options it is possible to override these
107 # ${prefix} depended values with fixed paths, which can't be replaced
108 # at make time.  See also am/cmacros.am and the defaults in AH_BOTTOM.
109 AC_ARG_WITH(agent-pgm,
110     [  --with-agent-pgm=PATH  Use PATH as the default for the agent)],
111           GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" )
112 AC_SUBST(GNUPG_AGENT_PGM)
113 AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM")
114 show_gnupg_agent_pgm="(default)"
115 test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM"
117 AC_ARG_WITH(pinentry-pgm,
118     [  --with-pinentry-pgm=PATH  Use PATH as the default for the pinentry)],
119           GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" )
120 AC_SUBST(GNUPG_PINENTRY_PGM)
121 AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM")
122 show_gnupg_pinentry_pgm="(default)"
123 test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM"
126 AC_ARG_WITH(scdaemon-pgm,
127     [  --with-scdaemon-pgm=PATH  Use PATH as the default for the scdaemon)],
128           GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" )
129 AC_SUBST(GNUPG_SCDAEMON_PGM)
130 AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM")
131 show_gnupg_scdaemon_pgm="(default)"
132 test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM"
135 AC_ARG_WITH(dirmngr-pgm,
136     [  --with-dirmngr-pgm=PATH  Use PATH as the default for the dirmngr)],
137           GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" )
138 AC_SUBST(GNUPG_DIRMNGR_PGM)
139 AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM")
140 show_gnupg_dirmngr_pgm="(default)"
141 test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM"
143 AC_ARG_WITH(protect-tool-pgm,
144     [  --with-protect-tool-pgm=PATH  Use PATH as the default for the protect-tool)],
145           GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" )
146 AC_SUBST(GNUPG_PROTECT_TOOL_PGM)
147 AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM")
148 show_gnupg_protect_tool_pgm="(default)"
149 test -n "$GNUPG_PROTECT_TOOL_PGM" \
150       && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM"
153 # Some folks want to use only the agent from this packet.  Make it
154 # easier for them by providing the configure option
155 # --enable-only-agent.
156 AC_ARG_ENABLE(agent-only,
157     AC_HELP_STRING([--enable-agent-only],[build only the gpg-agent]),
158     build_agent_only=$enableval)
160 # SELinux support includes tracking of sensitive files to avoid
161 # leaking their contents through processing these files by gpg itself
162 AC_MSG_CHECKING([whether SELinux support is requested])
163 AC_ARG_ENABLE(selinux-support,
164               AC_HELP_STRING([--enable-selinux-support],
165                              [enable SELinux support]),
166               selinux_support=$enableval, selinux_support=no)
167 AC_MSG_RESULT($selinux_support)
169 # Allow disabling of bzib2 support.
170 # It is defined only after we confirm the library is available later
171 AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm])
172 AC_ARG_ENABLE(bzip2,
173    AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]),
174    use_bzip2=$enableval)
175 AC_MSG_RESULT($use_bzip2)
177 # Configure option to allow or disallow execution of external
178 # programs, like a photo viewer.
179 AC_MSG_CHECKING([whether to enable external program execution])
180 AC_ARG_ENABLE(exec,
181     AC_HELP_STRING([--disable-exec],[disable all external program execution]),
182     use_exec=$enableval)
183 AC_MSG_RESULT($use_exec)
184 if test "$use_exec" = no ; then
185     AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution])
188 if test "$use_exec" = yes ; then
189   AC_MSG_CHECKING([whether to enable photo ID viewing])
190   AC_ARG_ENABLE(photo-viewers,
191       [  --disable-photo-viewers disable photo ID viewers],
192       [if test "$enableval" = no ; then
193          AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing])
194       fi],enableval=yes)
195   gnupg_cv_enable_photo_viewers=$enableval
196   AC_MSG_RESULT($enableval)
198   if test "$gnupg_cv_enable_photo_viewers" = yes ; then
199     AC_MSG_CHECKING([whether to use a fixed photo ID viewer])
200     AC_ARG_WITH(photo-viewer,
201         [  --with-photo-viewer=FIXED_VIEWER  set a fixed photo ID viewer],
202         [if test "$withval" = yes ; then
203            withval=no
204         elif test "$withval" != no ; then
205            AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval",
206                             [if set, restrict photo-viewer to this])
207         fi],withval=no)
208     AC_MSG_RESULT($withval)
209   fi
211   AC_MSG_CHECKING([whether to enable external keyserver helpers])
212   AC_ARG_ENABLE(keyserver-helpers,
213       [  --disable-keyserver-helpers  disable all external keyserver support],
214       [if test "$enableval" = no ; then
215          AC_DEFINE(DISABLE_KEYSERVER_HELPERS,1,
216                   [define to disable keyserver helpers])
217       fi],enableval=yes)
218   gnupg_cv_enable_keyserver_helpers=$enableval
219   AC_MSG_RESULT($enableval)
221   if test "$gnupg_cv_enable_keyserver_helpers" = yes ; then
222     # LDAP is defined only after we confirm the library is available later
223     AC_MSG_CHECKING([whether LDAP keyserver support is requested])
224     AC_ARG_ENABLE(ldap,
225       AC_HELP_STRING([--disable-ldap],[disable LDAP keyserver interface only]),
226       try_ldap=$enableval, try_ldap=yes)
227     AC_MSG_RESULT($try_ldap)
229     AC_MSG_CHECKING([whether HKP keyserver support is requested])
230     AC_ARG_ENABLE(hkp,
231       AC_HELP_STRING([--disable-hkp],[disable HKP keyserver interface only]),
232       try_hkp=$enableval, try_hkp=yes)
233     AC_MSG_RESULT($try_hkp)
235     AC_MSG_CHECKING([whether finger key fetching support is requested])
236     AC_ARG_ENABLE(finger,
237       AC_HELP_STRING([--disable-finger],
238         [disable finger key fetching interface only]),
239       try_finger=$enableval, try_finger=yes)
240     AC_MSG_RESULT($try_finger)
242     AC_MSG_CHECKING([whether generic object key fetching support is requested])
243     AC_ARG_ENABLE(generic,
244       AC_HELP_STRING([--disable-generic],
245         [disable generic object key fetching interface only]),
246       try_generic=$enableval, try_generic=yes)
247     AC_MSG_RESULT($try_generic)
249     AC_MSG_CHECKING([whether email keyserver support is requested])
250     AC_ARG_ENABLE(mailto,
251       AC_HELP_STRING([--enable-mailto],
252         [enable email keyserver interface only]),
253       try_mailto=$enableval, try_mailto=no)
254     AC_MSG_RESULT($try_mailto)
255     fi
257     AC_MSG_CHECKING([whether keyserver exec-path is enabled])
258     AC_ARG_ENABLE(keyserver-path,
259       AC_HELP_STRING([--disable-keyserver-path],
260         [disable the exec-path option for keyserver helpers]),
261       [if test "$enableval" = no ; then
262          disable_keyserver_path=yes
263       fi],enableval=yes)
264     AC_MSG_RESULT($enableval)
265   fi
269 # Check for the key/uid cache size.  This can't be zero, but can be
270 # pretty small on embedded systems.  This is used for the gpg part.
272 AC_MSG_CHECKING([for the size of the key and uid cache])
273 AC_ARG_ENABLE(key-cache,
274         AC_HELP_STRING([--enable-key-cache=SIZE],
275                        [Set key cache to SIZE (default 4096)]),,enableval=4096)
276 if test "$enableval" = "no"; then
277    enableval=5
278 elif test "$enableval" = "yes" || test "$enableval" = ""; then
279    enableval=4096
281 changequote(,)dnl
282 key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'`
283 changequote([,])dnl
284 if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then
285    AC_MSG_ERROR([invalid key-cache size])
287 AC_MSG_RESULT($key_cache_size)
288 AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size,
289                   [Size of the key and UID caches])
294 # Check whether we want to use Linux capabilities
296 AC_MSG_CHECKING([whether use of capabilities is requested])
297 AC_ARG_WITH(capabilities,
298     [  --with-capabilities     use linux capabilities [default=no]],
299 [use_capabilities="$withval"],[use_capabilities=no])
300 AC_MSG_RESULT($use_capabilities)
303 # To avoid double inclusion of config.h which might happen at some
304 # places, we add the usual double inclusion protection at the top of
305 # config.h.
307 AH_TOP([
308 #ifndef GNUPG_CONFIG_H_INCLUDED
309 #define GNUPG_CONFIG_H_INCLUDED
313 # Stuff which goes at the bottom of config.h.
315 AH_BOTTOM([
316 /* This is the major version number of GnuPG so that
317    source included files can test for this.  Note, that
318    we use 2 here even for GnuPG 1.9.x. */
319 #define GNUPG_MAJOR_VERSION 2
321 /* Now to separate file name parts.
322    Please note that the string version must not contain more
323    than one character because the code assumes strlen()==1 */
324 #ifdef HAVE_DOSISH_SYSTEM
325 #define DIRSEP_C '\\'
326 #define DIRSEP_S "\\"
327 #define EXTSEP_C '.'
328 #define EXTSEP_S "."
329 #define PATHSEP_C ';'
330 #define PATHSEP_S ";"
331 #define EXEEXT_S ".exe"
332 #else
333 #define DIRSEP_C '/'
334 #define DIRSEP_S "/"
335 #define EXTSEP_C '.'
336 #define EXTSEP_S "."
337 #define PATHSEP_C ':'
338 #define PATHSEP_S ":"
339 #define EXEEXT_S ""
340 #endif
342 /* This is the same as VERSION, but should be overridden if the
343    platform cannot handle things like dots '.' in filenames. Set
344    SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION
345    uses for dots and dashes. */
346 #define SAFE_VERSION VERSION
347 #define SAFE_VERSION_DOT  '.'
348 #define SAFE_VERSION_DASH '-'
350 /* Some global constants. */
351 #ifdef HAVE_DRIVE_LETTERS
352 #define GNUPG_DEFAULT_HOMEDIR "c:/gnupg"
353 #elif defined(__VMS)
354 #define GNUPG_DEFAULT_HOMEDIR "/SYS\$LOGIN/gnupg" 
355 #else
356 #define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
357 #endif 
358 #define GNUPG_PRIVATE_KEYS_DIR "private-keys-v1.d"
360 /* For some systems (DOS currently), we hardcode the path here.  For
361    POSIX systems the values are constructed by the Makefiles, so that
362    the values may be overridden by the make invocations; this is to
363    comply with the GNU coding standards. */
364 #ifdef HAVE_DRIVE_LETTERS
365  /* FIXME: We need to use a function to determine these values depending 
366     on the actual installation directory. */
367 #define GNUPG_BINDIR      "c:\\gnupg"
368 #define GNUPG_LIBEXECDIR  "c:\\gnupg"
369 #define GNUPG_LIBDIR      "c:\\gnupg"
370 #define GNUPG_DATADIR     "c:\\gnupg"
371 #define GNUPG_SYSCONFDIR  "c:\\gnupg"
372 #endif
374 /* Derive some other constants. */
375 #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
376 #define EXEC_TEMPFILE_ONLY
377 #endif
380 /* We didn't define endianness above, so get it from OS macros.  This
381    is intended for making fat binary builds on OS X. */
382 #if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST)
383 #if defined(__BIG_ENDIAN__)
384 #define BIG_ENDIAN_HOST 1
385 #elif defined(__LITTLE_ENDIAN__)
386 #define LITTLE_ENDIAN_HOST 1
387 #else
388 #error "No endianness found"
389 #endif
390 #endif
393 /* Hack used for W32: ldap.m4 also tests for the ASCII version of
394    ldap_start_tls_s because that is the actual symbol used in the
395    library.  winldap.h redefines it to our commonly used value,
396    thus we define our usual macro here.  */
397 #ifdef HAVE_LDAP_START_TLS_SA
398 # ifndef HAVE_LDAP_START_TLS_S
399 #  define HAVE_LDAP_START_TLS_S 1
400 # endif
401 #endif
404 /* Tell libgcrypt not to use its own libgpg-error implementation. */
405 #define USE_LIBGPG_ERROR 1
407 /* We use jnlib, so tell other modules about it.  */
408 #define HAVE_JNLIB_LOGGING 1
410 /* Our HTTP code is used in estream mode.  */
411 #define HTTP_USE_ESTREAM 1
413 /* Under W32 we do an explicit socket initialization, thus we need to
414    avoid the on-demand initialization which would also install an atexit
415    handler.  */
416 #define HTTP_NO_WSASTARTUP
418 /* We always include support for the OpenPGP card.  */
419 #define ENABLE_CARD_SUPPORT 1
421 /* We explicitly need to disable PTH's soft mapping as Debian
422    currently enables it by default for no reason. */
423 #define PTH_SYSCALL_SOFT 0
425 /* We want to use the libgcrypt provided memory allocation for
426    asprintf.  */
427 #define _ESTREAM_PRINTF_MALLOC        gcry_malloc
428 #define _ESTREAM_PRINTF_FREE          gcry_free
429 #define _ESTREAM_PRINTF_EXTRA_INCLUDE "util.h"
431 #endif /*GNUPG_CONFIG_H_INCLUDED*/
435 AM_MAINTAINER_MODE
437 # Checks for programs.
438 AC_MSG_NOTICE([checking for programs])
439 AC_PROG_MAKE_SET
440 AM_SANITY_CHECK
441 missing_dir=`cd $ac_aux_dir && pwd`
442 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
443 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
444 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
445 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
446 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
447 AC_PROG_AWK
448 AC_PROG_CC
449 AC_PROG_CPP
450 AM_PROG_CC_C_O
451 if test "x$ac_cv_prog_cc_c89" = "xno" ; then
452   AC_MSG_ERROR([[No C-89 compiler found]])
454 AC_PROG_INSTALL
455 AC_PROG_LN_S
456 AC_PROG_RANLIB
457 AC_CHECK_TOOL(AR, ar, :)
458 AC_PATH_PROG(PERL,"perl")
459 AC_CHECK_TOOL(WINDRES, windres, :)
460 AC_ISC_POSIX
461 gl_EARLY
462 AC_SYS_LARGEFILE
463 GNUPG_CHECK_FAQPROG
464 GNUPG_CHECK_USTAR
466 # We need to compile and run a program on the build machine.  A
467 # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
468 # the AC archive is broken for autoconf 2.57.  Given that tehre is no
469 # newer version of that macro, we assume that it is also broken for
470 # autoconf 2.61 and thus we use a simple but usually sufficient
471 # approach.
472 AC_MSG_CHECKING(for cc for build)
473 if test "$cross_compiling" = "yes"; then
474   CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
475 else
476   CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
478 AC_MSG_RESULT($CC_FOR_BUILD)
479 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
483 try_gettext=yes
484 have_dosish_system=no
485 have_w32_system=no
486 use_simple_gettext=no
487 case "${host}" in
488     *-mingw32*)
489         # special stuff for Windoze NT
490         ac_cv_have_dev_random=no
491         AC_DEFINE(USE_ONLY_8DOT3,1,
492                   [set this to limit filenames to the 8.3 format])
493         AC_DEFINE(HAVE_DRIVE_LETTERS,1,
494                   [defined if we must run on a stupid file system])
495         AC_DEFINE(USE_SIMPLE_GETTEXT,1,
496                   [because the Unix gettext has too much overhead on
497                    MingW32 systems and these systems lack Posix functions,
498                    we use a simplified version of gettext])
499         disable_keyserver_path=yes
500         have_dosish_system=yes
501         have_w32_system=yes
502         try_gettext="no"
503         use_simple_gettext=yes
504         ;;
505     i?86-emx-os2 | i?86-*-os2*emx )
506         # OS/2 with the EMX environment
507         ac_cv_have_dev_random=no
508         AC_DEFINE(HAVE_DRIVE_LETTERS)
509         have_dosish_system=yes
510         try_gettext="no"
511         ;;
513     i?86-*-msdosdjgpp*)
514         # DOS with the DJGPP environment
515         ac_cv_have_dev_random=no
516         AC_DEFINE(HAVE_DRIVE_LETTERS)
517         have_dosish_system=yes
518         try_gettext="no"
519         ;;
521     *-*-freebsd*)
522        # FreeBSD
523        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
524        LDFLAGS="$LDFLAGS -L/usr/local/lib"
525        ;;
527     *-*-hpux*)
528         if test -z "$GCC" ; then
529             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
530         fi
531         ;;
532     *-dec-osf4*)
533         if test -z "$GCC" ; then
534             # Suppress all warnings
535             # to get rid of the unsigned/signed char mismatch warnings.
536             CFLAGS="$CFLAGS -w"
537         fi
538         ;;
539     *-dec-osf5*)
540         if test -z "$GCC" ; then
541             # Use the newer compiler `-msg_disable ptrmismatch1' to
542             # get rid of the unsigned/signed char mismatch warnings.
543             # Using this may hide other pointer mismatch warnings, but
544             # it at least lets other warning classes through
545             CFLAGS="$CFLAGS -msg_disable ptrmismatch1"
546         fi
547         ;;
548     m68k-atari-mint)
549         ;;
550     *)
551        ;;
552 esac
554 if test "$have_dosish_system" = yes; then
555    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
556              [Defined if we run on some of the PCDOS like systems 
557               (DOS, Windoze. OS/2) with special properties like
558               no file modes])
560 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
562 AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes)
564 if test "$have_w32_system" = yes; then
565    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
567 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
569 if test "$disable_keyserver_path" = yes; then
570     AC_DEFINE(DISABLE_KEYSERVER_PATH,1,
571               [Defined to disable exec-path for keyserver helpers])
574 # (These need to go after AC_PROG_CC so that $EXEEXT is defined)
575 AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any])
577 if test x"$try_hkp" = xyes ; then
578   AC_SUBST(GPGKEYS_HKP,"gpg2keys_hkp$EXEEXT")
581 if test x"$try_finger" = xyes ; then
582   AC_SUBST(GPGKEYS_FINGER,"gpg2keys_finger$EXEEXT")
588 # Checks for libraries.
590 AC_MSG_NOTICE([checking for libraries])
594 # libgpg-error is a library with error codes shared between GnuPG
595 # related projects.
597 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
598                   have_gpg_error=yes,have_gpg_error=no)
602 # Libgcrypt is our generic crypto library
604 AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION",
605         have_libgcrypt=yes,have_libgcrypt=no)
609 # libassuan is used for IPC
611 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
612                   have_libassuan=yes,have_libassuan=no)
613 if test "$have_libassuan" = "yes"; then
614   have_libassuan=no
615   AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
616                     have_libassuan=yes,have_libassuan=no)       
617   AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version",
618                      [version of the libassuan library])
624 # libksba is our X.509 support library
626 AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no)
630 # libusb allows us to use the integrated CCID smartcard reader driver.
632 # FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs.
633 AC_CHECK_LIB(usb, usb_bulk_write,
634               [ LIBUSB_LIBS="$LIBUSB_LIBS -lusb"
635                 AC_DEFINE(HAVE_LIBUSB,1,
636                          [defined if libusb is available])
637                 have_libusb=yes
638              ])
639 AC_SUBST(LIBUSB_LIBS)
640 AC_CHECK_FUNCS(usb_create_match)
643 # Check wether it is necessary to link against libdl.
645 gnupg_dlopen_save_libs="$LIBS"
646 LIBS=""
647 AC_SEARCH_LIBS(dlopen, c dl,,,)
648 DL_LIBS=$LIBS
649 AC_SUBST(DL_LIBS)
650 LIBS="$gnupg_dlopen_save_libs"
652 # Checks for g13
654 AC_PATH_PROG(ENCFS, encfs, /usr/bin/encfs)
655 AC_DEFINE_UNQUOTED(ENCFS,
656         "${ENCFS}", [defines the filename of the encfs program])
658 AC_PATH_PROG(FUSERMOUNT, fusermount, /usr/bin/fusermount)
659 AC_DEFINE_UNQUOTED(FUSERMOUNT,
660         "${FUSERMOUNT}", [defines the filename of the fusermount program])
663 # Checks for symcryptrun:
666 # libutil has openpty() and login_tty().
667 AC_CHECK_LIB(util, openpty,
668               [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil"
669                 AC_DEFINE(HAVE_LIBUTIL,1,
670                          [defined if libutil is available])
671              ])
672 AC_SUBST(LIBUTIL_LIBS)
674 # shred is used to clean temporary plain text files.
675 AC_PATH_PROG(SHRED, shred, /usr/bin/shred)
676 AC_DEFINE_UNQUOTED(SHRED,
677         "${SHRED}", [defines the filename of the shred program])
681 # Check whether the GNU Pth library is available
682 # Note, that we include a Pth emulation for W32.
684 GNUPG_PATH_PTH
685 if test "$have_pth" = "yes"; then
686   AC_DEFINE(USE_GNU_PTH, 1,
687               [Defined if the GNU Portable Thread Library should be used])
688 else
689   AC_MSG_WARN([[
691 *** To support concurrent access to the gpg-agent and the SCdaemon
692 *** we need the support of the GNU Portable Threads Library.
693 *** Download it from ftp://ftp.gnu.org/gnu/pth/
694 *** On a Debian GNU/Linux system you might want to try 
695 ***   apt-get install libpth-dev
696 ***]])
700 AC_MSG_NOTICE([checking for networking options])
703 # Must check for network library requirements before doing link tests
704 # for ldap, for example. If ldap libs are static (or dynamic and without
705 # ELF runtime link paths), then link will fail and LDAP support won't
706 # be detected.
708 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
709         [NETLIBS="-lnsl $NETLIBS"]))
710 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
711         [NETLIBS="-lsocket $NETLIBS"]))
714 # Now try for the resolver functions so we can use DNS for SRV, PA and CERT.
716 if test x"$try_hkp" = xyes || test x"$try_http" = xyes ; then
717   AC_ARG_ENABLE(dns-srv,
718      AC_HELP_STRING([--disable-dns-srv],
719                     [disable the use of DNS SRV in HKP and HTTP]),
720                 use_dns_srv=$enableval,use_dns_srv=yes)
723 AC_ARG_ENABLE(dns-pka,
724    AC_HELP_STRING([--disable-dns-pka],
725         [disable the use of PKA records in DNS]),
726    use_dns_pka=$enableval,use_dns_pka=yes)
728 AC_ARG_ENABLE(dns-cert,
729    AC_HELP_STRING([--disable-dns-cert],
730         [disable the use of CERT records in DNS]),
731    use_dns_cert=$enableval,use_dns_cert=yes)
733 if test x"$use_dns_pka" = xyes || test x"$use_dns_srv" = xyes \
734    || test x"$use_dns_cert" = xyes; then
735   _dns_save_libs=$LIBS
736   LIBS=""
737   # the double underscore thing is a glibc-ism?
738   AC_SEARCH_LIBS(res_query,resolv bind,,
739                  AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no))
740   AC_SEARCH_LIBS(dn_expand,resolv bind,,
741                  AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no))
742   AC_SEARCH_LIBS(dn_skipname,resolv bind,,
743                  AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no))
745   if test x"$have_resolver" != xno ; then
747     # Make sure that the BIND 4 resolver interface is workable before
748     # enabling any code that calls it.  At some point I'll rewrite the
749     # code to use the BIND 8 resolver API.
750     # We might also want to use adns instead.
752     AC_MSG_CHECKING([whether the resolver is usable])
753     AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
754 #include <netinet/in.h>
755 #include <arpa/nameser.h>
756 #include <resolv.h>],
757 [[unsigned char answer[PACKETSZ];
758   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
759   dn_skipname(0,0); 
760   dn_expand(0,0,0,0,0);
761 ]])],have_resolver=yes,have_resolver=no)
762     AC_MSG_RESULT($have_resolver)
764     # This is Apple-specific and somewhat bizarre as they changed the
765     # define in bind 8 for some reason.
767     if test x"$have_resolver" != xyes ; then
768        AC_MSG_CHECKING(
769              [whether I can make the resolver usable with BIND_8_COMPAT])
770        AC_LINK_IFELSE([AC_LANG_PROGRAM([#define BIND_8_COMPAT
771 #include <sys/types.h>
772 #include <netinet/in.h>
773 #include <arpa/nameser.h>
774 #include <resolv.h>],
775 [[unsigned char answer[PACKETSZ];
776   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
777   dn_skipname(0,0); dn_expand(0,0,0,0,0);
778 ]])],[have_resolver=yes ; need_compat=yes])
779        AC_MSG_RESULT($have_resolver)
780     fi
781   fi
783   if test x"$have_resolver" = xyes ; then
784      DNSLIBS=$LIBS
786      if test x"$use_dns_srv" = xyes ; then
787         AC_DEFINE(USE_DNS_SRV,1,[define to use DNS SRV])
788      fi
790      if test x"$use_dns_pka" = xyes ; then
791         AC_DEFINE(USE_DNS_PKA,1,[define to use our experimental DNS PKA])
792      fi
794      if test x"$use_dns_cert" = xyes ; then
795         AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT])
796      fi
798      if test x"$need_compat" = xyes ; then
799         AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism])
800      fi
801   else
802      use_dns_srv=no
803      use_dns_pka=no
804      use_dns_cert=no
805   fi
807   LIBS=$_dns_save_libs
810 AC_SUBST(DNSLIBS)
812 AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes)
816 # Check for ADNS.
818 _cppflags="${CPPFLAGS}"
819 _ldflags="${LDFLAGS}"
820 AC_ARG_WITH(adns,
821             AC_HELP_STRING([--with-adns=DIR],
822                            [look for the adns library in DIR]),
823             [if test -d "$withval"; then
824                CPPFLAGS="${CPPFLAGS} -I$withval/include"
825                LDFLAGS="${LDFLAGS} -L$withval/lib"
826              fi])
827 if test "$with_adns" != "no"; then
828   AC_CHECK_HEADERS(adns.h,
829                 AC_CHECK_LIB(adns, adns_init,
830                              [have_adns=yes],
831                              [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]),
832                 [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}])
834 if test "$have_adns" = "yes"; then
835   ADNSLIBS="-ladns" 
837 AC_SUBST(ADNSLIBS)
838 # Newer adns versions feature a free function to be used under W32.
839 AC_CHECK_FUNCS(adns_free)
843 # Check for LDAP
845 if test "$try_ldap" = yes ; then
846    GNUPG_CHECK_LDAP($NETLIBS)
850 # Check for curl.  We fake the curl API if libcurl isn't installed.
851 # We require 7.10 or later as we use curl_version_info().
853 LIBCURL_CHECK_CONFIG([yes],[7.10],,[fake_curl=yes])
854 AM_CONDITIONAL(FAKE_CURL,test x"$fake_curl" = xyes)
856 # Generic, for us, means curl
858 if test x"$try_generic" = xyes ; then
859    AC_SUBST(GPGKEYS_CURL,"gpg2keys_curl$EXEEXT")
863 # Check for sendmail
865 # This isn't necessarily sendmail itself, but anything that gives a
866 # sendmail-ish interface to the outside world.  That includes Exim,
867 # Postfix, etc.  Basically, anything that can handle "sendmail -t".
868 if test "$try_mailto" = yes ; then
869   AC_ARG_WITH(mailprog,
870       AC_HELP_STRING([--with-mailprog=NAME],
871                      [use "NAME -t" for mail transport]),
872              ,with_mailprog=yes)
874   if test x"$with_mailprog" = xyes ; then
875     AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib)
876     if test "$ac_cv_path_SENDMAIL" ; then
877       GPGKEYS_MAILTO="gpg2keys_mailto"
878     fi
879   elif test x"$with_mailprog" != xno ; then
880     AC_MSG_CHECKING([for a mail transport program])
881     AC_SUBST(SENDMAIL,$with_mailprog)
882     AC_MSG_RESULT($with_mailprog)
883     GPGKEYS_MAILTO="gpg2keys_mailto"
884   fi
887 AC_SUBST(GPGKEYS_MAILTO)
890 # Construct a printable name of the OS
892 case "${host}" in
893     *-mingw32*)
894         PRINTABLE_OS_NAME="MingW32"
895         ;;
896     *-*-cygwin*)
897         PRINTABLE_OS_NAME="Cygwin"
898         ;;
899     i?86-emx-os2 | i?86-*-os2*emx )
900         PRINTABLE_OS_NAME="OS/2"
901         ;;
902     i?86-*-msdosdjgpp*)
903         PRINTABLE_OS_NAME="MSDOS/DJGPP"
904         try_dynload=no
905         ;;
906     *-linux*)
907         PRINTABLE_OS_NAME="GNU/Linux"
908         ;;
909     *)
910         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
911         ;;
912 esac
913 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
914                    [A human readable text with the name of the OS])
918 # Checking for iconv
920 AM_ICONV
924 # Check for gettext
926 # This is "GNU gnupg" - The project-id script from gettext
927 #                       needs this string
929 AC_MSG_NOTICE([checking for gettext])
930 AM_PO_SUBDIRS
931 AM_GNU_GETTEXT_VERSION([0.17])
932 if test "$try_gettext" = yes; then
933   AM_GNU_GETTEXT([external],[need-ngettext])
935   # gettext requires some extra checks.  These really should be part of
936   # the basic AM_GNU_GETTEXT macro.  TODO: move other gettext-specific
937   # function checks to here.
939   AC_CHECK_FUNCS(strchr)
940 else
941   USE_NLS=no
942   USE_INCLUDED_LIBINTL=no
943   BUILD_INCLUDED_LIBINTL=no
944   POSUB=po
945   AC_SUBST(USE_NLS)
946   AC_SUBST(USE_INCLUDED_LIBINTL)
947   AC_SUBST(BUILD_INCLUDED_LIBINTL)
948   AC_SUBST(POSUB)
951 # We use HAVE_LANGINFO_CODESET in a couple of places.
952 AM_LANGINFO_CODESET
954 # Checks required for our use locales
955 gt_LC_MESSAGES
959 # SELinux support
961 if test "$selinux_support" = yes ; then
962   AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support])
967 # Checks for header files.
969 AC_MSG_NOTICE([checking for header files])
970 AC_HEADER_STDC
971 AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h])
972 AC_CHECK_HEADERS([pty.h pwd.h inttypes.h])
973 AC_HEADER_TIME
977 # Checks for typedefs, structures, and compiler characteristics.
979 AC_MSG_NOTICE([checking for system characteristics])
980 AC_C_CONST
981 AC_C_INLINE
982 AC_C_VOLATILE
983 AC_TYPE_SIZE_T
984 AC_TYPE_MODE_T
985 AC_TYPE_SIGNAL
986 AC_DECL_SYS_SIGLIST
988 gl_HEADER_SYS_SOCKET
989 gl_TYPE_SOCKLEN_T
991 AC_ARG_ENABLE(endian-check,
992               AC_HELP_STRING([--disable-endian-check],
993               [disable the endian check and trust the OS provided macros]),
994               endiancheck=$enableval,endiancheck=yes)
996 if test x"$endiancheck" = xyes ; then
997   GNUPG_CHECK_ENDIAN
1000 # fixme: we should get rid of the byte type
1001 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
1002 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
1003 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
1004 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
1005 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
1007 AC_CHECK_SIZEOF(unsigned short)
1008 AC_CHECK_SIZEOF(unsigned int)
1009 AC_CHECK_SIZEOF(unsigned long)
1010 AC_CHECK_SIZEOF(unsigned long long)
1011 AC_CHECK_SIZEOF(time_t,,[[
1012 #include <stdio.h>
1013 #if TIME_WITH_SYS_TIME
1014 # include <sys/time.h>
1015 # include <time.h>
1016 #else
1017 # if HAVE_SYS_TIME_H
1018 #  include <sys/time.h>
1019 # else
1020 #  include <time.h>
1021 # endif
1022 #endif
1026 # Ensure that we have UINT64_C before we bother to check for uint64_t
1027 # Fixme: really needed in gnupg?  I think it is only useful in libcgrypt.
1028 AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
1029    AC_COMPILE_IFELSE(AC_LANG_PROGRAM([#include <inttypes.h>
1030        uint64_t foo=UINT64_C(42);]),
1031      gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
1032 if test "$gnupg_cv_uint64_c_works" = "yes" ; then
1033    AC_CHECK_SIZEOF(uint64_t)
1036 if test "$ac_cv_sizeof_unsigned_short" = "0" \
1037    || test "$ac_cv_sizeof_unsigned_int" = "0" \
1038    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
1039     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
1044 # Checks for library functions.
1046 AC_MSG_NOTICE([checking for library functions])
1047 AC_CHECK_DECLS(getpagesize)
1048 AC_FUNC_FSEEKO
1049 AC_FUNC_VPRINTF
1050 AC_FUNC_FORK
1051 AC_CHECK_FUNCS([strerror strlwr tcgetattr mmap])
1052 AC_CHECK_FUNCS([strcasecmp strncasecmp ctermid times gmtime_r])
1053 AC_CHECK_FUNCS([unsetenv fcntl ftruncate])
1054 AC_CHECK_FUNCS([gettimeofday getrusage getrlimit setrlimit clock_gettime])
1055 AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale])
1056 AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe stat getaddrinfo])
1057 AC_CHECK_FUNCS([ttyname rand ftello fsync])
1059 AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
1062 # These are needed by libjnlib - fixme: we should use a jnlib.m4
1063 # Note:  We already checked pwd.h.
1064 AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol])
1065 AC_CHECK_FUNCS([memrchr isascii timegm getrusage setrlimit stat setlocale])
1066 AC_CHECK_FUNCS([flockfile funlockfile fopencookie funopen getpwnam getpwuid])
1069 # gnulib checks
1071 gl_SOURCE_BASE([gl])
1072 gl_M4_BASE([gl/m4])
1073 gl_MODULES([setenv mkdtemp xsize strpbrk])
1074 gl_INIT
1078 # W32 specific test
1080 GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
1083 # Sanity check regex.  Tests adapted from mutt.
1085 AC_MSG_CHECKING([whether regular expression support is requested])
1086 AC_ARG_ENABLE(regex,
1087   AC_HELP_STRING([--disable-regex],
1088     [do not handle regular expressions in trust signatures]),
1089   use_regex=$enableval, use_regex=yes)
1090 AC_MSG_RESULT($use_regex)
1092 if test "$use_regex" = yes ; then
1093   _cppflags="${CPPFLAGS}"
1094   _ldflags="${LDFLAGS}"
1095   AC_ARG_WITH(regex,
1096      AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]),
1097       [
1098       if test -d "$withval" ; then
1099         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1100         LDFLAGS="${LDFLAGS} -L$withval/lib"
1101       fi
1102       ],withval="")     
1104   # Does the system have regex functions at all?
1105   AC_SEARCH_LIBS([regcomp], [regex])
1106   AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no)
1108   if test $gnupg_cv_have_regex = no; then
1109     use_regex=no
1110   else
1111     if test x"$cross_compiling" = xyes; then
1112       AC_MSG_WARN([cross compiling; assuming regexp libray is not broken])
1113     else
1114       AC_CACHE_CHECK([whether your system's regexp library is broken],
1115        [gnupg_cv_regex_broken],
1116        AC_TRY_RUN([
1117 #include <unistd.h>
1118 #include <regex.h>
1119 main() { regex_t blah ; regmatch_t p; p.rm_eo = p.rm_eo; return regcomp(&blah, "foo.*bar", REG_NOSUB) || regexec (&blah, "foobar", 0, NULL, 0); }],
1120        gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes))
1122       if test $gnupg_cv_regex_broken = yes; then
1123         AC_MSG_WARN([your regex is broken - disabling regex use])
1124         use_regex=no
1125       fi
1126     fi
1127   fi
1128   CPPFLAGS="${_cppflags}"
1129   LDFLAGS="${_ldflags}"
1132 if test "$use_regex" != yes ; then
1133   AC_DEFINE(DISABLE_REGEX,1, [Define to disable regular expression support])
1135 AM_CONDITIONAL(DISABLE_REGEX, test x"$use_regex" != xyes)
1140 # Do we have zlib? Must do it here because Solaris failed
1141 # when compiling a conftest (due to the "-lz" from LIBS).
1142 # Note that we combine zlib and bzlib2 in ZLIBS.
1144 _cppflags="${CPPFLAGS}"
1145 _ldflags="${LDFLAGS}"
1146 AC_ARG_WITH(zlib,
1147   [  --with-zlib=DIR         use libz in DIR],[
1148     if test -d "$withval"; then
1149       CPPFLAGS="${CPPFLAGS} -I$withval/include"
1150       LDFLAGS="${LDFLAGS} -L$withval/lib"
1151     fi
1152   ])
1154 AC_CHECK_HEADER(zlib.h,
1155       AC_CHECK_LIB(z, deflateInit2_,
1156        ZLIBS="-lz",
1157        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1158        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
1161 # Check whether we can support bzip2
1163 if test "$use_bzip2" = yes ; then
1164   _cppflags="${CPPFLAGS}"
1165   _ldflags="${LDFLAGS}"
1166   AC_ARG_WITH(bzip2,
1167      AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]),
1168       [
1169       if test -d "$withval" ; then
1170         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1171         LDFLAGS="${LDFLAGS} -L$withval/lib"
1172       fi
1173       ],withval="")
1175   # Checking alongside stdio.h as an early version of bzip2 (1.0)
1176   # required stdio.h to be included before bzlib.h, and Solaris 9 is 
1177   # woefully out of date.
1178   if test "$withval" != no ; then
1179      AC_CHECK_HEADER(bzlib.h,
1180         AC_CHECK_LIB(bz2,BZ2_bzCompressInit,
1181           [
1182           have_bz2=yes
1183           ZLIBS="$ZLIBS -lbz2"
1184           AC_DEFINE(HAVE_BZIP2,1,
1185                   [Defined if the bz2 compression library is available])
1186           ],
1187           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1188           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include <stdio.h>])
1189   fi
1191 AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes")
1192 AC_SUBST(ZLIBS)
1195 # Check for readline support
1196 GNUPG_CHECK_READLINE
1199 # Allow users to append something to the version string without
1200 # flagging it as development version.  The user version parts is
1201 # considered everything after a dash. 
1203 if test "$development_version" != yes; then
1204   changequote(,)dnl
1205   tmp_pat='[a-zA-Z]'
1206   changequote([,])dnl
1207   if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then
1208     development_version=yes
1209   fi
1211 if test "$development_version" = yes; then
1212     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1213             [Defined if this is not a regular release])
1216 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1218 GNUPG_CHECK_GNUMAKE
1220 # Add some extra libs here so that previous tests don't fail for
1221 # mysterious reasons - the final link step should bail out.
1222 # W32SOCKLIBS is also defined so that if can be used for tools not
1223 # requiring any network stuff but linking to code in libcommon which
1224 # tracks in winsock stuff (e.g. init_common_subsystems.
1225 if test "$have_w32_system" = yes; then
1226    W32SOCKLIBS="-lws2_32"
1227    NETLIBS="${NETLIBS} ${W32SOCKLIBS}"
1230 AC_SUBST(NETLIBS)
1231 AC_SUBST(W32SOCKLIBS)
1234 # Setup gcc specific options
1236 AC_MSG_NOTICE([checking for cc features])
1237 if test "$GCC" = yes; then
1238     # Note that it is okay to use CFLAGS here because this are just
1239     # warning options and the user should have a chance of overriding
1240     # them.
1241     if test "$USE_MAINTAINER_MODE" = "yes"; then
1242         CFLAGS="$CFLAGS -O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
1243         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1244         AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1245         _gcc_cflags_save=$CFLAGS
1246         CFLAGS="-Wno-missing-field-initializers"
1247         AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
1248         AC_MSG_RESULT($_gcc_wopt)
1249         CFLAGS=$_gcc_cflags_save;
1250         if test x"$_gcc_wopt" = xyes ; then
1251           CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
1252         fi
1253         AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
1254         _gcc_cflags_save=$CFLAGS
1255         CFLAGS="-Wdeclaration-after-statement"
1256         AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_wopt=yes,_gcc_wopt=no)
1257         AC_MSG_RESULT($_gcc_wopt)
1258         CFLAGS=$_gcc_cflags_save;
1259         if test x"$_gcc_wopt" = xyes ; then
1260           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1261         fi
1262     else
1263         CFLAGS="$CFLAGS -Wall"
1264     fi
1266     AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
1267     _gcc_cflags_save=$CFLAGS
1268     CFLAGS="-Wno-pointer-sign"
1269     AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
1270     AC_MSG_RESULT($_gcc_psign)
1271     CFLAGS=$_gcc_cflags_save;
1272     if test x"$_gcc_psign" = xyes ; then
1273        CFLAGS="$CFLAGS -Wno-pointer-sign"
1274     fi
1276     AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1277     _gcc_cflags_save=$CFLAGS
1278     CFLAGS="-Wpointer-arith"
1279     AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),_gcc_psign=yes,_gcc_psign=no)
1280     AC_MSG_RESULT($_gcc_psign)
1281     CFLAGS=$_gcc_cflags_save;
1282     if test x"$_gcc_psign" = xyes ; then
1283        CFLAGS="$CFLAGS -Wpointer-arith"
1284     fi
1289 # This is handy for debugging so the compiler doesn't rearrange
1290 # things and eliminate variables.
1292 AC_ARG_ENABLE(optimization,
1293    AC_HELP_STRING([--disable-optimization],
1294                   [disable compiler optimization]),
1295                   [if test $enableval = no ; then
1296                       CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1297                    fi])
1300 # Prepare building of estream
1302 estream_INIT
1306 # Decide what to build
1308 if test "$have_adns" = "yes"; then
1309   AC_SUBST(GPGKEYS_KDNS, "gpg2keys_kdns$EXEEXT")
1313 missing_pth=no
1314 if test $have_ksba = no; then
1315   build_gpgsm=no
1316   build_scdaemon=no
1319 build_agent_threaded=""
1320 if test "$build_agent" = "yes"; then
1321   if test $have_pth = no; then
1322      build_agent_threaded="(not multi-threaded)"
1323      missing_pth=yes
1324   fi
1327 build_scdaemon_extra=""
1328 if test "$build_scdaemon" = "yes"; then
1329   tmp=""
1330   if test $have_pth = no; then
1331      build_scdaemon_extra="not multi-threaded"
1332      tmp=", "
1333      missing_pth=yes
1334   fi
1335   if test $have_libusb = no; then
1336      build_scdaemon_extra="${tmp}without internal CCID driver"
1337      tmp=", "
1338   fi
1339   if test -n "$build_scdaemon_extra"; then
1340      build_scdaemon_extra="(${build_scdaemon_extra})"
1341   fi
1345 if test "$build_agent_only" = "yes" ; then
1346   build_gpg=no
1347   build_gpgsm=no
1348   build_scdaemon=no
1349   build_tools=no
1350   build_doc=no
1354 AM_CONDITIONAL(BUILD_GPG,   test "$build_gpg" = "yes")
1355 AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes")
1356 AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes")
1357 AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes")
1358 AM_CONDITIONAL(BUILD_G13,   test "$build_g13" = "yes")
1359 AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes")
1360 AM_CONDITIONAL(BUILD_DOC,   test "$build_doc" = "yes")
1361 AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes")
1363 AM_CONDITIONAL(RUN_GPG_TESTS,
1364         test x$cross_compiling = xno -a "$build_gpg" = yes )
1368 # Print errors here so that they are visible all
1369 # together and the user can acquire them all together.
1371 die=no
1372 if test "$have_gpg_error" = "no"; then
1373    die=yes
1374    AC_MSG_NOTICE([[
1375 ***  
1376 *** You need libgpg-error to build this program.
1377 **  This library is for example available at
1378 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
1379 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
1380 ***]])
1382 if test "$have_libgcrypt" = "no"; then
1383    die=yes
1384    AC_MSG_NOTICE([[
1385 ***  
1386 *** You need libgcrypt to build this program.
1387 **  This library is for example available at
1388 ***   ftp://ftp.gnupg.org/gcrypt/libgcrypt/
1389 *** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.)
1390 ***]])
1392 if test "$have_libassuan" = "no"; then
1393    die=yes
1394    AC_MSG_NOTICE([[
1396 *** You need libassuan to build this program.
1397 *** This library is for example available at
1398 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
1399 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
1400 ***]])
1402 if test "$have_ksba" = "no"; then
1403     AC_MSG_NOTICE([[
1405 *** You need libksba to build this program.
1406 *** This library is for example available at
1407 ***   ftp://ftp.gnupg.org/gcrypt/libksba/
1408 *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required).
1409 ***]])
1411 if test "$missing_pth" = "yes"; then
1412     AC_MSG_NOTICE([[
1414 *** It is now required to build with support for the
1415 *** GNU Portable Threads Library (Pth). Please install this
1416 *** library first.  The library is for example available at
1417 ***   ftp://ftp.gnu.org/gnu/pth/
1418 *** On a Debian GNU/Linux system you can install it using 
1419 ***   apt-get install libpth-dev
1420 *** To build GnuPG for Windows you need to use the W32PTH
1421 *** package; available at:
1422 ***   ftp://ftp.g10code.com/g10code/w32pth/
1423 ***]])
1424    die=yes
1427 if test "$die" = "yes"; then
1428     AC_MSG_ERROR([[
1430 *** Required libraries not found. Please consult the above messages
1431 *** and install them before running configure again.
1432 ***]])
1437 AC_CONFIG_FILES([ m4/Makefile 
1438 Makefile
1439 po/Makefile.in
1440 gl/Makefile
1441 include/Makefile
1442 jnlib/Makefile
1443 common/Makefile
1444 kbx/Makefile
1445 g10/Makefile
1446 sm/Makefile
1447 agent/Makefile
1448 scd/Makefile
1449 g13/Makefile
1450 keyserver/Makefile
1451 keyserver/gpg2keys_mailto
1452 keyserver/gpg2keys_test
1453 tools/gpg-zip
1454 tools/Makefile
1455 doc/Makefile
1456 tests/Makefile
1457 tests/openpgp/Makefile
1458 tests/pkits/Makefile
1460 AC_OUTPUT
1463 echo "
1464         GnuPG v${VERSION} has been configured as follows:
1465         
1466         Platform:  $PRINTABLE_OS_NAME ($host)
1468         OpenPGP:   $build_gpg
1469         S/MIME:    $build_gpgsm
1470         Agent:     $build_agent $build_agent_threaded
1471         Smartcard: $build_scdaemon $build_scdaemon_extra
1472         G13:       $build_g13
1475         Protect tool:      $show_gnupg_protect_tool_pgm
1476         Default agent:     $show_gnupg_agent_pgm
1477         Default pinentry:  $show_gnupg_pinentry_pgm
1478         Default scdaemon:  $show_gnupg_scdaemon_pgm
1479         Default dirmngr:   $show_gnupg_dirmngr_pgm
1481 if test x"$use_regex" != xyes ; then
1482 echo "
1483         Warning: No regular expression support available.
1484                  OpenPGP trust signatures won't work.
1485                  gpg-check-pattern will not be build.