Imported Upstream version 2.0.26
[platform/upstream/gpg2.git] / configure.ac
1 # configure.ac - for GnuPG 2.0
2 # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 #               2006, 2007, 2008, 2010, 2011,
4 #               2012 Free Software Foundation, Inc.
5 #
6 # This file is part of GnuPG.
7 #
8 # GnuPG 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 # GnuPG is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU 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, see <http://www.gnu.org/licenses/>.
20
21 # Process this file with autoconf to produce a configure script.
22 AC_PREREQ(2.61)
23 min_automake_version="1.10"
24
25 # To build a release you need to create a tag with the version number
26 # (git tag -s gnupg-2.n.m) and run "./autogen.sh --force".  Please
27 # bump the version number immediately *after* the release and do
28 # another commit and push so that the git magic is able to work.
29 m4_define([mym4_version], [2.0.26])
30
31 # Below is m4 magic to extract and compute the git revision number,
32 # the decimalized short revision number, a beta version string and a
33 # flag indicating a development version (mym4_isgit).  Note that the
34 # m4 processing is done by autoconf and not during the configure run.
35 m4_define([mym4_revision],
36           m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
37 m4_define([mym4_revision_dec],
38           m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
39 m4_define([mym4_betastring],
40           m4_esyscmd_s([git describe --match 'gnupg-2.[0-9].*[0-9]' --long|\
41                         awk -F- '$3!=0{print"-beta"$3}']))
42 m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
43 m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
44
45 AC_INIT([gnupg],[mym4_full_version], [http://bugs.gnupg.org])
46
47 NEED_GPG_ERROR_VERSION=1.11
48
49 NEED_LIBGCRYPT_API=1
50 NEED_LIBGCRYPT_VERSION=1.4.0
51
52 NEED_LIBASSUAN_API=2
53 NEED_LIBASSUAN_VERSION=2.0.0
54
55 NEED_KSBA_API=1
56 NEED_KSBA_VERSION=1.0.7
57
58 development_version=mym4_isgit
59 PACKAGE=$PACKAGE_NAME
60 PACKAGE_GT=${PACKAGE_NAME}2
61 VERSION=$PACKAGE_VERSION
62
63 AC_CONFIG_AUX_DIR(scripts)
64 AC_CONFIG_SRCDIR(sm/gpgsm.c)
65 AM_CONFIG_HEADER(config.h)
66 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
67 AC_CANONICAL_HOST
68 AB_INIT
69
70 AC_GNU_SOURCE
71
72 # Some status variables.
73 have_gpg_error=no
74 have_libgcrypt=no
75 have_libassuan=no
76 have_ksba=no
77 have_pth=no
78 have_libusb=no
79 have_adns=no
80
81 use_bzip2=yes
82 use_exec=yes
83 disable_keyserver_path=no
84 use_ccid_driver=yes
85 use_standard_socket=no
86
87 GNUPG_BUILD_PROGRAM(gpg, yes)
88 GNUPG_BUILD_PROGRAM(gpgsm, yes)
89 GNUPG_BUILD_PROGRAM(agent, yes)
90 GNUPG_BUILD_PROGRAM(scdaemon, yes)
91 GNUPG_BUILD_PROGRAM(tools, yes)
92 GNUPG_BUILD_PROGRAM(doc, yes)
93 GNUPG_BUILD_PROGRAM(symcryptrun, no)
94 GNUPG_BUILD_PROGRAM(gpgtar, no)
95
96
97 AC_SUBST(PACKAGE)
98 AC_SUBST(PACKAGE_GT)
99 AC_SUBST(VERSION)
100 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
101 AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT",
102                                 [Name of this package for gettext])
103 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
104 AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
105                                         [Bug report address])
106 AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION",
107                                        [Required version of Libgcrypt])
108 AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION",
109                                        [Required version of Libksba])
110
111
112 # The default is to use the modules from this package and the few
113 # other packages in a standard place; i.e where this package gets
114 # installed.  With these options it is possible to override these
115 # ${prefix} depended values with fixed paths, which can't be replaced
116 # at make time.  See also am/cmacros.am and the defaults in AH_BOTTOM.
117 AC_ARG_WITH(agent-pgm,
118     [  --with-agent-pgm=PATH  Use PATH as the default for the agent)],
119           GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" )
120 AC_SUBST(GNUPG_AGENT_PGM)
121 AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM")
122 show_gnupg_agent_pgm="(default)"
123 test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM"
124
125 AC_ARG_WITH(pinentry-pgm,
126     [  --with-pinentry-pgm=PATH  Use PATH as the default for the pinentry)],
127           GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" )
128 AC_SUBST(GNUPG_PINENTRY_PGM)
129 AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM")
130 show_gnupg_pinentry_pgm="(default)"
131 test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM"
132
133
134 AC_ARG_WITH(scdaemon-pgm,
135     [  --with-scdaemon-pgm=PATH  Use PATH as the default for the scdaemon)],
136           GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" )
137 AC_SUBST(GNUPG_SCDAEMON_PGM)
138 AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM")
139 show_gnupg_scdaemon_pgm="(default)"
140 test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM"
141
142
143 AC_ARG_WITH(dirmngr-pgm,
144     [  --with-dirmngr-pgm=PATH  Use PATH as the default for the dirmngr)],
145           GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" )
146 AC_SUBST(GNUPG_DIRMNGR_PGM)
147 AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM")
148 show_gnupg_dirmngr_pgm="(default)"
149 test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM"
150
151 AC_ARG_WITH(protect-tool-pgm,
152     [  --with-protect-tool-pgm=PATH  Use PATH as the default for the protect-tool)],
153           GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" )
154 AC_SUBST(GNUPG_PROTECT_TOOL_PGM)
155 AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM")
156 show_gnupg_protect_tool_pgm="(default)"
157 test -n "$GNUPG_PROTECT_TOOL_PGM" \
158       && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM"
159
160
161 # Some folks want to use only the agent from this packet.  Make it
162 # easier for them by providing the configure option
163 # --enable-only-agent.
164 AC_ARG_ENABLE(agent-only,
165     AC_HELP_STRING([--enable-agent-only],[build only the gpg-agent]),
166     build_agent_only=$enableval)
167
168 # SELinux support includes tracking of sensitive files to avoid
169 # leaking their contents through processing these files by gpg itself
170 AC_MSG_CHECKING([whether SELinux support is requested])
171 AC_ARG_ENABLE(selinux-support,
172               AC_HELP_STRING([--enable-selinux-support],
173                              [enable SELinux support]),
174               selinux_support=$enableval, selinux_support=no)
175 AC_MSG_RESULT($selinux_support)
176
177 # Allow disabling of bzib2 support.
178 # It is defined only after we confirm the library is available later
179 AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm])
180 AC_ARG_ENABLE(bzip2,
181    AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]),
182    use_bzip2=$enableval)
183 AC_MSG_RESULT($use_bzip2)
184
185 # Configure option to allow or disallow execution of external
186 # programs, like a photo viewer.
187 AC_MSG_CHECKING([whether to enable external program execution])
188 AC_ARG_ENABLE(exec,
189     AC_HELP_STRING([--disable-exec],[disable all external program execution]),
190     use_exec=$enableval)
191 AC_MSG_RESULT($use_exec)
192 if test "$use_exec" = no ; then
193     AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution])
194 fi
195
196 if test "$use_exec" = yes ; then
197   AC_MSG_CHECKING([whether to enable photo ID viewing])
198   AC_ARG_ENABLE(photo-viewers,
199       [  --disable-photo-viewers disable photo ID viewers],
200       [if test "$enableval" = no ; then
201          AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing])
202       fi],enableval=yes)
203   gnupg_cv_enable_photo_viewers=$enableval
204   AC_MSG_RESULT($enableval)
205
206   if test "$gnupg_cv_enable_photo_viewers" = yes ; then
207     AC_MSG_CHECKING([whether to use a fixed photo ID viewer])
208     AC_ARG_WITH(photo-viewer,
209         [  --with-photo-viewer=FIXED_VIEWER  set a fixed photo ID viewer],
210         [if test "$withval" = yes ; then
211            withval=no
212         elif test "$withval" != no ; then
213            AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval",
214                             [if set, restrict photo-viewer to this])
215         fi],withval=no)
216     AC_MSG_RESULT($withval)
217   fi
218
219   AC_MSG_CHECKING([whether to enable external keyserver helpers])
220   AC_ARG_ENABLE(keyserver-helpers,
221       [  --disable-keyserver-helpers  disable all external keyserver support],
222       [if test "$enableval" = no ; then
223          AC_DEFINE(DISABLE_KEYSERVER_HELPERS,1,
224                   [define to disable keyserver helpers])
225       fi],enableval=yes)
226   gnupg_cv_enable_keyserver_helpers=$enableval
227   AC_MSG_RESULT($enableval)
228
229   if test "$gnupg_cv_enable_keyserver_helpers" = yes ; then
230     # LDAP is defined only after we confirm the library is available later
231     AC_MSG_CHECKING([whether LDAP keyserver support is requested])
232     AC_ARG_ENABLE(ldap,
233       AC_HELP_STRING([--disable-ldap],[disable LDAP keyserver interface only]),
234       try_ldap=$enableval, try_ldap=yes)
235     AC_MSG_RESULT($try_ldap)
236
237     AC_MSG_CHECKING([whether HKP keyserver support is requested])
238     AC_ARG_ENABLE(hkp,
239       AC_HELP_STRING([--disable-hkp],[disable HKP keyserver interface only]),
240       try_hkp=$enableval, try_hkp=yes)
241     AC_MSG_RESULT($try_hkp)
242
243     AC_MSG_CHECKING([whether finger key fetching support is requested])
244     AC_ARG_ENABLE(finger,
245       AC_HELP_STRING([--disable-finger],
246         [disable finger key fetching interface only]),
247       try_finger=$enableval, try_finger=yes)
248     AC_MSG_RESULT($try_finger)
249
250     AC_MSG_CHECKING([whether generic object key fetching support is requested])
251     AC_ARG_ENABLE(generic,
252       AC_HELP_STRING([--disable-generic],
253         [disable generic object key fetching interface only]),
254       try_generic=$enableval, try_generic=yes)
255     AC_MSG_RESULT($try_generic)
256
257     AC_MSG_CHECKING([whether email keyserver support is requested])
258     AC_ARG_ENABLE(mailto,
259       AC_HELP_STRING([--enable-mailto],
260         [enable email keyserver interface only]),
261       try_mailto=$enableval, try_mailto=no)
262     AC_MSG_RESULT($try_mailto)
263   fi
264
265   AC_MSG_CHECKING([whether keyserver exec-path is enabled])
266   AC_ARG_ENABLE(keyserver-path,
267       AC_HELP_STRING([--disable-keyserver-path],
268            [disable the exec-path option for keyserver helpers]),
269            [if test "$enableval" = no ; then
270               disable_keyserver_path=yes
271            fi],enableval=yes)
272   AC_MSG_RESULT($enableval)
273 fi
274
275
276 #
277 # Check for the key/uid cache size.  This can't be zero, but can be
278 # pretty small on embedded systems.  This is used for the gpg part.
279 #
280 AC_MSG_CHECKING([for the size of the key and uid cache])
281 AC_ARG_ENABLE(key-cache,
282         AC_HELP_STRING([--enable-key-cache=SIZE],
283                        [Set key cache to SIZE (default 4096)]),,enableval=4096)
284 if test "$enableval" = "no"; then
285    enableval=5
286 elif test "$enableval" = "yes" || test "$enableval" = ""; then
287    enableval=4096
288 fi
289 changequote(,)dnl
290 key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'`
291 changequote([,])dnl
292 if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then
293    AC_MSG_ERROR([invalid key-cache size])
294 fi
295 AC_MSG_RESULT($key_cache_size)
296 AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size,
297                   [Size of the key and UID caches])
298
299
300
301 #
302 # Check whether we want to use Linux capabilities
303 #
304 AC_MSG_CHECKING([whether use of capabilities is requested])
305 AC_ARG_WITH(capabilities,
306     [  --with-capabilities     use linux capabilities [default=no]],
307 [use_capabilities="$withval"],[use_capabilities=no])
308 AC_MSG_RESULT($use_capabilities)
309
310
311 #
312 # Allow disabling of internal CCID support.
313 # It is defined only after we confirm the library is available later
314 #
315 AC_MSG_CHECKING([whether to enable the internal CCID driver])
316 AC_ARG_ENABLE(ccid-driver,
317               AC_HELP_STRING([--disable-ccid-driver],
318                              [disable the internal CCID driver]),
319               use_ccid_driver=$enableval)
320 AC_MSG_RESULT($use_ccid_driver)
321
322
323 #
324 # To avoid double inclusion of config.h which might happen at some
325 # places, we add the usual double inclusion protection at the top of
326 # config.h.
327 #
328 AH_TOP([
329 #ifndef GNUPG_CONFIG_H_INCLUDED
330 #define GNUPG_CONFIG_H_INCLUDED
331 ])
332
333 #
334 # Stuff which goes at the bottom of config.h.
335 #
336 AH_BOTTOM([
337 /* This is the major version number of GnuPG so that
338    source included files can test for this.  Note, that
339    we use 2 here even for GnuPG 1.9.x. */
340 #define GNUPG_MAJOR_VERSION 2
341
342 /* Now to separate file name parts.
343    Please note that the string version must not contain more
344    than one character because the code assumes strlen()==1 */
345 #ifdef HAVE_DOSISH_SYSTEM
346 #define DIRSEP_C '\\'
347 #define DIRSEP_S "\\"
348 #define EXTSEP_C '.'
349 #define EXTSEP_S "."
350 #define PATHSEP_C ';'
351 #define PATHSEP_S ";"
352 #define EXEEXT_S ".exe"
353 #else
354 #define DIRSEP_C '/'
355 #define DIRSEP_S "/"
356 #define EXTSEP_C '.'
357 #define EXTSEP_S "."
358 #define PATHSEP_C ':'
359 #define PATHSEP_S ":"
360 #define EXEEXT_S ""
361 #endif
362
363 /* This is the same as VERSION, but should be overridden if the
364    platform cannot handle things like dots '.' in filenames. Set
365    SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION
366    uses for dots and dashes. */
367 #define SAFE_VERSION VERSION
368 #define SAFE_VERSION_DOT  '.'
369 #define SAFE_VERSION_DASH '-'
370
371 /* Some global constants. */
372 #ifdef HAVE_DRIVE_LETTERS
373 #define GNUPG_DEFAULT_HOMEDIR "c:/gnupg"
374 #elif defined(__VMS)
375 #define GNUPG_DEFAULT_HOMEDIR "/SYS\$LOGIN/gnupg"
376 #else
377 #define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
378 #endif
379 #define GNUPG_PRIVATE_KEYS_DIR "private-keys-v1.d"
380
381 /* For some systems (DOS currently), we hardcode the path here.  For
382    POSIX systems the values are constructed by the Makefiles, so that
383    the values may be overridden by the make invocations; this is to
384    comply with the GNU coding standards. */
385 #ifdef HAVE_DRIVE_LETTERS
386  /* FIXME: We need to use a function to determine these values depending
387     on the actual installation directory. */
388 #define GNUPG_BINDIR      "c:\\gnupg"
389 #define GNUPG_LIBEXECDIR  "c:\\gnupg"
390 #define GNUPG_LIBDIR      "c:\\gnupg"
391 #define GNUPG_DATADIR     "c:\\gnupg"
392 #define GNUPG_SYSCONFDIR  "c:\\gnupg"
393 #endif
394
395 /* Derive some other constants. */
396 #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
397 #define EXEC_TEMPFILE_ONLY
398 #endif
399
400
401 /* We didn't define endianness above, so get it from OS macros.  This
402    is intended for making fat binary builds on OS X. */
403 #if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST)
404 #if defined(__BIG_ENDIAN__)
405 #define BIG_ENDIAN_HOST 1
406 #elif defined(__LITTLE_ENDIAN__)
407 #define LITTLE_ENDIAN_HOST 1
408 #else
409 #error "No endianness found"
410 #endif
411 #endif
412
413
414 /* Hack used for W32: ldap.m4 also tests for the ASCII version of
415    ldap_start_tls_s because that is the actual symbol used in the
416    library.  winldap.h redefines it to our commonly used value,
417    thus we define our usual macro here.  */
418 #ifdef HAVE_LDAP_START_TLS_SA
419 # ifndef HAVE_LDAP_START_TLS_S
420 #  define HAVE_LDAP_START_TLS_S 1
421 # endif
422 #endif
423
424
425 /* Tell libgcrypt not to use its own libgpg-error implementation. */
426 #define USE_LIBGPG_ERROR 1
427
428 /* We use jnlib, so tell other modules about it.  */
429 #define HAVE_JNLIB_LOGGING 1
430
431 /* Our HTTP code is used in estream mode.  */
432 #define HTTP_USE_ESTREAM 1
433
434 /* Under W32 we do an explicit socket initialization, thus we need to
435    avoid the on-demand initialization which would also install an atexit
436    handler.  */
437 #define HTTP_NO_WSASTARTUP
438
439 /* We always include support for the OpenPGP card.  */
440 #define ENABLE_CARD_SUPPORT 1
441
442 /* We don't want the old assuan codes anymore. */
443 #define _ASSUAN_ONLY_GPG_ERRORS 1
444
445 /* We don't need any of the old gcrypt functions.  */
446 #define GCRYPT_NO_DEPRECATED 1
447
448 /* We explicitly need to disable PTH's soft mapping as Debian
449    currently enables it by default for no reason. */
450 #define PTH_SYSCALL_SOFT 0
451
452 /* We want to use the libgcrypt provided memory allocation for
453    asprintf.  */
454 #define _ESTREAM_PRINTF_MALLOC        gcry_malloc
455 #define _ESTREAM_PRINTF_FREE          gcry_free
456 #define _ESTREAM_PRINTF_EXTRA_INCLUDE "util.h"
457
458 #endif /*GNUPG_CONFIG_H_INCLUDED*/
459 ])
460
461
462 AM_MAINTAINER_MODE
463
464 # Checks for programs.
465 AC_MSG_NOTICE([checking for programs])
466 AC_PROG_MAKE_SET
467 AM_SANITY_CHECK
468 missing_dir=`cd $ac_aux_dir && pwd`
469 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
470 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
471 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
472 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
473 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
474 AC_PROG_AWK
475 AC_PROG_CC
476 AC_PROG_CPP
477 AM_PROG_CC_C_O
478 if test "x$ac_cv_prog_cc_c89" = "xno" ; then
479   AC_MSG_ERROR([[No C-89 compiler found]])
480 fi
481 AC_PROG_INSTALL
482 AC_PROG_LN_S
483 AC_PROG_RANLIB
484 AC_CHECK_TOOL(AR, ar, :)
485 AC_PATH_PROG(PERL,"perl")
486 AC_CHECK_TOOL(WINDRES, windres, :)
487 AC_ISC_POSIX
488 gl_EARLY
489 AC_SYS_LARGEFILE
490 GNUPG_CHECK_FAQPROG
491 GNUPG_CHECK_USTAR
492
493 # We need to compile and run a program on the build machine.  A
494 # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
495 # the AC archive is broken for autoconf 2.57.  Given that tehre is no
496 # newer version of that macro, we assume that it is also broken for
497 # autoconf 2.61 and thus we use a simple but usually sufficient
498 # approach.
499 AC_MSG_CHECKING(for cc for build)
500 if test "$cross_compiling" = "yes"; then
501   CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
502 else
503   CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
504 fi
505 AC_MSG_RESULT($CC_FOR_BUILD)
506 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
507
508
509
510 try_gettext=yes
511 have_dosish_system=no
512 have_w32_system=no
513 use_simple_gettext=no
514 case "${host}" in
515     *-mingw32*)
516         # special stuff for Windoze NT
517         ac_cv_have_dev_random=no
518         AC_DEFINE(USE_ONLY_8DOT3,1,
519                   [set this to limit filenames to the 8.3 format])
520         AC_DEFINE(HAVE_DRIVE_LETTERS,1,
521                   [defined if we must run on a stupid file system])
522         AC_DEFINE(USE_SIMPLE_GETTEXT,1,
523                   [because the Unix gettext has too much overhead on
524                    MingW32 systems and these systems lack Posix functions,
525                    we use a simplified version of gettext])
526         disable_keyserver_path=yes
527         have_dosish_system=yes
528         have_w32_system=yes
529         try_gettext="no"
530         use_simple_gettext=yes
531         ;;
532     i?86-emx-os2 | i?86-*-os2*emx )
533         # OS/2 with the EMX environment
534         ac_cv_have_dev_random=no
535         AC_DEFINE(HAVE_DRIVE_LETTERS)
536         have_dosish_system=yes
537         try_gettext="no"
538         ;;
539
540     i?86-*-msdosdjgpp*)
541         # DOS with the DJGPP environment
542         ac_cv_have_dev_random=no
543         AC_DEFINE(HAVE_DRIVE_LETTERS)
544         have_dosish_system=yes
545         try_gettext="no"
546         ;;
547
548     *-*-freebsd*)
549        # FreeBSD
550        CPPFLAGS="$CPPFLAGS -I/usr/local/include"
551        LDFLAGS="$LDFLAGS -L/usr/local/lib"
552        ;;
553
554     *-*-hpux*)
555         if test -z "$GCC" ; then
556             CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
557         fi
558         ;;
559     *-dec-osf4*)
560         if test -z "$GCC" ; then
561             # Suppress all warnings
562             # to get rid of the unsigned/signed char mismatch warnings.
563             CFLAGS="$CFLAGS -w"
564         fi
565         ;;
566     *-dec-osf5*)
567         if test -z "$GCC" ; then
568             # Use the newer compiler `-msg_disable ptrmismatch1' to
569             # get rid of the unsigned/signed char mismatch warnings.
570             # Using this may hide other pointer mismatch warnings, but
571             # it at least lets other warning classes through
572             CFLAGS="$CFLAGS -msg_disable ptrmismatch1"
573         fi
574         ;;
575     m68k-atari-mint)
576         ;;
577     *)
578        ;;
579 esac
580
581 if test "$have_dosish_system" = yes; then
582    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
583              [Defined if we run on some of the PCDOS like systems
584               (DOS, Windoze. OS/2) with special properties like
585               no file modes])
586 fi
587 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
588
589 AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes)
590
591 if test "$have_w32_system" = yes; then
592    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
593 fi
594 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
595
596 if test "$disable_keyserver_path" = yes; then
597     AC_DEFINE(DISABLE_KEYSERVER_PATH,1,
598               [Defined to disable exec-path for keyserver helpers])
599 fi
600
601 #
602 # Allows enabling the use of a standard socket by default This is
603 # gpg-agent's option --[no-]use-standard-socket.  For Windows we force
604 # the use of this.
605 #
606 AC_MSG_CHECKING([whether to use a standard socket by default])
607 AC_ARG_ENABLE(standard-socket,
608               AC_HELP_STRING([--enable-standard-socket],
609                              [use a standard socket for the agent by default]),
610               use_standard_socket=$enableval)
611 tmp=""
612 if test "$use_standard_socket" != yes; then
613   if test "$have_w32_system" = yes; then
614     use_standard_socket=yes
615     tmp=" (forced)"
616   fi
617 fi
618 AC_MSG_RESULT($use_standard_socket$tmp)
619 if test "$use_standard_socket" = yes; then
620   AC_DEFINE(USE_STANDARD_SOCKET,1,
621             [Use a standard socket for the agent by default])
622 fi
623
624
625 # (These need to go after AC_PROG_CC so that $EXEEXT is defined)
626 AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any])
627
628 if test x"$try_hkp" = xyes ; then
629   AC_SUBST(GPGKEYS_HKP,"gpg2keys_hkp$EXEEXT")
630 fi
631
632 if test x"$try_finger" = xyes ; then
633   AC_SUBST(GPGKEYS_FINGER,"gpg2keys_finger$EXEEXT")
634 fi
635
636
637
638 #
639 # Checks for libraries.
640 #
641 AC_MSG_NOTICE([checking for libraries])
642
643
644 #
645 # libgpg-error is a library with error codes shared between GnuPG
646 # related projects.
647 #
648 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
649                   have_gpg_error=yes,have_gpg_error=no)
650
651
652 #
653 # Libgcrypt is our generic crypto library
654 #
655 AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION",
656         have_libgcrypt=yes,have_libgcrypt=no)
657
658
659 #
660 # libassuan is used for IPC
661 #
662 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
663                   have_libassuan=yes,have_libassuan=no)
664 if test "$have_libassuan" = "yes"; then
665   AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version",
666             [version of the libbassuan library])
667 fi
668
669
670
671 #
672 # libksba is our X.509 support library
673 #
674 AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no)
675
676
677 #
678 # libusb allows us to use the integrated CCID smartcard reader driver.
679 #
680 # FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs.
681 if test "$use_ccid_driver" = yes ; then
682   AC_CHECK_LIB(usb, usb_bulk_write,
683                 [ LIBUSB_LIBS="$LIBUSB_LIBS -lusb"
684                   AC_DEFINE(HAVE_LIBUSB,1,
685                            [defined if libusb is available])
686                   have_libusb=yes
687                ])
688   AC_CHECK_FUNCS(usb_create_match)
689 fi
690 AC_SUBST(LIBUSB_LIBS)
691
692 #
693 # Check wether it is necessary to link against libdl.
694 #
695 gnupg_dlopen_save_libs="$LIBS"
696 LIBS=""
697 AC_SEARCH_LIBS(dlopen, c dl,,,)
698 DL_LIBS=$LIBS
699 AC_SUBST(DL_LIBS)
700 LIBS="$gnupg_dlopen_save_libs"
701
702 #
703 # Checks for symcryptrun:
704 #
705
706 # libutil has openpty() and login_tty().
707 AC_CHECK_LIB(util, openpty,
708               [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil"
709                 AC_DEFINE(HAVE_LIBUTIL,1,
710                          [defined if libutil is available])
711              ])
712 AC_SUBST(LIBUTIL_LIBS)
713
714 # shred is used to clean temporary plain text files.
715 AC_PATH_PROG(SHRED, shred, /usr/bin/shred)
716 AC_DEFINE_UNQUOTED(SHRED,
717         "${SHRED}", [defines the filename of the shred program])
718
719
720
721 #
722 # Check whether the GNU Pth library is available
723 # Note, that we include a Pth emulation for W32.
724 #
725 GNUPG_PATH_PTH
726 if test "$have_pth" = "yes"; then
727   AC_DEFINE(USE_GNU_PTH, 1,
728               [Defined if the GNU Portable Thread Library should be used])
729 else
730   AC_MSG_WARN([[
731 ***
732 *** To support concurrent access to the gpg-agent and the SCdaemon
733 *** we need the support of the GNU Portable Threads Library.
734 *** Download it from ftp://ftp.gnu.org/gnu/pth/
735 *** On a Debian GNU/Linux system you might want to try
736 ***   apt-get install libpth-dev
737 ***]])
738 fi
739
740
741 AC_MSG_NOTICE([checking for networking options])
742
743 #
744 # Must check for network library requirements before doing link tests
745 # for ldap, for example. If ldap libs are static (or dynamic and without
746 # ELF runtime link paths), then link will fail and LDAP support won't
747 # be detected.
748 #
749 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
750         [NETLIBS="-lnsl $NETLIBS"]))
751 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
752         [NETLIBS="-lsocket $NETLIBS"]))
753
754
755 #
756 # Check for ADNS.
757 #
758 _cppflags="${CPPFLAGS}"
759 _ldflags="${LDFLAGS}"
760 AC_ARG_WITH(adns,
761             AC_HELP_STRING([--with-adns=DIR],
762                            [look for the adns library in DIR]),
763             [if test -d "$withval"; then
764                CPPFLAGS="${CPPFLAGS} -I$withval/include"
765                LDFLAGS="${LDFLAGS} -L$withval/lib"
766              fi])
767 if test "$with_adns" != "no"; then
768   AC_CHECK_HEADERS(adns.h,
769                 AC_CHECK_LIB(adns, adns_init,
770                              [have_adns=yes],
771                              [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}]),
772                 [CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}])
773 fi
774 if test "$have_adns" = "yes"; then
775   ADNSLIBS="-ladns"
776 fi
777 AC_SUBST(ADNSLIBS)
778 # Newer adns versions feature a free function to be used under W32.
779 AC_CHECK_FUNCS(adns_free)
780
781
782 #
783 # Now try for the resolver functions so we can use DNS for SRV, PA and CERT.
784 #
785 if test x"$try_hkp" = xyes || test x"$try_http" = xyes ; then
786   AC_ARG_ENABLE(dns-srv,
787      AC_HELP_STRING([--disable-dns-srv],
788                     [disable the use of DNS SRV in HKP and HTTP]),
789                 use_dns_srv=$enableval,use_dns_srv=yes)
790 fi
791
792 AC_ARG_ENABLE(dns-pka,
793    AC_HELP_STRING([--disable-dns-pka],
794         [disable the use of PKA records in DNS]),
795    use_dns_pka=$enableval,use_dns_pka=yes)
796
797 AC_ARG_ENABLE(dns-cert,
798    AC_HELP_STRING([--disable-dns-cert],
799         [disable the use of CERT records in DNS]),
800    use_dns_cert=$enableval,use_dns_cert=yes)
801
802 if test x"$use_dns_pka" = xyes || test x"$use_dns_srv" = xyes \
803    || test x"$use_dns_cert" = xyes; then
804   _dns_save_libs=$LIBS
805   LIBS=""
806   # the double underscore thing is a glibc-ism?
807   AC_SEARCH_LIBS(res_query,resolv bind,,
808                  AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no))
809   AC_SEARCH_LIBS(dn_expand,resolv bind,,
810                  AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no))
811   AC_SEARCH_LIBS(dn_skipname,resolv bind,,
812                  AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no))
813
814   if test x"$have_resolver" != xno ; then
815
816     # Make sure that the BIND 4 resolver interface is workable before
817     # enabling any code that calls it.  At some point I'll rewrite the
818     # code to use the BIND 8 resolver API.
819     # We might also want to use adns instead.  Problem with ADNS is that
820     # it does not support v6.
821
822     AC_MSG_CHECKING([whether the resolver is usable])
823     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
824 #include <netinet/in.h>
825 #include <arpa/nameser.h>
826 #include <resolv.h>]],
827 [[unsigned char answer[PACKETSZ];
828   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
829   dn_skipname(0,0);
830   dn_expand(0,0,0,0,0);
831 ]])],have_resolver=yes,have_resolver=no)
832     AC_MSG_RESULT($have_resolver)
833
834     # This is Apple-specific and somewhat bizarre as they changed the
835     # define in bind 8 for some reason.
836
837     if test x"$have_resolver" != xyes ; then
838        AC_MSG_CHECKING(
839              [whether I can make the resolver usable with BIND_8_COMPAT])
840        AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define BIND_8_COMPAT
841 #include <sys/types.h>
842 #include <netinet/in.h>
843 #include <arpa/nameser.h>
844 #include <resolv.h>]],
845 [[unsigned char answer[PACKETSZ];
846   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
847   dn_skipname(0,0); dn_expand(0,0,0,0,0);
848 ]])],[have_resolver=yes ; need_compat=yes])
849        AC_MSG_RESULT($have_resolver)
850     fi
851   fi
852
853   if test x"$have_resolver" = xyes ; then
854      DNSLIBS=$LIBS
855
856      if test x"$use_dns_srv" = xyes ; then
857         AC_DEFINE(USE_DNS_SRV,1,[define to use DNS SRV])
858      fi
859
860      if test x"$use_dns_pka" = xyes ; then
861         AC_DEFINE(USE_DNS_PKA,1,[define to use our experimental DNS PKA])
862      fi
863
864      if test x"$use_dns_cert" = xyes ; then
865         AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT])
866      fi
867
868      if test x"$need_compat" = xyes ; then
869         AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism])
870      fi
871   else
872      # If we have no resolver library but ADNS (e.g. under W32) enable the
873      # code parts which can be used with ADNS.
874      if test x"$have_adns" = xyes ; then
875         DNSLIBS="$ADNSLIBS"
876         AC_DEFINE(USE_ADNS,1,[Use ADNS as resolver library.])
877
878         if test x"$use_dns_srv" = xyes ; then
879            AC_DEFINE(USE_DNS_SRV,1)
880         fi
881
882         if test x"$use_dns_pka" = xyes ; then
883            AC_DEFINE(USE_DNS_PKA,1)
884         fi
885
886         if test x"$use_dns_cert" = xyes ; then
887            AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT])
888         fi
889      else
890         use_dns_srv=no
891         use_dns_pka=no
892         use_dns_cert=no
893      fi
894   fi
895
896   LIBS=$_dns_save_libs
897 fi
898
899 AC_SUBST(DNSLIBS)
900
901 AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes)
902
903
904 #
905 # Check for LDAP
906 #
907 if test "$try_ldap" = yes ; then
908    GNUPG_CHECK_LDAP($NETLIBS)
909 fi
910
911 #
912 # Check for curl.  We fake the curl API if libcurl isn't installed.
913 # We require 7.10 or later as we use curl_version_info().
914 #
915 LIBCURL_CHECK_CONFIG([yes],[7.10],,[fake_curl=yes])
916 AM_CONDITIONAL(FAKE_CURL,test x"$fake_curl" = xyes)
917
918 # Generic, for us, means curl
919
920 if test x"$try_generic" = xyes ; then
921    AC_SUBST(GPGKEYS_CURL,"gpg2keys_curl$EXEEXT")
922 fi
923
924 #
925 # Check for sendmail
926 #
927 # This isn't necessarily sendmail itself, but anything that gives a
928 # sendmail-ish interface to the outside world.  That includes Exim,
929 # Postfix, etc.  Basically, anything that can handle "sendmail -t".
930 if test "$try_mailto" = yes ; then
931   AC_ARG_WITH(mailprog,
932       AC_HELP_STRING([--with-mailprog=NAME],
933                      [use "NAME -t" for mail transport]),
934              ,with_mailprog=yes)
935
936   if test x"$with_mailprog" = xyes ; then
937     AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib)
938     if test "$ac_cv_path_SENDMAIL" ; then
939       GPGKEYS_MAILTO="gpg2keys_mailto"
940     fi
941   elif test x"$with_mailprog" != xno ; then
942     AC_MSG_CHECKING([for a mail transport program])
943     AC_SUBST(SENDMAIL,$with_mailprog)
944     AC_MSG_RESULT($with_mailprog)
945     GPGKEYS_MAILTO="gpg2keys_mailto"
946   fi
947 fi
948
949 AC_SUBST(GPGKEYS_MAILTO)
950
951 #
952 # Construct a printable name of the OS
953 #
954 case "${host}" in
955     *-mingw32*)
956         PRINTABLE_OS_NAME="MingW32"
957         ;;
958     *-*-cygwin*)
959         PRINTABLE_OS_NAME="Cygwin"
960         ;;
961     i?86-emx-os2 | i?86-*-os2*emx )
962         PRINTABLE_OS_NAME="OS/2"
963         ;;
964     i?86-*-msdosdjgpp*)
965         PRINTABLE_OS_NAME="MSDOS/DJGPP"
966         try_dynload=no
967         ;;
968     *-linux*)
969         PRINTABLE_OS_NAME="GNU/Linux"
970         ;;
971     *)
972         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
973         ;;
974 esac
975 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
976                    [A human readable text with the name of the OS])
977
978
979 #
980 # Checking for iconv
981 #
982 missing_iconv=no
983 AM_ICONV
984 if test "$am_cv_func_iconv" != yes; then
985    missing_iconv=yes
986 fi
987
988
989 #
990 # Check for gettext
991 #
992 # This is "GNU gnupg" - The project-id script from gettext
993 #                       needs this string
994 #
995 AC_MSG_NOTICE([checking for gettext])
996 AM_PO_SUBDIRS
997 AM_GNU_GETTEXT_VERSION([0.17])
998 if test "$try_gettext" = yes; then
999   AM_GNU_GETTEXT([external],[need-ngettext])
1000
1001   # gettext requires some extra checks.  These really should be part of
1002   # the basic AM_GNU_GETTEXT macro.  TODO: move other gettext-specific
1003   # function checks to here.
1004
1005   AC_CHECK_FUNCS(strchr)
1006 else
1007   USE_NLS=no
1008   USE_INCLUDED_LIBINTL=no
1009   BUILD_INCLUDED_LIBINTL=no
1010   POSUB=po
1011   AC_SUBST(USE_NLS)
1012   AC_SUBST(USE_INCLUDED_LIBINTL)
1013   AC_SUBST(BUILD_INCLUDED_LIBINTL)
1014   AC_SUBST(POSUB)
1015 fi
1016
1017 # We use HAVE_LANGINFO_CODESET in a couple of places.
1018 AM_LANGINFO_CODESET
1019
1020 # Checks required for our use locales
1021 gt_LC_MESSAGES
1022
1023
1024 #
1025 # SELinux support
1026 #
1027 if test "$selinux_support" = yes ; then
1028   AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support])
1029 fi
1030
1031
1032 #
1033 # Checks for header files.
1034 #
1035 AC_MSG_NOTICE([checking for header files])
1036 AC_HEADER_STDC
1037 AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h])
1038 AC_CHECK_HEADERS([pty.h utmp.h pwd.h inttypes.h])
1039 AC_HEADER_TIME
1040
1041
1042 #
1043 # Checks for typedefs, structures, and compiler characteristics.
1044 #
1045 AC_MSG_NOTICE([checking for system characteristics])
1046 AC_C_CONST
1047 AC_C_INLINE
1048 AC_C_VOLATILE
1049 AC_TYPE_SIZE_T
1050 AC_TYPE_MODE_T
1051 AC_TYPE_SIGNAL
1052 AC_DECL_SYS_SIGLIST
1053
1054 gl_HEADER_SYS_SOCKET
1055 gl_TYPE_SOCKLEN_T
1056
1057 AC_ARG_ENABLE(endian-check,
1058               AC_HELP_STRING([--disable-endian-check],
1059               [disable the endian check and trust the OS provided macros]),
1060               endiancheck=$enableval,endiancheck=yes)
1061
1062 if test x"$endiancheck" = xyes ; then
1063   GNUPG_CHECK_ENDIAN
1064 fi
1065
1066 # fixme: we should get rid of the byte type
1067 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
1068 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
1069 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
1070 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
1071 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
1072
1073 AC_CHECK_SIZEOF(unsigned short)
1074 AC_CHECK_SIZEOF(unsigned int)
1075 AC_CHECK_SIZEOF(unsigned long)
1076 AC_CHECK_SIZEOF(unsigned long long)
1077 AC_CHECK_SIZEOF(time_t,,[[
1078 #include <stdio.h>
1079 #if TIME_WITH_SYS_TIME
1080 # include <sys/time.h>
1081 # include <time.h>
1082 #else
1083 # if HAVE_SYS_TIME_H
1084 #  include <sys/time.h>
1085 # else
1086 #  include <time.h>
1087 # endif
1088 #endif
1089 ]])
1090
1091
1092 # Ensure that we have UINT64_C before we bother to check for uint64_t
1093 # Fixme: really needed in gnupg?  I think it is only useful in libcgrypt.
1094 AC_CACHE_CHECK([for UINT64_C],[gnupg_cv_uint64_c_works],
1095    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],
1096                                       [[uint64_t foo=UINT64_C(42);]])],
1097                                       [gnupg_cv_uint64_c_works=yes],
1098                                       [gnupg_cv_uint64_c_works=no]   ))
1099 if test "$gnupg_cv_uint64_c_works" = "yes" ; then
1100    AC_CHECK_SIZEOF(uint64_t)
1101 fi
1102
1103 if test "$ac_cv_sizeof_unsigned_short" = "0" \
1104    || test "$ac_cv_sizeof_unsigned_int" = "0" \
1105    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
1106     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
1107 fi
1108
1109
1110 #
1111 # Checks for library functions.
1112 #
1113 AC_MSG_NOTICE([checking for library functions])
1114 AC_CHECK_DECLS(getpagesize)
1115 AC_FUNC_FSEEKO
1116 AC_FUNC_VPRINTF
1117 AC_FUNC_FORK
1118 AC_CHECK_FUNCS([strerror strlwr tcgetattr mmap])
1119 AC_CHECK_FUNCS([strcasecmp strncasecmp ctermid times gmtime_r])
1120 AC_CHECK_FUNCS([unsetenv fcntl ftruncate inet_ntop])
1121 AC_CHECK_FUNCS([gettimeofday getrusage getrlimit setrlimit clock_gettime])
1122 AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale])
1123 AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe stat getaddrinfo])
1124 AC_CHECK_FUNCS([ttyname rand ftello fsync stat])
1125
1126 AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
1127
1128 #
1129 # These are needed by libjnlib - fixme: we should use a jnlib.m4
1130 # Note:  We already checked pwd.h.
1131 AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol])
1132 AC_CHECK_FUNCS([memrchr isascii timegm getrusage setrlimit stat setlocale])
1133 AC_CHECK_FUNCS([flockfile funlockfile fopencookie funopen getpwnam getpwuid])
1134
1135 #
1136 # gnulib checks
1137 #
1138 gl_SOURCE_BASE([gl])
1139 gl_M4_BASE([gl/m4])
1140 gl_MODULES([setenv mkdtemp xsize strpbrk])
1141 gl_INIT
1142
1143
1144 #
1145 # W32 specific test
1146 #
1147 GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
1148
1149 #
1150 # Sanity check regex.  Tests adapted from mutt.
1151 #
1152 AC_MSG_CHECKING([whether regular expression support is requested])
1153 AC_ARG_ENABLE(regex,
1154   AC_HELP_STRING([--disable-regex],
1155     [do not handle regular expressions in trust signatures]),
1156   use_regex=$enableval, use_regex=yes)
1157 AC_MSG_RESULT($use_regex)
1158
1159 if test "$use_regex" = yes ; then
1160   _cppflags="${CPPFLAGS}"
1161   _ldflags="${LDFLAGS}"
1162   AC_ARG_WITH(regex,
1163      AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]),
1164       [
1165       if test -d "$withval" ; then
1166         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1167         LDFLAGS="${LDFLAGS} -L$withval/lib"
1168       fi
1169       ],withval="")
1170
1171   # Does the system have regex functions at all?
1172   AC_SEARCH_LIBS([regcomp], [regex])
1173   AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no)
1174
1175   if test $gnupg_cv_have_regex = no; then
1176     use_regex=no
1177   else
1178     if test x"$cross_compiling" = xyes; then
1179       AC_MSG_WARN([cross compiling; assuming regexp libray is not broken])
1180     else
1181       AC_CACHE_CHECK([whether your system's regexp library is broken],
1182        [gnupg_cv_regex_broken],
1183        AC_TRY_RUN([
1184 #include <unistd.h>
1185 #include <regex.h>
1186 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); }],
1187        gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes))
1188
1189       if test $gnupg_cv_regex_broken = yes; then
1190         AC_MSG_WARN([your regex is broken - disabling regex use])
1191         use_regex=no
1192       fi
1193     fi
1194   fi
1195   CPPFLAGS="${_cppflags}"
1196   LDFLAGS="${_ldflags}"
1197 fi
1198
1199 if test "$use_regex" != yes ; then
1200   AC_DEFINE(DISABLE_REGEX,1, [Define to disable regular expression support])
1201 fi
1202 AM_CONDITIONAL(DISABLE_REGEX, test x"$use_regex" != xyes)
1203
1204
1205
1206 #
1207 # Do we have zlib? Must do it here because Solaris failed
1208 # when compiling a conftest (due to the "-lz" from LIBS).
1209 # Note that we combine zlib and bzlib2 in ZLIBS.
1210 #
1211 _cppflags="${CPPFLAGS}"
1212 _ldflags="${LDFLAGS}"
1213 AC_ARG_WITH(zlib,
1214   [  --with-zlib=DIR         use libz in DIR],[
1215     if test -d "$withval"; then
1216       CPPFLAGS="${CPPFLAGS} -I$withval/include"
1217       LDFLAGS="${LDFLAGS} -L$withval/lib"
1218     fi
1219   ])
1220
1221 AC_CHECK_HEADER(zlib.h,
1222       AC_CHECK_LIB(z, deflateInit2_,
1223        ZLIBS="-lz",
1224        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1225        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
1226
1227 #
1228 # Check whether we can support bzip2
1229 #
1230 if test "$use_bzip2" = yes ; then
1231   _cppflags="${CPPFLAGS}"
1232   _ldflags="${LDFLAGS}"
1233   AC_ARG_WITH(bzip2,
1234      AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]),
1235       [
1236       if test -d "$withval" ; then
1237         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1238         LDFLAGS="${LDFLAGS} -L$withval/lib"
1239       fi
1240       ],withval="")
1241
1242   # Checking alongside stdio.h as an early version of bzip2 (1.0)
1243   # required stdio.h to be included before bzlib.h, and Solaris 9 is
1244   # woefully out of date.
1245   if test "$withval" != no ; then
1246      AC_CHECK_HEADER(bzlib.h,
1247         AC_CHECK_LIB(bz2,BZ2_bzCompressInit,
1248           [
1249           have_bz2=yes
1250           ZLIBS="$ZLIBS -lbz2"
1251           AC_DEFINE(HAVE_BZIP2,1,
1252                   [Defined if the bz2 compression library is available])
1253           ],
1254           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1255           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include <stdio.h>])
1256   fi
1257 fi
1258 AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes")
1259 AC_SUBST(ZLIBS)
1260
1261
1262 # Check for readline support
1263 GNUPG_CHECK_READLINE
1264
1265
1266 if test "$development_version" = yes; then
1267     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1268             [Defined if this is not a regular release])
1269 fi
1270
1271 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1272
1273 GNUPG_CHECK_GNUMAKE
1274
1275 # Add some extra libs here so that previous tests don't fail for
1276 # mysterious reasons - the final link step should bail out.
1277 # W32SOCKLIBS is also defined so that if can be used for tools not
1278 # requiring any network stuff but linking to code in libcommon which
1279 # tracks in winsock stuff (e.g. init_common_subsystems.
1280 if test "$have_w32_system" = yes; then
1281    W32SOCKLIBS="-lws2_32"
1282    NETLIBS="${NETLIBS} ${W32SOCKLIBS}"
1283 fi
1284
1285 AC_SUBST(NETLIBS)
1286 AC_SUBST(W32SOCKLIBS)
1287
1288 #
1289 # Setup gcc specific options
1290 #
1291 AC_MSG_NOTICE([checking for cc features])
1292 if test "$GCC" = yes; then
1293     # Check whether gcc does not emit a diagnositc for unknow -Wno-*
1294     # options.  This is the case for gcc >= 4.6
1295     AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
1296     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1297 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
1298 #kickerror
1299 #endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
1300     AC_MSG_RESULT($_gcc_silent_wno)
1301
1302     # Note that it is okay to use CFLAGS here because this are just
1303     # warning options and the user should have a chance of overriding
1304     # them.
1305     if test "$USE_MAINTAINER_MODE" = "yes"; then
1306         CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
1307         CFLAGS="$CFLAGS -Wformat -Wno-format-y2k -Wformat-security"
1308         if test x"$_gcc_silent_wno" = xyes ; then
1309           _gcc_wopt=yes
1310         else
1311           AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1312           _gcc_cflags_save=$CFLAGS
1313           CFLAGS="-Wno-missing-field-initializers"
1314           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1315                             [_gcc_wopt=yes],[_gcc_wopt=no])
1316           AC_MSG_RESULT($_gcc_wopt)
1317           CFLAGS=$_gcc_cflags_save;
1318         fi
1319         if test x"$_gcc_wopt" = xyes ; then
1320           CFLAGS="$CFLAGS -W -Wno-sign-compare -Wno-missing-field-initializers"
1321         fi
1322
1323         AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
1324         _gcc_cflags_save=$CFLAGS
1325         CFLAGS="-Wdeclaration-after-statement"
1326         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1327                           [_gcc_wopt=yes],[_gcc_wopt=no])
1328         AC_MSG_RESULT($_gcc_wopt)
1329         CFLAGS=$_gcc_cflags_save;
1330         if test x"$_gcc_wopt" = xyes ; then
1331           CFLAGS="$CFLAGS -Wdeclaration-after-statement"
1332         fi
1333     else
1334         CFLAGS="$CFLAGS -Wall"
1335     fi
1336
1337     if test x"$_gcc_silent_wno" = xyes ; then
1338       _gcc_psign=yes
1339     else
1340       AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
1341       _gcc_cflags_save=$CFLAGS
1342       CFLAGS="-Wno-pointer-sign"
1343       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1344                         [_gcc_psign=yes],[_gcc_psign=no])
1345       AC_MSG_RESULT($_gcc_psign)
1346       CFLAGS=$_gcc_cflags_save;
1347     fi
1348     if test x"$_gcc_psign" = xyes ; then
1349        CFLAGS="$CFLAGS -Wno-pointer-sign"
1350     fi
1351
1352     AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1353     _gcc_cflags_save=$CFLAGS
1354     CFLAGS="-Wpointer-arith"
1355     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[_gcc_psign=yes],[_gcc_psign=no])
1356     AC_MSG_RESULT($_gcc_psign)
1357     CFLAGS=$_gcc_cflags_save;
1358     if test x"$_gcc_psign" = xyes ; then
1359        CFLAGS="$CFLAGS -Wpointer-arith"
1360     fi
1361
1362     # The undocumented option -Wno-psabi suppresses the annoying
1363     #   "the ABI of passing union with long double has changed in GCC 4.4"
1364     # which is emitted in estream-printf.c but entirely irrelvant
1365     # because that union is local to the file.
1366     if test x"$_gcc_silent_wno" = xyes ; then
1367        CFLAGS="$CFLAGS -Wno-psabi"
1368     fi
1369 fi
1370
1371
1372 #
1373 # This is handy for debugging so the compiler doesn't rearrange
1374 # things and eliminate variables.
1375 #
1376 AC_ARG_ENABLE(optimization,
1377    AC_HELP_STRING([--disable-optimization],
1378                   [disable compiler optimization]),
1379                   [if test $enableval = no ; then
1380                       CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1381                    fi])
1382
1383 #
1384 # Prepare building of estream
1385 #
1386 estream_INIT
1387
1388
1389 #
1390 # Decide what to build
1391 #
1392 if test "$have_adns" = "yes"; then
1393   AC_SUBST(GPGKEYS_KDNS, "gpg2keys_kdns$EXEEXT")
1394 fi
1395
1396
1397 missing_pth=no
1398 if test $have_ksba = no; then
1399   build_gpgsm=no
1400   build_scdaemon=no
1401 fi
1402
1403 build_agent_threaded=""
1404 if test "$build_agent" = "yes"; then
1405   if test $have_pth = no; then
1406      build_agent_threaded="(not multi-threaded)"
1407      missing_pth=yes
1408   fi
1409 fi
1410
1411 build_scdaemon_extra=""
1412 if test "$build_scdaemon" = "yes"; then
1413   tmp=""
1414   if test $have_pth = no; then
1415      build_scdaemon_extra="not multi-threaded"
1416      tmp=", "
1417      missing_pth=yes
1418   fi
1419   if test $have_libusb = no; then
1420      build_scdaemon_extra="${tmp}without internal CCID driver"
1421      tmp=", "
1422   fi
1423   if test -n "$build_scdaemon_extra"; then
1424      build_scdaemon_extra="(${build_scdaemon_extra})"
1425   fi
1426 fi
1427
1428
1429 if test "$build_agent_only" = "yes" ; then
1430   build_gpg=no
1431   build_gpgsm=no
1432   build_scdaemon=no
1433   build_tools=no
1434   build_doc=no
1435 fi
1436
1437
1438 AM_CONDITIONAL(BUILD_GPG,   test "$build_gpg" = "yes")
1439 AM_CONDITIONAL(BUILD_GPGSM, test "$build_gpgsm" = "yes")
1440 AM_CONDITIONAL(BUILD_AGENT, test "$build_agent" = "yes")
1441 AM_CONDITIONAL(BUILD_SCDAEMON, test "$build_scdaemon" = "yes")
1442 AM_CONDITIONAL(BUILD_TOOLS, test "$build_tools" = "yes")
1443 AM_CONDITIONAL(BUILD_DOC,   test "$build_doc" = "yes")
1444 AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes")
1445 AM_CONDITIONAL(BUILD_GPGTAR,      test "$build_gpgtar" = "yes")
1446
1447 AM_CONDITIONAL(RUN_GPG_TESTS,
1448         test x$cross_compiling = xno -a "$build_gpg" = yes )
1449
1450
1451 #
1452 # Provide information about the build.
1453 #
1454 BUILD_REVISION="mym4_revision"
1455 AC_SUBST(BUILD_REVISION)
1456 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
1457                    [GIT commit id revision used to build this package])
1458
1459 changequote(,)dnl
1460 BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
1461 changequote([,])dnl
1462 BUILD_FILEVERSION="${BUILD_FILEVERSION}mym4_revision_dec"
1463 AC_SUBST(BUILD_FILEVERSION)
1464
1465 BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
1466 AC_SUBST(BUILD_TIMESTAMP)
1467 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
1468                    [The time this package was configured for a build])
1469 BUILD_HOSTNAME="$ac_hostname"
1470 AC_SUBST(BUILD_HOSTNAME)
1471
1472
1473 #
1474 # Print errors here so that they are visible all
1475 # together and the user can acquire them all together.
1476 #
1477 die=no
1478 if test "$have_gpg_error" = "no"; then
1479    die=yes
1480    AC_MSG_NOTICE([[
1481 ***
1482 *** You need libgpg-error to build this program.
1483 **  This library is for example available at
1484 ***   ftp://ftp.gnupg.org/gcrypt/libgpg-error
1485 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
1486 ***]])
1487 fi
1488 if test "$have_libgcrypt" = "no"; then
1489    die=yes
1490    AC_MSG_NOTICE([[
1491 ***
1492 *** You need libgcrypt to build this program.
1493 **  This library is for example available at
1494 ***   ftp://ftp.gnupg.org/gcrypt/libgcrypt/
1495 *** (at least version $NEED_LIBGCRYPT_VERSION using API $NEED_LIBGCRYPT_API is required.)
1496 ***]])
1497 fi
1498 if test "$have_libassuan" = "no"; then
1499    die=yes
1500    AC_MSG_NOTICE([[
1501 ***
1502 *** You need libassuan to build this program.
1503 *** This library is for example available at
1504 ***   ftp://ftp.gnupg.org/gcrypt/libassuan/
1505 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
1506 ***]])
1507 fi
1508 if test "$have_ksba" = "no"; then
1509     AC_MSG_NOTICE([[
1510 ***
1511 *** You need libksba to build this program.
1512 *** This library is for example available at
1513 ***   ftp://ftp.gnupg.org/gcrypt/libksba/
1514 *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required).
1515 ***]])
1516 fi
1517 if test "$missing_pth" = "yes"; then
1518     AC_MSG_NOTICE([[
1519 ***
1520 *** It is now required to build with support for the
1521 *** GNU Portable Threads Library (Pth). Please install this
1522 *** library first.  The library is for example available at
1523 ***   ftp://ftp.gnu.org/gnu/pth/
1524 *** On a Debian GNU/Linux system you can install it using
1525 ***   apt-get install libpth-dev
1526 *** To build GnuPG for Windows you need to use the W32PTH
1527 *** package; available at:
1528 ***   ftp://ftp.g10code.com/g10code/w32pth/
1529 ***]])
1530    die=yes
1531 fi
1532 if test "$missing_iconv" = "yes"; then
1533     AC_MSG_NOTICE([[
1534 ***
1535 *** It is now required to build with support for iconv
1536 *** Please install a suitable iconv implementation.
1537 ***]])
1538    die=yes
1539 fi
1540
1541 if test "$die" = "yes"; then
1542     AC_MSG_ERROR([[
1543 ***
1544 *** Required libraries not found. Please consult the above messages
1545 *** and install them before running configure again.
1546 ***]])
1547 fi
1548
1549
1550
1551 AC_CONFIG_FILES([ m4/Makefile
1552 Makefile
1553 po/Makefile.in
1554 gl/Makefile
1555 include/Makefile
1556 jnlib/Makefile
1557 common/Makefile
1558 common/w32info-rc.h
1559 kbx/Makefile
1560 g10/Makefile
1561 sm/Makefile
1562 agent/Makefile
1563 scd/Makefile
1564 keyserver/Makefile
1565 keyserver/gpg2keys_mailto
1566 keyserver/gpg2keys_test
1567 tools/gpg-zip
1568 tools/Makefile
1569 doc/Makefile
1570 tests/Makefile
1571 tests/openpgp/Makefile
1572 tests/pkits/Makefile
1573 ])
1574 AC_OUTPUT
1575
1576
1577 echo "
1578         GnuPG v${VERSION} has been configured as follows:
1579
1580         Revision:  mym4_revision  (mym4_revision_dec)
1581         Platform:  $PRINTABLE_OS_NAME ($host)
1582
1583         OpenPGP:   $build_gpg
1584         S/MIME:    $build_gpgsm
1585         Agent:     $build_agent $build_agent_threaded
1586         Smartcard: $build_scdaemon $build_scdaemon_extra
1587         Gpgtar:    $build_gpgtar
1588
1589         Protect tool:      $show_gnupg_protect_tool_pgm
1590         Default agent:     $show_gnupg_agent_pgm
1591         Default pinentry:  $show_gnupg_pinentry_pgm
1592         Default scdaemon:  $show_gnupg_scdaemon_pgm
1593         Default dirmngr:   $show_gnupg_dirmngr_pgm
1594 "
1595 if test x"$use_regex" != xyes ; then
1596 echo "
1597         Warning: No regular expression support available.
1598                  OpenPGP trust signatures won't work.
1599                  gpg-check-pattern will not be build.
1600 "
1601 fi