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