1# configure.ac script for GnuPG
2# Copyright (C) 1998-2015 Free Software Foundation, Inc.
3# Copyright (C) 1998-2015 Werner Koch
4#
5# This file is part of GnuPG.
6#
7# GnuPG is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 3 of the License, or
10# (at your option) any later version.
11#
12# GnuPG is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, see <http://www.gnu.org/licenses/>.
19#
20# (Process this file with autoconf to produce a configure script.)
21
22AC_PREREQ(2.61)
23min_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-1.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.
29m4_define([mym4_version], [1.4.23])
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.
35m4_define([mym4_revision],
36          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
37m4_define([mym4_revision_dec],
38          m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
39m4_define([mym4_betastring],
40          m4_esyscmd_s([git describe --match 'gnupg-1.[0-9].*[0-9]' --long|\
41                        awk -F- '$3!=0{print"-beta"$3}']))
42m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
43m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
44
45AC_INIT([gnupg],[mym4_full_version], [https://bugs.gnupg.org])
46
47
48development_version=mym4_isgit
49
50AC_CONFIG_AUX_DIR(scripts)
51AC_CONFIG_SRCDIR(g10/gpg.c)
52AC_CANONICAL_HOST
53AM_INIT_AUTOMAKE([serial-tests std-options dist-bzip2 filename-length-max=99])
54AB_INIT
55AC_CONFIG_HEADERS(config.h)
56
57AC_GNU_SOURCE
58
59dnl
60dnl  Check for random module options
61dnl
62AC_MSG_CHECKING([which random module to use])
63AC_ARG_ENABLE(static-rnd,
64    AC_HELP_STRING([[--enable-static-rnd=[egd|unix|linux|auto]]],
65                   [specify a random number source]),
66    [use_static_rnd=$enableval], [use_static_rnd=default])
67
68if test "$use_static_rnd" = no; then
69    use_static_rnd=default
70fi
71
72case "$use_static_rnd" in
73    egd | linux | unix | default )
74      AC_MSG_RESULT($use_static_rnd)
75      ;;
76    auto )
77      AC_MSG_RESULT(automagically selected at runtime)
78      ;;
79    * )
80      AC_MSG_RESULT(invalid argument)
81      AC_MSG_ERROR(there is no random module rnd$use_static_rnd)
82      ;;
83esac
84
85AC_ARG_WITH(egd-socket,
86    AC_HELP_STRING([--with-egd-socket=NAME],[use NAME for the EGD socket]),
87            egd_socket_name="$withval", egd_socket_name="" )
88AC_DEFINE_UNQUOTED(EGD_SOCKET_NAME, "$egd_socket_name",
89                   [Define if you don't want the default EGD socket name.
90                    For details see cipher/rndegd.c])
91
92
93dnl
94dnl See whether the user wants to disable checking for /dev/random
95
96AC_MSG_CHECKING([whether use of /dev/random is requested])
97AC_ARG_ENABLE(dev-random,
98   AC_HELP_STRING([--disable-dev-random],[disable the use of dev random]),
99   try_dev_random=$enableval, try_dev_random=yes)
100AC_MSG_RESULT($try_dev_random)
101
102
103dnl
104dnl  Check other options
105dnl
106
107AC_MSG_CHECKING([whether assembler modules are requested])
108AC_ARG_ENABLE(asm,
109   AC_HELP_STRING([--disable-asm],[do not use assembler modules]),
110     try_asm_modules=$enableval, try_asm_modules=yes)
111AC_MSG_RESULT($try_asm_modules)
112
113dnl AC_MSG_CHECKING([whether memory guard is requested])
114dnl AC_ARG_ENABLE(m-guard,
115dnl     [  --enable-m-guard        enable memory guard facility],
116dnl     use_m_guard=$enableval, use_m_guard=no)
117dnl AC_MSG_RESULT($use_m_guard)
118dnl if test "$use_m_guard" = yes ; then
119dnl     AC_DEFINE(M_GUARD,1,[Define to use the (obsolete) malloc guarding feature])
120dnl fi
121
122# SELinux support includes tracking of sensitive files to avoid
123# leaking their contents through processing these files by gpg itself
124AC_MSG_CHECKING([whether SELinux support is requested])
125AC_ARG_ENABLE(selinux-support,
126              AC_HELP_STRING([--enable-selinux-support],
127                             [enable SELinux support]),
128              selinux_support=$enableval, selinux_support=no)
129AC_MSG_RESULT($selinux_support)
130
131
132AC_MSG_CHECKING([whether the new iconv based code is requested])
133AC_ARG_ENABLE(gnupg-iconv,
134              AC_HELP_STRING([--disable-gnupg-iconv],
135                             [disable the new iconv code]),
136              gnupg_use_iconv=$enableval, gnupg_use_iconv=yes)
137AC_MSG_RESULT($gnupg_use_iconv)
138
139dnl See if we are disabling any algorithms or features for a smaller
140dnl binary
141
142try_extensions=no
143
144try_gettext=yes
145try_dns=yes
146use_rsa=yes
147use_idea=yes
148use_cast5=yes
149use_blowfish=yes
150use_aes=yes
151use_twofish=yes
152use_camellia=yes
153use_sha256=yes
154use_sha512=yes
155use_bzip2=yes
156use_exec=yes
157card_support=yes
158agent_support=yes
159disable_keyserver_path=no
160large_secmem=no
161
162AC_ARG_ENABLE(minimal,
163   AC_HELP_STRING([--enable-minimal],[build the smallest gpg binary possible]),
164   try_dns=no
165   use_rsa=no
166   use_idea=no
167   use_cast5=no
168   use_blowfish=no
169   use_aes=no
170   use_twofish=no
171   use_camellia=no
172   use_sha256=no
173   use_sha512=no
174   use_bzip2=no
175   use_exec=no
176   card_support=no
177   agent_support=no)
178
179
180AC_MSG_CHECKING([whether to allocate extra secure memory])
181AC_ARG_ENABLE(large-secmem,
182              AC_HELP_STRING([--enable-large-secmem],
183                             [allocate extra secure memory]),
184              large_secmem=$enableval, large_secmem=no)
185AC_MSG_RESULT($large_secmem)
186if test "$large_secmem" = yes ; then
187   SECMEM_BUFFER_SIZE=65536
188else
189   SECMEM_BUFFER_SIZE=32768
190fi
191AC_DEFINE_UNQUOTED(SECMEM_BUFFER_SIZE,$SECMEM_BUFFER_SIZE,
192                   [Size of secure memory buffer])
193
194
195AC_MSG_CHECKING([whether OpenPGP card support is requested])
196AC_ARG_ENABLE(card-support,
197              AC_HELP_STRING([--disable-card-support],
198                             [disable OpenPGP card support]),
199              card_support=$enableval)
200AC_MSG_RESULT($card_support)
201
202
203# Note that we may later disable the agent support based on the platform.
204AC_MSG_CHECKING([whether gpg-agent support is requested])
205AC_ARG_ENABLE(agent-support,
206              AC_HELP_STRING([--disable-agent-support],
207                             [disable gpg-agent support]),
208              agent_support=$enableval)
209AC_MSG_RESULT($agent_support)
210
211
212AC_MSG_CHECKING([whether to enable the RSA public key algorithm])
213AC_ARG_ENABLE(rsa,
214   AC_HELP_STRING([--disable-rsa],[disable the RSA public key algorithm]),
215   use_rsa=$enableval)
216AC_MSG_RESULT($use_rsa)
217if test x"$use_rsa" = xyes ; then
218   AC_DEFINE(USE_RSA,1,[Define to include the RSA public key algorithm])
219fi
220
221AC_MSG_CHECKING([whether to enable the IDEA cipher])
222AC_ARG_ENABLE(idea,
223   AC_HELP_STRING([--disable-idea],[disable the IDEA cipher]),
224   use_idea=$enableval)
225AC_MSG_RESULT($use_idea)
226if test x"$use_idea" = xyes ; then
227   AC_DEFINE(USE_IDEA,1,[Define to include the IDEA cipher])
228fi
229
230AC_MSG_CHECKING([whether to enable the CAST5 cipher])
231AC_ARG_ENABLE(cast5,
232   AC_HELP_STRING([--disable-cast5],[disable the CAST5 cipher]),
233   use_cast5=$enableval)
234AC_MSG_RESULT($use_cast5)
235if test x"$use_cast5" = xyes ; then
236   AC_DEFINE(USE_CAST5,1,[Define to include the CAST5 cipher])
237fi
238
239AC_MSG_CHECKING([whether to enable the BLOWFISH cipher])
240AC_ARG_ENABLE(blowfish,
241   AC_HELP_STRING([--disable-blowfish],[disable the BLOWFISH cipher]),
242   use_blowfish=$enableval)
243AC_MSG_RESULT($use_blowfish)
244if test x"$use_blowfish" = xyes ; then
245   AC_DEFINE(USE_BLOWFISH,1,[Define to include the BLOWFISH cipher])
246fi
247
248AC_MSG_CHECKING([whether to enable the AES ciphers])
249AC_ARG_ENABLE(aes,
250   AC_HELP_STRING([--disable-aes],[disable the AES, AES192, and AES256 ciphers]),
251   use_aes=$enableval)
252AC_MSG_RESULT($use_aes)
253if test x"$use_aes" = xyes ; then
254   AC_DEFINE(USE_AES,1,[Define to include the AES, AES192, and AES256 ciphers])
255fi
256
257AC_MSG_CHECKING([whether to enable the TWOFISH cipher])
258AC_ARG_ENABLE(twofish,
259   AC_HELP_STRING([--disable-twofish],[disable the TWOFISH cipher]),
260   use_twofish=$enableval)
261AC_MSG_RESULT($use_twofish)
262if test x"$use_twofish" = xyes ; then
263   AC_DEFINE(USE_TWOFISH,1,[Define to include the TWOFISH cipher])
264fi
265
266AC_MSG_CHECKING([whether to enable the CAMELLIA cipher])
267AC_ARG_ENABLE(camellia,
268   AC_HELP_STRING([--enable-camellia],[enable the CAMELLIA cipher]),
269   use_camellia=$enableval)
270AC_MSG_RESULT($use_camellia)
271if test x"$use_camellia" = xyes ; then
272   AC_DEFINE(USE_CAMELLIA,1,[Define to include the CAMELLIA cipher])
273fi
274
275AC_MSG_CHECKING([whether to enable the SHA-224 and SHA-256 digests])
276AC_ARG_ENABLE(sha256,
277   AC_HELP_STRING([--disable-sha256],[disable the SHA-224 and SHA-256 digests]),
278   use_sha256=$enableval)
279AC_MSG_RESULT($use_sha256)
280if test x"$use_sha256" = xyes ; then
281   AC_DEFINE(USE_SHA256,1,[Define to include the SHA-224 and SHA-256 digests])
282fi
283
284dnl SHA512 is defined only after we confirm 64-bit support later
285AC_MSG_CHECKING([whether to enable the SHA-384 and SHA-512 digests])
286AC_ARG_ENABLE(sha512,
287   AC_HELP_STRING([--disable-sha512],[disable the SHA-384 and SHA-512 digests]),
288   use_sha512=$enableval)
289AC_MSG_RESULT($use_sha512)
290
291dnl BZLIB is defined only after we confirm the library is available later
292AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm])
293AC_ARG_ENABLE(bzip2,
294   AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]),
295   use_bzip2=$enableval)
296AC_MSG_RESULT($use_bzip2)
297
298AC_MSG_CHECKING([whether to enable external program execution])
299AC_ARG_ENABLE(exec,
300    AC_HELP_STRING([--disable-exec],[disable all external program execution]),
301    use_exec=$enableval)
302AC_MSG_RESULT($use_exec)
303if test "$use_exec" = no ; then
304    AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution])
305fi
306
307if test "$use_exec" = yes ; then
308  AC_MSG_CHECKING([whether to enable photo ID viewing])
309  AC_ARG_ENABLE(photo-viewers,
310      AC_HELP_STRING([--disable-photo-viewers],[disable photo ID viewers]),
311      [if test "$enableval" = no ; then
312         AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing])
313      fi],enableval=yes)
314  gnupg_cv_enable_photo_viewers=$enableval
315  AC_MSG_RESULT($enableval)
316
317  if test "$gnupg_cv_enable_photo_viewers" = yes ; then
318    AC_MSG_CHECKING([whether to use a fixed photo ID viewer])
319    AC_ARG_WITH(photo-viewer,
320        AC_HELP_STRING([--with-photo-viewer=FIXED_VIEWER],
321                       [set a fixed photo ID viewer]),
322        [if test "$withval" = yes ; then
323           withval=no
324        elif test "$withval" != no ; then
325           AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval",
326  	                    [if set, restrict photo-viewer to this])
327        fi],withval=no)
328    AC_MSG_RESULT($withval)
329  fi
330
331  AC_MSG_CHECKING([whether to enable external keyserver helpers])
332  AC_ARG_ENABLE(keyserver-helpers,
333      AC_HELP_STRING([--disable-keyserver-helpers],
334                     [disable all external keyserver support]),
335      [if test "$enableval" = no ; then
336         AC_DEFINE(DISABLE_KEYSERVER_HELPERS,1,
337                  [define to disable keyserver helpers])
338      fi],enableval=yes)
339  gnupg_cv_enable_keyserver_helpers=$enableval
340  AC_MSG_RESULT($enableval)
341
342  if test "$gnupg_cv_enable_keyserver_helpers" = yes ; then
343dnl LDAP is defined only after we confirm the library is available later
344    AC_MSG_CHECKING([whether LDAP keyserver support is requested])
345    AC_ARG_ENABLE(ldap,
346      AC_HELP_STRING([--disable-ldap],[disable LDAP keyserver interface only]),
347      try_ldap=$enableval, try_ldap=yes)
348    AC_MSG_RESULT($try_ldap)
349
350    AC_MSG_CHECKING([whether HKP keyserver support is requested])
351    AC_ARG_ENABLE(hkp,
352      AC_HELP_STRING([--disable-hkp],[disable HKP keyserver interface only]),
353      try_hkp=$enableval, try_hkp=yes)
354    AC_MSG_RESULT($try_hkp)
355
356    AC_MSG_CHECKING([whether finger key fetching support is requested])
357    AC_ARG_ENABLE(finger,
358      AC_HELP_STRING([--disable-finger],
359        [disable finger key fetching interface only]),
360      try_finger=$enableval, try_finger=yes)
361    AC_MSG_RESULT($try_finger)
362
363    AC_MSG_CHECKING([whether generic object key fetching support is requested])
364    AC_ARG_ENABLE(generic,
365      AC_HELP_STRING([--disable-generic],
366        [disable generic object key fetching interface only]),
367      try_generic=$enableval, try_generic=yes)
368    AC_MSG_RESULT($try_generic)
369
370    AC_MSG_CHECKING([whether email keyserver support is requested])
371    AC_ARG_ENABLE(mailto,
372      AC_HELP_STRING([--enable-mailto],
373	[enable email keyserver interface only]),
374      try_mailto=$enableval, try_mailto=no)
375    AC_MSG_RESULT($try_mailto)
376  fi
377
378  AC_MSG_CHECKING([whether keyserver exec-path is enabled])
379  AC_ARG_ENABLE(keyserver-path,
380    AC_HELP_STRING([--disable-keyserver-path],
381      [disable the exec-path option for keyserver helpers]),
382    [if test "$enableval" = no ; then
383       disable_keyserver_path=yes
384    fi],enableval=yes)
385  AC_MSG_RESULT($enableval)
386fi
387
388AC_MSG_CHECKING([whether the included zlib is requested])
389AC_ARG_WITH(included-zlib,
390    AC_HELP_STRING([--with-included-zlib],[use the zlib code included here]),
391[g10_force_zlib="$withval"], [g10_force_zlib=no] )
392AC_MSG_RESULT($g10_force_zlib)
393
394dnl
395dnl Check for the key/uid cache size.  This can't be zero, but can be
396dnl pretty small on embedded systems.
397dnl
398AC_MSG_CHECKING([for the size of the key and uid cache])
399AC_ARG_ENABLE(key-cache,
400	AC_HELP_STRING([--enable-key-cache=SIZE],[Set key cache to SIZE (default 4096)]),,enableval=4096)
401
402if test "$enableval" = "no"; then
403   enableval=5
404elif test "$enableval" = "yes" || test "$enableval" = ""; then
405   enableval=4096
406fi
407
408changequote(,)dnl
409key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'`
410changequote([,])dnl
411
412if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then
413   AC_MSG_ERROR([invalid key-cache size])
414fi
415
416AC_MSG_RESULT($key_cache_size)
417AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size,[Size of the key and UID caches])
418
419dnl
420dnl Check whether we want to use Linux capabilities
421dnl
422AC_MSG_CHECKING([whether use of capabilities is requested])
423AC_ARG_WITH(capabilities,
424    AC_HELP_STRING([--with-capabilities],
425                   [use linux capabilities [default=no]]),
426[use_capabilities="$withval"],[use_capabilities=no])
427AC_MSG_RESULT($use_capabilities)
428
429# To avoid double inclusion of config.h which might happen at some
430# places, we add the usual double inclusion protection.
431AH_TOP([
432#ifndef GNUPG_CONFIG_H_INCLUDED
433#define GNUPG_CONFIG_H_INCLUDED
434])
435
436AH_BOTTOM([
437/* We didn't define endianness above, so get it from OS macros.  This
438is intended for making fat binary builds on OS X. */
439#if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST)
440# if defined(__BIG_ENDIAN__)
441#  define BIG_ENDIAN_HOST 1
442# elif defined(__LITTLE_ENDIAN__)
443#  define LITTLE_ENDIAN_HOST 1
444# else
445#  error "No endianness found"
446# endif
447#endif
448
449#if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
450# define EXEC_TEMPFILE_ONLY
451#endif
452
453/* A macro to help checking the GCC version.  */
454#ifdef __GNUC__
455# define GNUPG_GCC_VERSION (__GNUC__ * 10000       \
456                            + __GNUC_MINOR__ * 100 \
457                            + __GNUC_PATCHLEVEL__)
458#endif /*__GNUC__*/
459
460/* Please note that the string version must not contain more
461   than one character because the using code assumes strlen()==1 */
462#ifdef HAVE_DOSISH_SYSTEM
463# define DIRSEP_C '\\'
464# define EXTSEP_C '.'
465# define DIRSEP_S "\\"
466# define EXTSEP_S "."
467# define PATHSEP_C ';'
468# define PATHSEP_S ";"
469#else
470# define DIRSEP_C '/'
471# define EXTSEP_C '.'
472# define DIRSEP_S "/"
473# define EXTSEP_S "."
474# define PATHSEP_C ':'
475# define PATHSEP_S ":"
476#endif
477
478#ifdef __VMS
479# define GNUPG_BAK_SFX "_bak"
480# define GNUPG_TMP_SFX "_tmp"
481#else /*!def __VMS */
482# define GNUPG_BAK_SFX "~"
483# define GNUPG_TMP_SFX EXTSEP_S "tmp"
484#endif /* def __VMS [else] */
485
486
487/* For some OSes we need to use fixed strings for certain directories.  */
488#ifdef HAVE_DRIVE_LETTERS
489# define LOCALEDIR         "c:\\\\lib\\\\gnupg\\\\locale"
490# define GNUPG_LIBDIR      "c:\\\\lib\\\\gnupg"
491# define GNUPG_LIBEXECDIR  "c:\\\\lib\\\\gnupg"
492# define GNUPG_DATADIR     "c:\\\\lib\\\\gnupg"
493# define GNUPG_HOMEDIR     "c:\\\\gnupg"
494#else
495# ifdef __VMS
496#  define GNUPG_DATADIR     "/SYS$MANAGER/gnupg_share"
497#  define GNUPG_HOMEDIR     "/SYS$LOGIN/gnupg"
498#  define GNUPG_LIBDIR      "/SYS$MANAGER/gnupg_share"
499#  define GNUPG_LIBEXECDIR  ""
500# else
501#  define GNUPG_HOMEDIR "~/.gnupg"
502# endif
503#endif
504
505/* Hack used for W32: ldap.m4 also tests for the ASCII version of
506   ldap_start_tls_s because that is the actual symbol used in the
507   library.  winldap.h redefines it to our commonly used value,
508   thus we define our usual macro here.  */
509#ifdef HAVE_LDAP_START_TLS_SA
510# ifndef HAVE_LDAP_START_TLS_S
511#  define HAVE_LDAP_START_TLS_S 1
512# endif
513#endif
514
515/* This is the major version number of GnuPG so that
516   source included files can test for this. */
517#define GNUPG_MAJOR_VERSION 1
518
519/* This is the same as VERSION, but should be overridden if the
520   platform cannot handle things like dots'.' in filenames.  Set
521   SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION
522   uses for dots and dashes. */
523#define SAFE_VERSION      VERSION
524#define SAFE_VERSION_DOT  '.'
525#define SAFE_VERSION_DASH '-'
526
527/* We want to use our memory allocator for estream-printf.  */
528#define _ESTREAM_PRINTF_MALLOC        xtrymalloc
529#define _ESTREAM_PRINTF_FREE          xfree
530#define _ESTREAM_PRINTF_EXTRA_INCLUDE "memory.h"
531
532#endif /*GNUPG_CONFIG_H_INCLUDED*/
533])
534
535AM_MAINTAINER_MODE
536
537dnl Checks for programs.
538
539AC_PROG_MAKE_SET
540AM_SANITY_CHECK
541missing_dir=`cd $ac_aux_dir && pwd`
542AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
543AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
544AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
545AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
546AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
547AC_PROG_CC
548AM_PROG_CC_C_O
549AC_PROG_CPP
550AC_PROG_RANLIB
551AC_CHECK_TOOL(AR, ar, :)
552AC_PATH_PROG(PERL,"perl")
553AC_ISC_POSIX
554AC_SYS_LARGEFILE
555AC_PROG_INSTALL
556AC_PROG_AWK
557GNUPG_CHECK_USTAR
558
559
560# According to a comment by Marcus Brinkman in libgpg-error, the
561# AC_PROG_CC_FOR_BUILD macro in the AC archive is broken for autoconf
562# 2.57.  Thus we use a simply use "cc" if we are cross-compiling.
563AC_MSG_CHECKING(for cc for build)
564if test "$cross_compiling" = "yes"; then
565  CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
566else
567  CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
568fi
569AC_MSG_RESULT($CC_FOR_BUILD)
570AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
571
572
573
574MPI_OPT_FLAGS=""
575
576have_dosish_system=no
577need_dlopen=yes
578case "${host}" in
579    *-mingw32*)
580        # special stuff for Windoze NT
581        ac_cv_have_dev_random=no
582        AC_DEFINE(USE_ONLY_8DOT3,1,
583                  [set this to limit filenames to the 8.3 format])
584        AC_DEFINE(HAVE_DRIVE_LETTERS,1,
585                  [defined if we must run on a stupid file system])
586        AC_DEFINE(USE_SIMPLE_GETTEXT,1,
587                  [because the Unix gettext has too much overhead on
588                   MingW32 systems and these systems lack Posix functions,
589                   we use a simplified version of gettext])
590        AC_DEFINE(HAVE_W32_SYSTEM,1,
591                  [Defined if we run on a W32 API based system])
592        disable_keyserver_path=yes
593        have_dosish_system=yes
594        need_dlopen=no
595        try_gettext="no"
596        agent_support=no
597	use_simple_gettext=yes
598	have_w32_system=yes
599        # gcc 4.6 uses by default -fomit-frame-pointer.  This
600        # conflicts with mingw runtime's setjmp/longjmp usage.  The
601        # actual bug we notice is a segv related to the dlopened
602        # iconv.dll: After returning from set_native_charset the stack
603        # frame is corrupt.
604        if test -n "$GCC" ; then
605            CFLAGS="$CFLAGS -fno-omit-frame-pointer"
606        fi
607        ;;
608    i?86-emx-os2 | i?86-*-os2*emx )
609        # OS/2 with the EMX environment
610        ac_cv_have_dev_random=no
611        AC_DEFINE(HAVE_DRIVE_LETTERS)
612        have_dosish_system=yes
613        try_gettext="no"
614        agent_support=no
615        ;;
616
617    i?86-*-msdosdjgpp*)
618        # DOS with the DJGPP environment
619        ac_cv_have_dev_random=no
620        AC_DEFINE(HAVE_DRIVE_LETTERS)
621        have_dosish_system=yes
622        try_gettext="no"
623        agent_support=no
624        ;;
625
626    *-*-hpux*)
627        if test -z "$GCC" ; then
628            CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
629        fi
630        ;;
631    *-dec-osf4*)
632        if test -z "$GCC" ; then
633            # Suppress all warnings
634            # to get rid of the unsigned/signed char mismatch warnings.
635            CFLAGS="$CFLAGS -w"
636        fi
637        ;;
638    *-dec-osf5*)
639        if test -z "$GCC" ; then
640            # Use the newer compiler `-msg_disable ptrmismatch1' to
641            # get rid of the unsigned/signed char mismatch warnings.
642            # Using this may hide other pointer mismatch warnings, but
643	    # it at least lets other warning classes through
644            CFLAGS="$CFLAGS -msg_disable ptrmismatch1"
645        fi
646        ;;
647    m68k-atari-mint)
648        ;;
649    *)
650       ;;
651esac
652
653if test "$have_dosish_system" = yes; then
654   AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
655             [defined if we run on some of the PCDOS like systems
656              (DOS, Windoze. OS/2) with special properties like
657              no file modes])
658fi
659AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
660
661AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes)
662AM_CONDITIONAL(HAVE_W32_SYSTEM, test x"$have_w32_system" = xyes)
663
664if test "$disable_keyserver_path" = yes; then
665    AC_DEFINE(DISABLE_KEYSERVER_PATH,1,
666              [define to disable exec-path for keyserver helpers])
667fi
668
669AC_SUBST(MPI_OPT_FLAGS)
670GNUPG_SYS_SYMBOL_UNDERSCORE
671
672dnl These need to go after AC_PROG_CC so that $EXEEXT is defined
673
674AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any])
675
676if test x"$try_hkp" = xyes ; then
677  AC_SUBST(GPGKEYS_HKP,"gpgkeys_hkp$EXEEXT")
678fi
679
680if test x"$try_finger" = xyes ; then
681  AC_SUBST(GPGKEYS_FINGER,"gpgkeys_finger$EXEEXT")
682fi
683
684dnl Must check for network library requirements before doing link tests
685dnl for ldap, for example. If ldap libs are static (or dynamic and without
686dnl ELF runtime link paths), then link will fail and LDAP support won't
687dnl be detected.
688
689AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
690	[NETLIBS="-lnsl $NETLIBS"]))
691AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
692	[NETLIBS="-lsocket $NETLIBS"]))
693
694dnl Now try for the resolver functions so we can use DNS for SRV, PKA,
695dnl and CERT.
696
697if test x"$try_dns" = xyes ; then
698   if test x"$try_hkp" = xyes || test x"$try_http" = xyes ; then
699      AC_ARG_ENABLE(dns-srv,
700         AC_HELP_STRING([--disable-dns-srv],
701      	[disable the use of DNS SRV in HKP and HTTP]),
702         use_dns_srv=$enableval,use_dns_srv=yes)
703   fi
704
705   AC_ARG_ENABLE(dns-cert,
706      AC_HELP_STRING([--disable-dns-cert],
707   	[disable the use of CERT records in DNS]),
708      use_dns_cert=$enableval,use_dns_cert=yes)
709fi
710
711if test x"$use_dns_srv" = xyes || test x"$use_dns_cert" = xyes; then
712  _dns_save_libs=$LIBS
713  LIBS=""
714  # the double underscore thing is a glibc-ism?
715  AC_SEARCH_LIBS(res_query,resolv bind socket,,
716            AC_SEARCH_LIBS(__res_query,resolv bind socket,,have_resolver=no))
717  AC_SEARCH_LIBS(dn_expand,resolv bind socket,,
718            AC_SEARCH_LIBS(__dn_expand,resolv bind socket,,have_resolver=no))
719  AC_SEARCH_LIBS(dn_skipname,resolv bind socket,,
720            AC_SEARCH_LIBS(__dn_skipname,resolv bind socket,,have_resolver=no))
721
722  if test x"$have_resolver" != xno ; then
723
724    # Make sure that the BIND 4 resolver interface is workable before
725    # enabling any code that calls it.  At some point I'll rewrite the
726    # code to use the BIND 8 resolver API.
727
728    AC_MSG_CHECKING([whether the resolver is usable])
729    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
730#include <netinet/in.h>
731#include <arpa/nameser.h>
732#include <resolv.h>]],
733[[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0);]])],have_resolver=yes,have_resolver=no)
734    AC_MSG_RESULT($have_resolver)
735
736    # This is Apple-specific and somewhat bizarre as they changed the
737    # define in bind 8 for some reason.
738
739    if test x"$have_resolver" != xyes ; then
740       AC_MSG_CHECKING([whether I can make the resolver usable with BIND_8_COMPAT and libresolv])
741       LIBS="$LIBS -lresolv"
742       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define BIND_8_COMPAT
743#include <sys/types.h>
744#include <netinet/in.h>
745#include <arpa/nameser.h>
746#include <resolv.h>]],
747[[unsigned char answer[PACKETSZ]; res_query("foo.bar",C_IN,T_A,answer,PACKETSZ); dn_skipname(0,0); dn_expand(0,0,0,0,0);]])],[have_resolver=yes ; need_compat=yes])
748       AC_MSG_RESULT($have_resolver)
749    fi
750  fi
751
752  if test x"$have_resolver" = xyes ; then
753     DNSLIBS=$LIBS
754
755     if test x"$use_dns_srv" = xyes ; then
756        AC_DEFINE(USE_DNS_SRV,1,[define to use DNS SRV])
757     fi
758
759     if test x"$use_dns_cert" = xyes ; then
760        AC_DEFINE(USE_DNS_CERT,1,[define to use DNS CERT])
761     fi
762
763     if test x"$need_compat" = xyes ; then
764        AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism])
765     fi
766  else
767     use_dns_srv=no
768     use_dns_cert=no
769  fi
770
771  LIBS=$_dns_save_libs
772fi
773
774AC_SUBST(DNSLIBS)
775
776AM_CONDITIONAL(USE_DNS_SRV, test x"$use_dns_srv" = xyes)
777
778# Check for LDAP
779
780if test "$try_ldap" = yes ; then
781   GNUPG_CHECK_LDAP($NETLIBS)
782fi
783
784# Check for curl.  We fake the curl API if libcurl isn't installed.
785# We require 7.10 or better as we use curl_version_info().
786
787LIBCURL_CHECK_CONFIG([yes],[7.10],,[fake_curl=yes])
788AM_CONDITIONAL(FAKE_CURL,test x"$fake_curl" = xyes)
789
790# Generic, for us, means curl
791
792if test x"$try_generic" = xyes ; then
793   AC_SUBST(GPGKEYS_CURL,"gpgkeys_curl$EXEEXT")
794fi
795
796dnl This isn't necessarily sendmail itself, but anything that gives a
797dnl sendmail-ish interface to the outside world.  That includes qmail,
798dnl postfix, etc.  Basically, anything that can handle "sendmail -t".
799
800if test "$try_mailto" = yes ; then
801  AC_ARG_WITH(mailprog,
802     AC_HELP_STRING([--with-mailprog=NAME],
803                    [use "NAME -t" for mail transport]),,with_mailprog=yes)
804
805  if test "$with_mailprog" = yes ; then
806    AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib)
807    if test "$ac_cv_path_SENDMAIL" ; then
808      GPGKEYS_MAILTO="gpgkeys_mailto"
809    fi
810  elif test "$with_mailprog" != no ; then
811    AC_MSG_CHECKING([for a mail transport program])
812    AC_SUBST(SENDMAIL,$with_mailprog)
813    AC_MSG_RESULT($with_mailprog)
814    GPGKEYS_MAILTO="gpgkeys_mailto"
815  fi
816fi
817
818AC_SUBST(GPGKEYS_MAILTO)
819
820case "${host}" in
821    *-mingw32*)
822        PRINTABLE_OS_NAME="MingW32"
823        ;;
824    *-*-cygwin*)
825        PRINTABLE_OS_NAME="Cygwin"
826        ;;
827    i?86-emx-os2 | i?86-*-os2*emx )
828        PRINTABLE_OS_NAME="OS/2"
829        ;;
830    i?86-*-msdosdjgpp*)
831        PRINTABLE_OS_NAME="MSDOS/DJGPP"
832        try_extensions=no
833        ;;
834    *-linux*)
835        PRINTABLE_OS_NAME="GNU/Linux"
836        ;;
837    *)
838        PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
839        ;;
840esac
841AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
842                   [A human readable text with the name of the OS])
843
844
845#
846# 1. Set names of random devices
847#
848NAME_OF_DEV_RANDOM="/dev/random"
849NAME_OF_DEV_URANDOM="/dev/urandom"
850AC_DEFINE_UNQUOTED(NAME_OF_DEV_RANDOM, "$NAME_OF_DEV_RANDOM",
851                   [defined to the name of the strong random device])
852AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM",
853                   [defined to the name of the weaker random device])
854AC_SUBST(MPI_OPT_FLAGS)
855
856
857dnl Checks for libraries.
858
859
860# This is "GNU gnupg" - The project-id script from gettext
861#                       needs to find this string.  Without
862#                       it "make distcheck" may fail.
863AM_PO_SUBDIRS
864AM_GNU_GETTEXT_VERSION([0.19.3])
865if test "$try_gettext" = yes; then
866  AM_GNU_GETTEXT(,[need-ngettext])
867  # gettext requires some extra checks.  These really should be part of
868  # the basic AM_GNU_GETTEXT macro.  TODO: move other gettext-specific
869  # function checks to here.
870  AC_CHECK_FUNCS(strchr)
871else
872  enable_nls=no
873  USE_NLS=no
874  USE_INCLUDED_LIBINTL=no
875  BUILD_INCLUDED_LIBINTL=no
876  POSUB=po
877  AC_SUBST(USE_NLS)
878  AC_SUBST(USE_INCLUDED_LIBINTL)
879  AC_SUBST(BUILD_INCLUDED_LIBINTL)
880  AC_SUBST(POSUB)
881fi
882
883
884if test "$try_extensions" = yes || test x"$card_support" = xyes ; then
885  if test "$need_dlopen" = yes; then
886    _dl_save_libs=$LIBS
887    LIBS=""
888    AC_SEARCH_LIBS(dlopen,dl,found_dlopen=yes)
889    if test x"$found_dlopen" = "xyes" ; then
890      AC_DEFINE(HAVE_DL_DLOPEN,1,
891                [Defined when the dlopen function family is available])
892      DLLIBS=$LIBS
893    else
894      if test "$try_extensions" = yes ; then
895         AC_MSG_NOTICE([dlopen not found.  Disabling extensions.])
896	 try_extensions=no
897      fi
898
899      if test "$card_support" = yes ; then
900         AC_MSG_WARN([dlopen not found.  Disabling OpenPGP card support.])
901         card_support=no
902      fi
903    fi
904    LIBS=$_dl_save_libs
905  fi
906fi
907
908AC_SUBST(DLLIBS)
909
910if test "$card_support" = yes ; then
911  AC_DEFINE(ENABLE_CARD_SUPPORT,1,[Define to include OpenPGP card support])
912fi
913
914if test "$agent_support" = yes ; then
915  AC_DEFINE(ENABLE_AGENT_SUPPORT,1,[Define to include gpg-agent support])
916fi
917
918if test "$try_extensions" = yes ; then
919  AC_DEFINE(USE_DYNAMIC_LINKING,1,[Define to enable the use of extensions])
920fi
921
922if test "$selinux_support" = yes ; then
923  AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support])
924fi
925
926if test "$gnupg_use_iconv" = yes ; then
927  AC_DEFINE(USE_GNUPG_ICONV,1,[Define to use the new iconv based code])
928fi
929
930AM_CONDITIONAL(ENABLE_CARD_SUPPORT, test "$card_support" = yes)
931AM_CONDITIONAL(ENABLE_AGENT_SUPPORT, test "$agent_support" = yes)
932AM_CONDITIONAL(ENABLE_SELINUX_HACKS, test "$selinux_support" = yes)
933
934dnl Checks for header files.
935AC_HEADER_STDC
936AC_CHECK_HEADERS([unistd.h langinfo.h termio.h locale.h getopt.h pwd.h \
937                  signal.h])
938
939# Note that we do not check for iconv here because this is done anyway
940# by the gettext checks and thus it allows us to disable the use of
941# iconv by using --disable-nls.
942
943dnl Checks for typedefs, structures, and compiler characteristics.
944AC_C_CONST
945AC_C_INLINE
946AC_C_VOLATILE
947AC_TYPE_SIZE_T
948AC_TYPE_MODE_T
949AC_TYPE_SIGNAL
950AC_DECL_SYS_SIGLIST
951
952AC_ARG_ENABLE(endian-check,
953              AC_HELP_STRING([--disable-endian-check],
954	      [disable the endian check and trust the OS provided macros]),
955	      endiancheck=$enableval,endiancheck=yes)
956
957if test x"$endiancheck" = xyes ; then
958   GNUPG_CHECK_ENDIAN
959fi
960
961GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
962GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
963GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
964GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
965GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
966
967AC_CHECK_SIZEOF(unsigned short)
968AC_CHECK_SIZEOF(unsigned int)
969AC_CHECK_SIZEOF(unsigned long)
970AC_CHECK_SIZEOF(unsigned long long)
971AC_HEADER_TIME
972AC_CHECK_SIZEOF(time_t,,[[
973#include <stdio.h>
974#if TIME_WITH_SYS_TIME
975# include <sys/time.h>
976# include <time.h>
977#else
978# if HAVE_SYS_TIME_H
979#  include <sys/time.h>
980# else
981#  include <time.h>
982# endif
983#endif
984]])
985GNUPG_TIME_T_UNSIGNED
986
987# Ensure that we have UINT64_C before we bother to check for uint64_t
988AC_CHECK_HEADERS([inttypes.h])
989AC_CACHE_CHECK([for UINT64_C], [gnupg_cv_uint64_c_works],
990               AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <inttypes.h>]],[[
991uint64_t foo=UINT64_C(42);]])],gnupg_cv_uint64_c_works=yes,gnupg_cv_uint64_c_works=no))
992
993if test "$gnupg_cv_uint64_c_works" = "yes" ; then
994   AC_CHECK_SIZEOF(uint64_t)
995fi
996
997if test "$ac_cv_sizeof_unsigned_short" = "0" \
998   || test "$ac_cv_sizeof_unsigned_int" = "0" \
999   || test "$ac_cv_sizeof_unsigned_long" = "0"; then
1000    AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
1001fi
1002
1003dnl Do we have any 64-bit data types?
1004if test x"$use_sha512" = xyes \
1005   && test "$ac_cv_sizeof_unsigned_int" != "8" \
1006   && test "$ac_cv_sizeof_unsigned_long" != "8" \
1007   && test "$ac_cv_sizeof_unsigned_long_long" != "8" \
1008   && test x"$ac_cv_sizeof_uint64_t" != "x8"; then
1009    AC_MSG_NOTICE([No 64-bit types.  Disabling SHA-384 and SHA-512.])
1010    use_sha512=no
1011fi
1012
1013if test x"$use_sha512" = xyes ; then
1014    AC_DEFINE(USE_SHA512,1,[Define to include the SHA-384 and SHA-512 digests])
1015fi
1016
1017AM_CONDITIONAL(USE_SHA512, test x"$use_sha512" = xyes)
1018
1019dnl Checks for library functions.
1020AC_CHECK_DECLS(getpagesize)
1021AC_FUNC_FSEEKO
1022AC_FUNC_VPRINTF
1023AC_FUNC_FORK
1024AC_CHECK_FUNCS(strerror stpcpy strlwr tcgetattr strtoul mmap sysconf)
1025AC_CHECK_FUNCS(strcasecmp strncasecmp ctermid times unsetenv getpwnam getpwuid)
1026AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
1027AC_CHECK_FUNCS(atexit raise getpagesize strftime nl_langinfo setlocale)
1028AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand pipe stat getaddrinfo)
1029AC_CHECK_FUNCS(fcntl ftruncate inet_ntop)
1030AC_REPLACE_FUNCS(mkdtemp timegm isascii memrchr strsep)
1031
1032AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
1033
1034# See if getopt is in libiberty.  This is of course not optimal since
1035# it might be somewhere other than libiberty, but does cover the
1036# mingw32 case.
1037
1038AC_CHECK_FUNC(getopt,,AC_CHECK_LIB(iberty,getopt,AC_SUBST(GETOPT,"-liberty")))
1039
1040#
1041# check for gethrtime and run a testprogram to see whether
1042# it is broken.  It has been reported that some Solaris and HP UX systems
1043# raise an SIGILL
1044#
1045AC_CACHE_CHECK([for gethrtime],
1046               [gnupg_cv_func_gethrtime],
1047               [AC_TRY_LINK([#include <sys/times.h>],[
1048                   hrtime_t tv;
1049                   tv = gethrtime();
1050                 ],
1051                 [gnupg_cv_func_gethrtime=yes],
1052                 [gnupg_cv_func_gethrtime=no])
1053               ])
1054if test $gnupg_cv_func_gethrtime = yes; then
1055     AC_DEFINE([HAVE_GETHRTIME], 1,
1056               [Define if you have the `gethrtime(2)' function.])
1057     AC_CACHE_CHECK([whether gethrtime is broken],
1058               [gnupg_cv_func_broken_gethrtime],
1059               [AC_TRY_RUN([
1060                   #include <sys/times.h>
1061                   int main () {
1062                   hrtime_t tv;
1063                   tv = gethrtime();
1064                 }
1065                 ],
1066                 [gnupg_cv_func_broken_gethrtime=no],
1067                 [gnupg_cv_func_broken_gethrtime=yes],
1068                 [gnupg_cv_func_broken_gethrtime=assume-no])
1069                ])
1070    if test $gnupg_cv_func_broken_gethrtime = yes; then
1071      AC_DEFINE([HAVE_BROKEN_GETHRTIME], 1,
1072      [Define if `gethrtime(2)' does not work correctly i.e. issues a SIGILL.])
1073    fi
1074fi
1075
1076
1077GNUPG_CHECK_MLOCK
1078GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
1079
1080#
1081# Prepare building of estream-printf
1082#
1083estream_PRINTF_INIT
1084
1085
1086dnl
1087dnl Check whether we can use Linux capabilities as requested
1088dnl
1089if test "$use_capabilities" = "yes" ; then
1090
1091AC_MSG_WARN([[
1092***
1093*** WARNING: using capabilities with GnuPG is experimental code!
1094***]])
1095
1096use_capabilities=no
1097AC_CHECK_HEADERS(sys/capability.h)
1098if test "$ac_cv_header_sys_capability_h" = "yes" ; then
1099  AC_CHECK_LIB(cap, cap_init, ac_need_libcap=1)
1100  if test "$ac_cv_lib_cap_cap_init" = "yes"; then
1101     AC_DEFINE(USE_CAPABILITIES,1,
1102               [define if capabilities should be used])
1103     AC_SUBST(CAPLIBS,"-lcap")
1104     use_capabilities=yes
1105  fi
1106fi
1107if test "$use_capabilities" = "no" ; then
1108    AC_MSG_WARN([[
1109***
1110*** The use of capabilities on this system is not possible.
1111*** You need a recent Linux kernel and some patches:
1112***   fcaps-2.2.9-990610.patch      (kernel patch for 2.2.9)
1113***   fcap-module-990613.tar.gz     (kernel module)
1114***   libcap-1.92.tar.gz            (user mode library and utilities)
1115*** And you have to configure the kernel with CONFIG_VFS_CAP_PLUGIN
1116*** set (filesystems menu). Be warned: This code is *really* ALPHA.
1117***]])
1118fi
1119fi
1120
1121
1122GNUPG_CHECK_IPC
1123if test "$ac_cv_header_sys_shm_h" = "yes"; then
1124  AC_DEFINE(USE_SHM_COPROCESSING,1,
1125            [define if the shared memory interface should be made available])
1126fi
1127
1128AM_CONDITIONAL(HAVE_SHM, test "$ac_cv_header_sys_shm_h" = yes)
1129
1130dnl
1131dnl check whether we have a random device
1132dnl
1133if test "$try_dev_random" = yes ; then
1134    AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
1135    [if test -r "$NAME_OF_DEV_RANDOM" && test -r "$NAME_OF_DEV_URANDOM" ; then
1136      ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
1137    if test "$ac_cv_have_dev_random" = yes; then
1138        AC_DEFINE(HAVE_DEV_RANDOM,1,
1139                 [defined if the system supports a random device] )
1140    fi
1141else
1142    AC_MSG_CHECKING(for random device)
1143    ac_cv_have_dev_random=no
1144    AC_MSG_RESULT(has been disabled)
1145fi
1146
1147
1148dnl
1149dnl Figure out the default random module.
1150dnl
1151random_modules=""
1152if test "$use_static_rnd" = default; then
1153     if test "$ac_cv_have_dev_random" = yes; then
1154        random_modules="rndlinux"
1155     else
1156         case "${host}" in
1157            *-mingw32*|*-*-cygwin*)
1158                random_modules="rndw32"
1159                ;;
1160            i?86-emx-os2|i?86-*-os2*emx)
1161                random_modules="rndos2"
1162                ;;
1163            m68k-atari-mint)
1164                random_modules="rndatari"
1165                ;;
1166            i?86-*-msdosdjgpp*)
1167                :
1168                ;;
1169            *)
1170                random_modules="rndlinux rndegd rndunix"
1171                AC_DEFINE(USE_ALL_RANDOM_MODULES, 1,
1172                          [Allow to select random modules at runtime.])
1173                ;;
1174         esac
1175     fi
1176else
1177  if test "$use_static_rnd" = auto; then
1178     random_modules="rndlinux rndegd rndunix"
1179     AC_DEFINE(USE_ALL_RANDOM_MODULES, 1)
1180  else
1181     random_modules="rnd$use_static_rnd";
1182  fi
1183fi
1184
1185if test -z "$random_modules"; then
1186   AC_MSG_ERROR(no random module available)
1187fi
1188print_egd_warning=no
1189for rndmod in $random_modules "" ; do
1190  case "$rndmod" in
1191    rndlinux)
1192         AC_DEFINE(USE_RNDLINUX,1,
1193                  [Defined if the /dev/random based RNG should be used.])
1194         use_rndlinux=yes
1195         ;;
1196    rndunix)
1197         AC_DEFINE(USE_RNDUNIX,1,
1198                  [Defined if the default Unix RNG should be used.])
1199         print_egd_warning=yes
1200         use_rndunix=yes
1201          ;;
1202    rndegd)
1203         AC_DEFINE(USE_RNDEGD,1,
1204                  [Defined if the EGD based RNG should be used.])
1205         use_rndegd=yes
1206         ;;
1207    rndw32)
1208         AC_DEFINE(USE_RNDW32,1,
1209                  [Defined if the Windows specific RNG should be used.])
1210         use_rndw32=yes
1211        ;;
1212   esac
1213done
1214
1215AM_CONDITIONAL(USE_RNDLINUX, test "$use_rndlinux" = yes)
1216AM_CONDITIONAL(USE_RNDUNIX,  test "$use_rndunix" = yes)
1217AM_CONDITIONAL(USE_RNDEGD,   test "$use_rndegd" = yes)
1218AM_CONDITIONAL(USE_RNDW32,   test "$use_rndw32" = yes)
1219
1220dnl setup assembler stuff
1221AC_MSG_CHECKING(for mpi assembler functions)
1222if test -f $srcdir/mpi/config.links ; then
1223    . $srcdir/mpi/config.links
1224    AC_CONFIG_LINKS("$mpi_ln_list")
1225    ac_cv_mpi_extra_asm_modules="$mpi_extra_modules"
1226    ac_cv_mpi_sflags="$mpi_sflags"
1227    ac_cv_mpi_config_done="yes"
1228    AC_MSG_RESULT(done)
1229else
1230    AC_MSG_RESULT(failed)
1231    AC_MSG_ERROR([mpi/config.links missing!])
1232fi
1233MPI_EXTRA_ASM_OBJS=""
1234show_extraasm=""
1235if test "$ac_cv_mpi_extra_asm_modules" != ""; then
1236for i in $ac_cv_mpi_extra_asm_modules; do
1237    show_extraasm="$show_extraasm $i"
1238    MPI_EXTRA_ASM_OBJS="$MPI_EXTRA_ASM_OBJS $i.o"
1239done
1240fi
1241AC_SUBST(MPI_EXTRA_ASM_OBJS)
1242MPI_SFLAGS="$ac_cv_mpi_sflags"
1243AC_SUBST(MPI_SFLAGS)
1244
1245# Sanity check regex.  Tests adapted from mutt.
1246
1247AC_MSG_CHECKING([whether regular expression support is requested])
1248AC_ARG_ENABLE(regex,
1249  AC_HELP_STRING([--disable-regex],
1250    [do not handle regular expressions in trust signatures]),
1251  use_regex=$enableval, use_regex=yes)
1252AC_MSG_RESULT($use_regex)
1253
1254if test "$use_regex" = yes ; then
1255  AC_MSG_CHECKING([whether the included regex lib is requested])
1256  AC_ARG_WITH(included-regex,
1257      AC_HELP_STRING([--with-included-regex],
1258                     [use the included GNU regex library]),
1259      [gnupg_cv_included_regex="$withval"],[gnupg_cv_included_regex=no])
1260  AC_MSG_RESULT($gnupg_cv_included_regex)
1261
1262  if test $gnupg_cv_included_regex = no ; then
1263     # Does the system have regex functions at all?
1264     AC_CHECK_FUNC(regcomp,gnupg_cv_included_regex=no,
1265			   gnupg_cv_included_regex=yes)
1266  fi
1267
1268  if test $gnupg_cv_included_regex = no ; then
1269     AC_CACHE_CHECK([whether your system's regexp library is broken],
1270       [gnupg_cv_regex_broken],
1271       AC_TRY_RUN([
1272#include <unistd.h>
1273#include <regex.h>
1274main() { 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); }],
1275       gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes))
1276
1277     if test $gnupg_cv_regex_broken = yes ; then
1278      AC_MSG_WARN(your regex is broken - using the included GNU regex instead.)
1279      gnupg_cv_included_regex=yes
1280     fi
1281  fi
1282
1283  if test $gnupg_cv_included_regex = yes; then
1284     AC_DEFINE(USE_INTERNAL_REGEX,1,[ Define if you want to use the included regex lib ])
1285  fi
1286else
1287  AC_DEFINE(DISABLE_REGEX,1,[ Define to disable regular expression support ])
1288fi
1289
1290AM_CONDITIONAL(USE_INTERNAL_REGEX, test x"$gnupg_cv_included_regex" = xyes)
1291
1292dnl Do we have zlib? Must do it here because Solaris failed
1293dnl when compiling a conftest (due to the "-lz" from LIBS).
1294use_local_zlib=yes
1295if test "$g10_force_zlib" = "yes"; then
1296  :
1297else
1298  _cppflags="${CPPFLAGS}"
1299  _ldflags="${LDFLAGS}"
1300
1301  AC_ARG_WITH(zlib,
1302     AC_HELP_STRING([--with-zlib=DIR],[use libz in DIR]),[
1303    if test -d "$withval"; then
1304      CPPFLAGS="${CPPFLAGS} -I$withval/include"
1305      LDFLAGS="${LDFLAGS} -L$withval/lib"
1306    fi
1307  ])
1308
1309  AC_CHECK_HEADER(zlib.h,
1310      AC_CHECK_LIB(z, deflateInit2_,
1311       use_local_zlib=no
1312       ZLIBS="-lz",
1313       CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1314       CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
1315fi
1316
1317if test "$use_local_zlib" = yes ; then
1318    AC_CONFIG_LINKS(zlib.h:zlib/zlib.h zconf.h:zlib/zconf.h )
1319    ZLIBS="../zlib/libzlib.a"
1320fi
1321
1322AM_CONDITIONAL(ENABLE_LOCAL_ZLIB, test "$use_local_zlib" = yes)
1323
1324
1325# Under W32 we force the use ofthe included bzip2 code.
1326if test x"$have_w32_system" = xyes ; then
1327    have_bz2=yes
1328    AC_DEFINE(HAVE_BZIP2,1,
1329              [Defined if the bz2 compression library is available])
1330    AC_CONFIG_LINKS(bzlib.h:bzlib/bzlib.h)
1331    ZLIBS="$ZLIBS ../bzlib/libbz2.a"
1332else
1333 if test "$use_bzip2" = yes ; then
1334  _cppflags="${CPPFLAGS}"
1335  _ldflags="${LDFLAGS}"
1336  AC_ARG_WITH(bzip2,
1337     AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]),
1338      [
1339      if test -d "$withval" ; then
1340        CPPFLAGS="${CPPFLAGS} -I$withval/include"
1341        LDFLAGS="${LDFLAGS} -L$withval/lib"
1342      fi
1343      ],withval="")
1344
1345# Checking alongside stdio.h as an early version of bzip2 (1.0)
1346# required stdio.h to be included before bzlib.h, and Solaris 9 is
1347# woefully out of date.
1348
1349  if test "$withval" != no ; then
1350     AC_CHECK_HEADER(bzlib.h,
1351        AC_CHECK_LIB(bz2,BZ2_bzCompressInit,
1352  	  [
1353	  have_bz2=yes
1354	  ZLIBS="$ZLIBS -lbz2"
1355	  AC_DEFINE(HAVE_BZIP2,1)
1356	  ],
1357	  CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1358	  CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include <stdio.h>])
1359  fi
1360 fi
1361fi
1362
1363AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes")
1364AC_SUBST(ZLIBS)
1365
1366# libusb allows us to use the integrated CCID smartcard reader driver.
1367# We don't need it if we don't have card support though.
1368if test "$card_support" = yes ; then
1369   GNUPG_CHECK_LIBUSB
1370fi
1371
1372# Check for readline support
1373GNUPG_CHECK_READLINE
1374
1375# Allow users to append something to the version string without
1376# flagging it as development version.  The user version parts is
1377# considered everything after a dash.
1378if test "$development_version" != yes; then
1379  changequote(,)dnl
1380  tmp_pat='[a-zA-Z]'
1381  changequote([,])dnl
1382  if echo "$VERSION" | sed 's/-.*//' | grep "$tmp_pat" >/dev/null ; then
1383    development_version=yes
1384  fi
1385fi
1386if test "$development_version" = yes; then
1387    AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1388            [Defined if this is not a regular release])
1389fi
1390
1391AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1392
1393
1394# add some extra libs here so that previous tests don't fail for
1395# mysterious reasons - the final link step should bail out.
1396case "${host}" in
1397    *-mingw32*)
1398dnl      NETLIBS="$NETLIBS -lwsock32"
1399	W32LIBS="-lwsock32"
1400        ;;
1401    *)
1402       ;;
1403esac
1404
1405AC_SUBST(NETLIBS)
1406AC_SUBST(W32LIBS)
1407
1408# Special options used with gcc.
1409if test "$GCC" = yes; then
1410    # Note that it is okay to use CFLAGS here because this are just
1411    # warning options and the user should have a chance of overriding
1412    #them.
1413    if test "$USE_MAINTAINER_MODE" = "yes"; then
1414        CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
1415        CFLAGS="$CFLAGS -Wformat-nonliteral"
1416    else
1417        CFLAGS="$CFLAGS -Wall"
1418    fi
1419
1420    # This is handy for debugging so the compiler doesn't rearrange
1421    # things and eliminate variables.
1422    AC_ARG_ENABLE(optimization,
1423       AC_HELP_STRING([--disable-optimization],
1424		      [disable compiler optimization]),
1425                      [if test $enableval = no ; then
1426                         CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//'`
1427                       fi])
1428
1429    AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
1430
1431    _gcc_cflags_save=$CFLAGS
1432    CFLAGS="-Wno-pointer-sign"
1433
1434    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],_gcc_psign=yes,_gcc_psign=no)
1435    AC_MSG_RESULT($_gcc_psign)
1436
1437    CFLAGS=$_gcc_cflags_save;
1438
1439    if test x"$_gcc_psign" = xyes ; then
1440       CFLAGS="$CFLAGS -Wno-pointer-sign"
1441    fi
1442fi
1443
1444CL_AS_NOEXECSTACK
1445
1446if test "$print_egd_warning" = yes; then
1447  AC_MSG_WARN([[
1448***
1449*** The performance of the UNIX random gatherer module is not very good
1450*** and it does not keep the entropy pool over multiple invocations of
1451*** GnuPG.  The suggested way to overcome this problem is to use the
1452***
1453***               Entropy Gathering Daemon (EGD)
1454***
1455*** which provides a entropy source for the whole system.  It is written
1456*** in Perl and available at the GnuPG FTP servers.  For more information
1457*** consult the GnuPG webpages:
1458***
1459***           http://www.gnupg.org/download/#EGD
1460***
1461*** You may want to run ./configure with --enable-static-rnd=egd or
1462*** --enable-static-rnd=auto to use it.
1463***]])
1464fi
1465
1466AC_CONFIG_FILES([
1467Makefile
1468m4/Makefile
1469intl/Makefile
1470po/Makefile.in
1471util/Makefile
1472mpi/Makefile
1473cipher/Makefile
1474g10/Makefile
1475keyserver/Makefile
1476keyserver/gpgkeys_mailto
1477keyserver/gpgkeys_test
1478doc/Makefile
1479tools/Makefile
1480tools/gpg-zip
1481zlib/Makefile
1482bzlib/Makefile
1483checks/Makefile
1484])
1485AC_OUTPUT
1486
1487# Give some feedback
1488echo
1489echo   "                Version info:   $PACKAGE_STRING"
1490echo   "                Configured for: $PRINTABLE_OS_NAME ($host)"
1491if test -n "$show_extraasm"; then
1492  echo "  Extra cpu specific functions:$show_extraasm"
1493fi
1494echo
1495