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