Merge branch 'STABLE-BRANCH-2-2' into master
[gnupg.git] / configure.ac
1 # configure.ac - for GnuPG 2.1
2 # Copyright (C) 1998-2018 Free Software Foundation, Inc.
3 # Copyright (C) 1998-2018 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 <https://www.gnu.org/licenses/>.
19
20 # Process this file with autoconf to produce a configure script.
21 AC_PREREQ(2.61)
22 min_automake_version="1.14"
23
24 # To build a release you need to create a tag with the version number
25 # (git tag -s gnupg-2.n.m) and run "./autogen.sh --force".  Please
26 # bump the version number immediately *after* the release and do
27 # another commit and push so that the git magic is able to work.
28 m4_define([mym4_package],[gnupg])
29 m4_define([mym4_major], [2])
30 m4_define([mym4_minor], [3])
31 m4_define([mym4_micro], [0])
32
33 # To start a new development series, i.e a new major or minor number
34 # you need to mark an arbitrary commit before the first beta release
35 # with an annotated tag.  For example the 2.1 branch starts off with
36 # the tag "gnupg-2.1-base".  This is used as the base for counting
37 # beta numbers before the first release of a series.
38
39 # Below is m4 magic to extract and compute the git revision number,
40 # the decimalized short revision number, a beta version string and a
41 # flag indicating a development version (mym4_isbeta).  Note that the
42 # m4 processing is done by autoconf and not during the configure run.
43 m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
44                            mym4_package mym4_major mym4_minor mym4_micro),[:]))
45 m4_define([mym4_isbeta],       m4_argn(2, mym4_verslist))
46 m4_define([mym4_version],      m4_argn(4, mym4_verslist))
47 m4_define([mym4_revision],     m4_argn(7, mym4_verslist))
48 m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
49 m4_esyscmd([echo ]mym4_version[>VERSION])
50 AC_INIT([mym4_package],[mym4_version], [https://bugs.gnupg.org])
51
52 # When changing the SWDB tag please also adjust the hard coded tags in
53 # build-aux/speedo.mk and Makefile.am
54 AC_DEFINE_UNQUOTED(GNUPG_SWDB_TAG, "gnupg24", [swdb tag for this branch])
55
56 NEED_GPG_ERROR_VERSION=1.24
57
58 NEED_LIBGCRYPT_API=1
59 NEED_LIBGCRYPT_VERSION=1.7.0
60
61 NEED_LIBASSUAN_API=2
62 NEED_LIBASSUAN_VERSION=2.5.0
63
64 NEED_KSBA_API=1
65 NEED_KSBA_VERSION=1.3.4
66
67 NEED_NTBTLS_API=1
68 NEED_NTBTLS_VERSION=0.1.0
69
70 NEED_NPTH_API=1
71 NEED_NPTH_VERSION=1.2
72
73
74 NEED_GNUTLS_VERSION=3.0
75
76 NEED_SQLITE_VERSION=3.7
77
78 development_version=mym4_isbeta
79 PACKAGE=$PACKAGE_NAME
80 PACKAGE_GT=${PACKAGE_NAME}2
81 VERSION=$PACKAGE_VERSION
82
83 AC_CONFIG_AUX_DIR([build-aux])
84 AC_CONFIG_SRCDIR([sm/gpgsm.c])
85 AC_CONFIG_HEADER([config.h])
86 AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
87 AC_CANONICAL_HOST
88 AB_INIT
89
90 AC_GNU_SOURCE
91
92
93 # Some status variables.
94 have_gpg_error=no
95 have_libgcrypt=no
96 have_libassuan=no
97 have_ksba=no
98 have_ntbtls=no
99 have_gnutls=no
100 have_sqlite=no
101 have_npth=no
102 have_libusb=no
103 have_system_resolver=no
104 gnupg_have_ldap="n/a"
105
106 use_zip=yes
107 use_bzip2=yes
108 use_exec=yes
109 use_trust_models=yes
110 use_tofu=yes
111 use_libdns=yes
112 card_support=yes
113 use_ccid_driver=auto
114 dirmngr_auto_start=yes
115 use_tls_library=no
116 large_secmem=no
117 show_tor_support=no
118
119 # gpg is a required part and can't be disabled anymore.
120 build_gpg=yes
121 GNUPG_BUILD_PROGRAM(gpgsm, yes)
122 # The agent is a required part and can't be disabled anymore.
123 build_agent=yes
124 GNUPG_BUILD_PROGRAM(scdaemon, yes)
125 GNUPG_BUILD_PROGRAM(g13, no)
126 GNUPG_BUILD_PROGRAM(dirmngr, yes)
127 GNUPG_BUILD_PROGRAM(doc, yes)
128 GNUPG_BUILD_PROGRAM(symcryptrun, no)
129 # We use gpgtar to unpack test data, hence we always build it.  If the
130 # user opts out, we simply don't install it.
131 GNUPG_BUILD_PROGRAM(gpgtar, yes)
132 GNUPG_BUILD_PROGRAM(wks-tools, no)
133
134 AC_SUBST(PACKAGE)
135 AC_SUBST(PACKAGE_GT)
136 AC_SUBST(VERSION)
137 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
138 AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT",
139                                 [Name of this package for gettext])
140 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
141 AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
142                                         [Bug report address])
143 AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION",
144                                        [Required version of Libgcrypt])
145 AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION",
146                                        [Required version of Libksba])
147 AC_DEFINE_UNQUOTED(NEED_NTBTLS_VERSION, "$NEED_NTBTLS_VERSION",
148                                        [Required version of NTBTLS])
149
150
151
152 # The default is to use the modules from this package and the few
153 # other packages in a standard place; i.e where this package gets
154 # installed.  With these options it is possible to override these
155 # ${prefix} depended values with fixed paths, which can't be replaced
156 # at make time.  See also am/cmacros.am and the defaults in AH_BOTTOM.
157 AC_ARG_WITH(agent-pgm,
158     [  --with-agent-pgm=PATH  Use PATH as the default for the agent)],
159           GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" )
160 AC_SUBST(GNUPG_AGENT_PGM)
161 AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM")
162 show_gnupg_agent_pgm="(default)"
163 test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM"
164
165 AC_ARG_WITH(pinentry-pgm,
166     [  --with-pinentry-pgm=PATH  Use PATH as the default for the pinentry)],
167           GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" )
168 AC_SUBST(GNUPG_PINENTRY_PGM)
169 AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM")
170 show_gnupg_pinentry_pgm="(default)"
171 test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM"
172
173
174 AC_ARG_WITH(scdaemon-pgm,
175     [  --with-scdaemon-pgm=PATH  Use PATH as the default for the scdaemon)],
176           GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" )
177 AC_SUBST(GNUPG_SCDAEMON_PGM)
178 AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM")
179 show_gnupg_scdaemon_pgm="(default)"
180 test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM"
181
182
183 AC_ARG_WITH(dirmngr-pgm,
184     [  --with-dirmngr-pgm=PATH  Use PATH as the default for the dirmngr)],
185           GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" )
186 AC_SUBST(GNUPG_DIRMNGR_PGM)
187 AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM")
188 show_gnupg_dirmngr_pgm="(default)"
189 test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM"
190
191 AC_ARG_WITH(protect-tool-pgm,
192     [  --with-protect-tool-pgm=PATH  Use PATH as the default for the protect-tool)],
193           GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" )
194 AC_SUBST(GNUPG_PROTECT_TOOL_PGM)
195 AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM")
196 show_gnupg_protect_tool_pgm="(default)"
197 test -n "$GNUPG_PROTECT_TOOL_PGM" \
198       && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM"
199
200 AC_ARG_WITH(dirmngr-ldap-pgm,
201     [  --with-dirmngr-ldap-pgm=PATH  Use PATH as the default for the dirmngr ldap wrapper)],
202           GNUPG_DIRMNGR_LDAP_PGM="$withval", GNUPG_DIRMNGR_LDAP_PGM="" )
203 AC_SUBST(GNUPG_DIRMNGR_LDAP_PGM)
204 AM_CONDITIONAL(GNUPG_DIRMNGR_LDAP_PGM, test -n "$GNUPG_DIRMNGR_LDAP_PGM")
205 show_gnupg_dirmngr_ldap_pgm="(default)"
206 test -n "$GNUPG_DIRMNGR_LDAP_PGM" \
207       && show_gnupg_dirmngr_ldap_pgm="$GNUPG_DIRMNGR_LDAP_PGM"
208
209
210 #
211 # For a long time gpg 2.x was installed as gpg2.  This changed with
212 # 2.2.  This option can be used to install gpg under the name gpg2.
213 #
214 AC_ARG_ENABLE(gpg-is-gpg2,
215     AC_HELP_STRING([--enable-gpg-is-gpg2],[Set installed name of gpg to gpg2]),
216     gpg_is_gpg2=$enableval)
217 if test "$gpg_is_gpg2" = "yes"; then
218    AC_DEFINE(USE_GPG2_HACK, 1, [Define to install gpg as gpg2])
219 fi
220 AM_CONDITIONAL(USE_GPG2_HACK, test "$gpg_is_gpg2" = "yes")
221
222
223 # SELinux support includes tracking of sensitive files to avoid
224 # leaking their contents through processing these files by gpg itself
225 AC_MSG_CHECKING([whether SELinux support is requested])
226 AC_ARG_ENABLE(selinux-support,
227               AC_HELP_STRING([--enable-selinux-support],
228                              [enable SELinux support]),
229               selinux_support=$enableval, selinux_support=no)
230 AC_MSG_RESULT($selinux_support)
231
232
233 AC_MSG_CHECKING([whether to allocate extra secure memory])
234 AC_ARG_ENABLE(large-secmem,
235               AC_HELP_STRING([--enable-large-secmem],
236                              [allocate extra secure memory]),
237               large_secmem=$enableval, large_secmem=no)
238 AC_MSG_RESULT($large_secmem)
239 if test "$large_secmem" = yes ; then
240    SECMEM_BUFFER_SIZE=65536
241 else
242    SECMEM_BUFFER_SIZE=32768
243 fi
244 AC_DEFINE_UNQUOTED(SECMEM_BUFFER_SIZE,$SECMEM_BUFFER_SIZE,
245                    [Size of secure memory buffer])
246
247 AC_MSG_CHECKING([calibrated passphrase-stretching (s2k) duration])
248 AC_ARG_WITH(agent-s2k-calibration,
249               AC_HELP_STRING([--with-agent-s2k-calibration=MSEC],
250                              [calibrate passphrase stretching (s2k) to MSEC milliseconds]),
251               agent_s2k_calibration=$withval, agent_s2k_calibration=100)
252 AC_MSG_RESULT($agent_s2k_calibration milliseconds)
253 AC_DEFINE_UNQUOTED(AGENT_S2K_CALIBRATION, $agent_s2k_calibration,
254                    [Agent s2k calibration time (ms)])
255
256 AC_MSG_CHECKING([whether to enable trust models])
257 AC_ARG_ENABLE(trust-models,
258               AC_HELP_STRING([--disable-trust-models],
259                              [disable all trust models except "always"]),
260               use_trust_models=$enableval)
261 AC_MSG_RESULT($use_trust_models)
262 if test "$use_trust_models" = no ; then
263     AC_DEFINE(NO_TRUST_MODELS, 1,
264              [Define to include only trust-model always])
265 fi
266
267 AC_MSG_CHECKING([whether to enable TOFU])
268 AC_ARG_ENABLE(tofu,
269                 AC_HELP_STRING([--disable-tofu],
270                                [disable the TOFU trust model]),
271               use_tofu=$enableval, use_tofu=$use_trust_models)
272 AC_MSG_RESULT($use_tofu)
273 if test "$use_trust_models" = no && test "$use_tofu" = yes; then
274     AC_MSG_ERROR([both --disable-trust-models and --enable-tofu given])
275 fi
276
277 AC_MSG_CHECKING([whether to enable libdns])
278 AC_ARG_ENABLE(libdns,
279                 AC_HELP_STRING([--disable-libdns],
280                                [do not build with libdns support]),
281               use_libdns=$enableval, use_libdns=yes)
282 AC_MSG_RESULT($use_libdns)
283 if test x"$use_libdns" = xyes ; then
284     AC_DEFINE(USE_LIBDNS, 1, [Build with integrated libdns support])
285 fi
286 AM_CONDITIONAL(USE_LIBDNS, test "$use_libdns" = yes)
287
288
289 #
290 # Options to disable algorithm
291 #
292
293 GNUPG_GPG_DISABLE_ALGO([rsa],[RSA public key])
294 # Elgamal is a MUST algorithm
295 # DSA is a MUST algorithm
296 GNUPG_GPG_DISABLE_ALGO([ecdh],[ECDH public key])
297 GNUPG_GPG_DISABLE_ALGO([ecdsa],[ECDSA public key])
298 GNUPG_GPG_DISABLE_ALGO([eddsa],[EdDSA public key])
299
300 GNUPG_GPG_DISABLE_ALGO([idea],[IDEA cipher])
301 # 3DES is a MUST algorithm
302 GNUPG_GPG_DISABLE_ALGO([cast5],[CAST5 cipher])
303 GNUPG_GPG_DISABLE_ALGO([blowfish],[BLOWFISH cipher])
304 GNUPG_GPG_DISABLE_ALGO([aes128],[AES128 cipher])
305 GNUPG_GPG_DISABLE_ALGO([aes192],[AES192 cipher])
306 GNUPG_GPG_DISABLE_ALGO([aes256],[AES256 cipher])
307 GNUPG_GPG_DISABLE_ALGO([twofish],[TWOFISH cipher])
308 GNUPG_GPG_DISABLE_ALGO([camellia128],[CAMELLIA128 cipher])
309 GNUPG_GPG_DISABLE_ALGO([camellia192],[CAMELLIA192 cipher])
310 GNUPG_GPG_DISABLE_ALGO([camellia256],[CAMELLIA256 cipher])
311
312 GNUPG_GPG_DISABLE_ALGO([md5],[MD5 hash])
313 # SHA1 is a MUST algorithm
314 GNUPG_GPG_DISABLE_ALGO([rmd160],[RIPE-MD160 hash])
315 GNUPG_GPG_DISABLE_ALGO([sha224],[SHA-224 hash])
316 # SHA256 is a MUST algorithm for GnuPG.
317 GNUPG_GPG_DISABLE_ALGO([sha384],[SHA-384 hash])
318 GNUPG_GPG_DISABLE_ALGO([sha512],[SHA-512 hash])
319
320
321 # Allow disabling of zip support.
322 # This is in general not a good idea because according to rfc4880 OpenPGP
323 # implementations SHOULD support ZLIB.
324 AC_MSG_CHECKING([whether to enable the ZIP and ZLIB compression algorithm])
325 AC_ARG_ENABLE(zip,
326    AC_HELP_STRING([--disable-zip],
327                   [disable the ZIP and ZLIB compression algorithm]),
328    use_zip=$enableval)
329 AC_MSG_RESULT($use_zip)
330
331 # Allow disabling of bzib2 support.
332 # It is defined only after we confirm the library is available later
333 AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm])
334 AC_ARG_ENABLE(bzip2,
335    AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]),
336    use_bzip2=$enableval)
337 AC_MSG_RESULT($use_bzip2)
338
339 # Configure option to allow or disallow execution of external
340 # programs, like a photo viewer.
341 AC_MSG_CHECKING([whether to enable external program execution])
342 AC_ARG_ENABLE(exec,
343     AC_HELP_STRING([--disable-exec],[disable all external program execution]),
344     use_exec=$enableval)
345 AC_MSG_RESULT($use_exec)
346 if test "$use_exec" = no ; then
347     AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution])
348 fi
349
350 if test "$use_exec" = yes ; then
351   AC_MSG_CHECKING([whether to enable photo ID viewing])
352   AC_ARG_ENABLE(photo-viewers,
353       [  --disable-photo-viewers disable photo ID viewers],
354       [if test "$enableval" = no ; then
355          AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing])
356       fi],enableval=yes)
357   gnupg_cv_enable_photo_viewers=$enableval
358   AC_MSG_RESULT($enableval)
359
360   if test "$gnupg_cv_enable_photo_viewers" = yes ; then
361     AC_MSG_CHECKING([whether to use a fixed photo ID viewer])
362     AC_ARG_WITH(photo-viewer,
363         [  --with-photo-viewer=FIXED_VIEWER  set a fixed photo ID viewer],
364         [if test "$withval" = yes ; then
365            withval=no
366         elif test "$withval" != no ; then
367            AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval",
368                             [if set, restrict photo-viewer to this])
369         fi],withval=no)
370     AC_MSG_RESULT($withval)
371   fi
372 fi
373
374
375 #
376 # Check for the key/uid cache size.  This can't be zero, but can be
377 # pretty small on embedded systems.  This is used for the gpg part.
378 #
379 AC_MSG_CHECKING([for the size of the key and uid cache])
380 AC_ARG_ENABLE(key-cache,
381         AC_HELP_STRING([--enable-key-cache=SIZE],
382                        [Set key cache to SIZE (default 4096)]),,enableval=4096)
383 if test "$enableval" = "no"; then
384    enableval=5
385 elif test "$enableval" = "yes" || test "$enableval" = ""; then
386    enableval=4096
387 fi
388 changequote(,)dnl
389 key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'`
390 changequote([,])dnl
391 if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then
392    AC_MSG_ERROR([invalid key-cache size])
393 fi
394 AC_MSG_RESULT($key_cache_size)
395 AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size,
396                   [Size of the key and UID caches])
397
398
399
400 #
401 # Check whether we want to use Linux capabilities
402 #
403 AC_MSG_CHECKING([whether use of capabilities is requested])
404 AC_ARG_WITH(capabilities,
405     [  --with-capabilities     use linux capabilities [default=no]],
406 [use_capabilities="$withval"],[use_capabilities=no])
407 AC_MSG_RESULT($use_capabilities)
408
409 #
410 # Check whether to disable the card support
411 AC_MSG_CHECKING([whether smartcard support is requested])
412 AC_ARG_ENABLE(card-support,
413               AC_HELP_STRING([--disable-card-support],
414                              [disable smartcard support]),
415               card_support=$enableval)
416 AC_MSG_RESULT($card_support)
417 if test "$card_support" = yes ; then
418   AC_DEFINE(ENABLE_CARD_SUPPORT,1,[Define to include smartcard support])
419 else
420   build_scdaemon=no
421 fi
422
423 #
424 # Allow disabling of internal CCID support.
425 # It is defined only after we confirm the library is available later
426 #
427 AC_MSG_CHECKING([whether to enable the internal CCID driver])
428 AC_ARG_ENABLE(ccid-driver,
429               AC_HELP_STRING([--disable-ccid-driver],
430                              [disable the internal CCID driver]),
431               use_ccid_driver=$enableval)
432 AC_MSG_RESULT($use_ccid_driver)
433
434 AC_MSG_CHECKING([whether to auto start dirmngr])
435 AC_ARG_ENABLE(dirmngr-auto-start,
436               AC_HELP_STRING([--disable-dirmngr-auto-start],
437                              [disable auto starting of the dirmngr]),
438               dirmngr_auto_start=$enableval)
439 AC_MSG_RESULT($dirmngr_auto_start)
440 if test "$dirmngr_auto_start" = yes ; then
441     AC_DEFINE(USE_DIRMNGR_AUTO_START,1,
442               [Define to enable auto starting of the dirmngr])
443 fi
444
445
446 #
447 # To avoid double inclusion of config.h which might happen at some
448 # places, we add the usual double inclusion protection at the top of
449 # config.h.
450 #
451 AH_TOP([
452 #ifndef GNUPG_CONFIG_H_INCLUDED
453 #define GNUPG_CONFIG_H_INCLUDED
454 ])
455
456 #
457 # Stuff which goes at the bottom of config.h.
458 #
459 AH_BOTTOM([
460 /* This is the major version number of GnuPG so that
461    source included files can test for this.  Note, that
462    we use 2 here even for GnuPG 1.9.x. */
463 #define GNUPG_MAJOR_VERSION 2
464
465 /* Now to separate file name parts.
466    Please note that the string version must not contain more
467    than one character because the code assumes strlen()==1 */
468 #ifdef HAVE_DOSISH_SYSTEM
469 #define DIRSEP_C '\\'
470 #define DIRSEP_S "\\"
471 #define EXTSEP_C '.'
472 #define EXTSEP_S "."
473 #define PATHSEP_C ';'
474 #define PATHSEP_S ";"
475 #define EXEEXT_S ".exe"
476 #else
477 #define DIRSEP_C '/'
478 #define DIRSEP_S "/"
479 #define EXTSEP_C '.'
480 #define EXTSEP_S "."
481 #define PATHSEP_C ':'
482 #define PATHSEP_S ":"
483 #define EXEEXT_S ""
484 #endif
485
486 /* This is the same as VERSION, but should be overridden if the
487    platform cannot handle things like dots '.' in filenames. Set
488    SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION
489    uses for dots and dashes. */
490 #define SAFE_VERSION VERSION
491 #define SAFE_VERSION_DOT  '.'
492 #define SAFE_VERSION_DASH '-'
493
494 /* Some global constants.
495  * Note that the homedir must not end in a slash.  */
496 #ifdef HAVE_DOSISH_SYSTEM
497 # ifdef HAVE_DRIVE_LETTERS
498 #  define GNUPG_DEFAULT_HOMEDIR "c:/gnupg"
499 # else
500 #  define GNUPG_DEFAULT_HOMEDIR "/gnupg"
501 # endif
502 #elif defined(__VMS)
503 #define GNUPG_DEFAULT_HOMEDIR "/SYS$LOGIN/gnupg"
504 #else
505 #define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
506 #endif
507 #define GNUPG_PRIVATE_KEYS_DIR  "private-keys-v1.d"
508 #define GNUPG_OPENPGP_REVOC_DIR "openpgp-revocs.d"
509
510 /* For some systems (DOS currently), we hardcode the path here.  For
511    POSIX systems the values are constructed by the Makefiles, so that
512    the values may be overridden by the make invocations; this is to
513    comply with the GNU coding standards.  Note that these values are
514    only defaults.  */
515 #ifdef HAVE_DOSISH_SYSTEM
516 # ifdef HAVE_DRIVE_LETTERS
517 #  define GNUPG_BINDIR      "c:\\gnupg"
518 #  define GNUPG_LIBEXECDIR  "c:\\gnupg"
519 #  define GNUPG_LIBDIR      "c:\\gnupg"
520 #  define GNUPG_DATADIR     "c:\\gnupg"
521 #  define GNUPG_SYSCONFDIR  "c:\\gnupg"
522 # else
523 #  define GNUPG_BINDIR      "\\gnupg"
524 #  define GNUPG_LIBEXECDIR  "\\gnupg"
525 #  define GNUPG_LIBDIR      "\\gnupg"
526 #  define GNUPG_DATADIR     "\\gnupg"
527 #  define GNUPG_SYSCONFDIR  "\\gnupg"
528 # endif
529 #endif
530
531 /* Derive some other constants. */
532 #if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
533 #define EXEC_TEMPFILE_ONLY
534 #endif
535
536
537 /* We didn't define endianness above, so get it from OS macros.  This
538    is intended for making fat binary builds on OS X. */
539 #if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST)
540 #if defined(__BIG_ENDIAN__)
541 #define BIG_ENDIAN_HOST 1
542 #elif defined(__LITTLE_ENDIAN__)
543 #define LITTLE_ENDIAN_HOST 1
544 #else
545 #error "No endianness found"
546 #endif
547 #endif
548
549
550 /* Hack used for W32: ldap.m4 also tests for the ASCII version of
551    ldap_start_tls_s because that is the actual symbol used in the
552    library.  winldap.h redefines it to our commonly used value,
553    thus we define our usual macro here.  */
554 #ifdef HAVE_LDAP_START_TLS_SA
555 # ifndef HAVE_LDAP_START_TLS_S
556 #  define HAVE_LDAP_START_TLS_S 1
557 # endif
558 #endif
559
560 /* Enable the es_ macros from gpgrt.  */
561 #define GPGRT_ENABLE_ES_MACROS 1
562
563 /* Enable the log_ macros from gpgrt.  */
564 #define GPGRT_ENABLE_LOG_MACROS 1
565
566 /* Tell libgcrypt not to use its own libgpg-error implementation. */
567 #define USE_LIBGPG_ERROR 1
568
569 /* Tell Libgcrypt not to include deprecated definitions.  */
570 #define GCRYPT_NO_DEPRECATED 1
571
572 /* Our HTTP code is used in estream mode.  */
573 #define HTTP_USE_ESTREAM 1
574
575 /* Under W32 we do an explicit socket initialization, thus we need to
576    avoid the on-demand initialization which would also install an atexit
577    handler.  */
578 #define HTTP_NO_WSASTARTUP
579
580 /* Under Windows we use the gettext code from libgpg-error.  */
581 #define GPG_ERR_ENABLE_GETTEXT_MACROS
582
583 /* Under WindowsCE we use the strerror replacement from libgpg-error.  */
584 #define GPG_ERR_ENABLE_ERRNO_MACROS
585
586 #endif /*GNUPG_CONFIG_H_INCLUDED*/
587 ])
588
589
590 AM_MAINTAINER_MODE
591 AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
592
593 # Checks for programs.
594 AC_MSG_NOTICE([checking for programs])
595 AC_PROG_MAKE_SET
596 AM_SANITY_CHECK
597 missing_dir=`cd $ac_aux_dir && pwd`
598 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
599 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
600 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
601 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
602 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
603 AM_SILENT_RULES
604 AC_PROG_AWK
605 AC_PROG_CC
606 AC_PROG_CPP
607 AM_PROG_CC_C_O
608 if test "x$ac_cv_prog_cc_c89" = "xno" ; then
609   AC_MSG_ERROR([[No C-89 compiler found]])
610 fi
611 AC_PROG_INSTALL
612 AC_PROG_LN_S
613 AC_PROG_RANLIB
614 AC_CHECK_TOOL(AR, ar, :)
615 AC_PATH_PROG(PERL,"perl")
616 AC_CHECK_TOOL(WINDRES, windres, :)
617 AC_PATH_PROG(YAT2M, "yat2m", "./yat2m" )
618 AC_ARG_VAR(YAT2M, [tool to convert texi to man pages])
619 AM_CONDITIONAL(HAVE_YAT2M, test -n "$ac_cv_path_YAT2M")
620 AC_ISC_POSIX
621 AC_SYS_LARGEFILE
622 GNUPG_CHECK_USTAR
623
624
625 # We need to compile and run a program on the build machine.  A
626 # comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
627 # the AC archive is broken for autoconf 2.57.  Given that there is no
628 # newer version of that macro, we assume that it is also broken for
629 # autoconf 2.61 and thus we use a simple but usually sufficient
630 # approach.
631 AC_MSG_CHECKING(for cc for build)
632 if test "$cross_compiling" = "yes"; then
633   CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
634 else
635   CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
636 fi
637 AC_MSG_RESULT($CC_FOR_BUILD)
638 AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])
639
640 # We need to call this macro because other pkg-config macros are
641 # not always used.
642 PKG_PROG_PKG_CONFIG
643
644
645 try_gettext=yes
646 require_iconv=yes
647 have_dosish_system=no
648 have_w32_system=no
649 have_w32ce_system=no
650 have_android_system=no
651 use_simple_gettext=no
652 use_ldapwrapper=yes
653 mmap_needed=yes
654 require_pipe_to_unblock_pselect=yes
655 case "${host}" in
656     *-mingw32*)
657         # special stuff for Windoze NT
658         ac_cv_have_dev_random=no
659         AC_DEFINE(USE_ONLY_8DOT3,1,
660                   [Set this to limit filenames to the 8.3 format])
661         AC_DEFINE(USE_SIMPLE_GETTEXT,1,
662                   [Because the Unix gettext has too much overhead on
663                    MingW32 systems and these systems lack Posix functions,
664                    we use a simplified version of gettext])
665         have_dosish_system=yes
666         have_w32_system=yes
667         require_iconv=no
668         use_ldapwrapper=no  # Fixme: Do this only for CE.
669         require_pipe_to_unblock_pselect=no
670         case "${host}" in
671           *-mingw32ce*)
672             have_w32ce_system=yes
673             ;;
674           *)
675             AC_DEFINE(HAVE_DRIVE_LETTERS,1,
676                       [Defined if the OS supports drive letters.])
677             ;;
678         esac
679         try_gettext="no"
680         use_simple_gettext=yes
681         mmap_needed=no
682         ;;
683     i?86-emx-os2 | i?86-*-os2*emx )
684         # OS/2 with the EMX environment
685         ac_cv_have_dev_random=no
686         AC_DEFINE(HAVE_DRIVE_LETTERS)
687         have_dosish_system=yes
688         try_gettext="no"
689         ;;
690
691     i?86-*-msdosdjgpp*)
692         # DOS with the DJGPP environment
693         ac_cv_have_dev_random=no
694         AC_DEFINE(HAVE_DRIVE_LETTERS)
695         have_dosish_system=yes
696         try_gettext="no"
697         ;;
698
699     *-*-hpux*)
700         if test -z "$GCC" ; then
701             CFLAGS="-Ae -D_HPUX_SOURCE $CFLAGS"
702         fi
703         ;;
704     *-dec-osf4*)
705         if test -z "$GCC" ; then
706             # Suppress all warnings
707             # to get rid of the unsigned/signed char mismatch warnings.
708             CFLAGS="-w $CFLAGS"
709         fi
710         ;;
711     *-dec-osf5*)
712         if test -z "$GCC" ; then
713             # Use the newer compiler `-msg_disable ptrmismatch1' to
714             # get rid of the unsigned/signed char mismatch warnings.
715             # Using this may hide other pointer mismatch warnings, but
716             # it at least lets other warning classes through
717             CFLAGS="-msg_disable ptrmismatch1 $CFLAGS"
718         fi
719         ;;
720     m68k-atari-mint)
721         ;;
722     *-linux-android*)
723         have_android_system=yes
724         # Android is fully utf-8 and we do not want to use iconv to
725         # keeps things simple
726         require_iconv=no
727         ;;
728     *-apple-darwin*)
729         AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
730                   Expose all libc features (__DARWIN_C_FULL).)
731         ;;
732     *-*-netbsd*)
733         require_pipe_to_unblock_pselect=yes
734         ;;
735     *)
736         ;;
737 esac
738
739 if test "$require_pipe_to_unblock_pselect" = yes; then
740    AC_DEFINE(HAVE_PSELECT_NO_EINTR, 1,
741              [Defined if we run on systems like NetBSD, where
742               pselect cannot be unblocked by signal from a thread
743               within the same process.  We use pipe in this case, instead.])
744 fi
745
746 if test "$have_dosish_system" = yes; then
747    AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
748              [Defined if we run on some of the PCDOS like systems
749               (DOS, Windoze. OS/2) with special properties like
750               no file modes, case insensitive file names and preferred
751               use of backslashes as directory name separators.])
752 fi
753 AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)
754
755 AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes)
756
757 if test "$have_w32_system" = yes; then
758    AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
759    if test "$have_w32ce_system" = yes; then
760       AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
761    fi
762 fi
763 AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
764 AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
765
766 if test "$have_android_system" = yes; then
767    AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
768 fi
769 AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)
770
771
772 # (These need to go after AC_PROG_CC so that $EXEEXT is defined)
773 AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any])
774
775
776 #
777 # Checks for libraries.
778 #
779 AC_MSG_NOTICE([checking for libraries])
780
781
782 #
783 # libgpg-error is a library with error codes shared between GnuPG
784 # related projects.
785 #
786 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
787                   have_gpg_error=yes,have_gpg_error=no)
788
789
790 #
791 # Libgcrypt is our generic crypto library
792 #
793 AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION",
794         have_libgcrypt=yes,have_libgcrypt=no)
795
796
797 #
798 # libassuan is used for IPC
799 #
800 AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
801                   have_libassuan=yes,have_libassuan=no)
802 if test "$have_libassuan" = "yes"; then
803   AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version",
804                      [version of the libassuan library])
805   show_tor_support="only .onion"
806 fi
807
808
809 #
810 # libksba is our X.509 support library
811 #
812 AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no)
813
814
815 #
816 # libusb allows us to use the integrated CCID smartcard reader driver.
817 #
818 # FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs.
819 if test "$use_ccid_driver" = auto || test "$use_ccid_driver" = yes; then
820    case "${host}" in
821      *-mingw32*)
822        LIBUSB_NAME=
823        LIBUSB_LIBS=
824        LIBUSB_CPPFLAGS=
825        ;;
826      *-*-darwin*)
827        LIBUSB_NAME=usb-1.0
828        LIBUSB_LIBS="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit"
829        ;;
830      *-*-freebsd*)
831        # FreeBSD has a native 1.0 compatible library by -lusb.
832        LIBUSB_NAME=usb
833        LIBUSB_LIBS=
834        ;;
835      *)
836        LIBUSB_NAME=usb-1.0
837        LIBUSB_LIBS=
838        ;;
839    esac
840 fi
841 if test x"$LIBUSB_NAME" != x ; then
842    AC_CHECK_LIB($LIBUSB_NAME, libusb_init,
843                 [ LIBUSB_LIBS="-l$LIBUSB_NAME $LIBUSB_LIBS"
844                   have_libusb=yes ])
845    AC_MSG_CHECKING([libusb include dir])
846    usb_incdir_found="no"
847    for _incdir in "" "/usr/include/libusb-1.0" \
848        "/usr/local/include/libusb-1.0" "/usr/pkg/include/libusb-1.0"; do
849      _libusb_save_cppflags=$CPPFLAGS
850      if test -n "${_incdir}"; then
851        CPPFLAGS="-I${_incdir} ${CPPFLAGS}"
852      fi
853      AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <libusb.h>]])],
854      [usb_incdir=${_incdir}; usb_incdir_found="yes"], [])
855      CPPFLAGS=${_libusb_save_cppflags}
856      if test "$usb_incdir_found" = "yes"; then
857        break
858      fi
859    done
860    if test "$usb_incdir_found" = "yes"; then
861      AC_MSG_RESULT([${usb_incdir}])
862    else
863      AC_MSG_RESULT([not found])
864      usb_incdir=""
865      have_libusb=no
866      if test "$use_ccid_driver" != yes; then
867        use_ccid_driver=no
868      fi
869      LIBUSB_LIBS=""
870    fi
871
872    if test "$have_libusb" = yes; then
873      AC_DEFINE(HAVE_LIBUSB,1, [defined if libusb is available])
874    fi
875    if test x"$usb_incdir" = x; then
876      LIBUSB_CPPFLAGS=""
877    else
878      LIBUSB_CPPFLAGS="-I${usb_incdir}"
879    fi
880 fi
881 AC_SUBST(LIBUSB_LIBS)
882 AC_SUBST(LIBUSB_CPPFLAGS)
883
884 #
885 # Check whether it is necessary to link against libdl.
886 # (For example to load libpcsclite)
887 #
888 gnupg_dlopen_save_libs="$LIBS"
889 LIBS=""
890 AC_SEARCH_LIBS(dlopen, c dl,,,)
891 DL_LIBS=$LIBS
892 AC_SUBST(DL_LIBS)
893 LIBS="$gnupg_dlopen_save_libs"
894
895
896 # Checks for g10
897
898 AC_ARG_ENABLE(sqlite,
899                 AC_HELP_STRING([--disable-sqlite],
900                                [disable the use of SQLITE]),
901               try_sqlite=$enableval, try_sqlite=yes)
902
903 if test x"$use_tofu" = xyes ; then
904   if test x"$try_sqlite" = xyes ; then
905     PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= $NEED_SQLITE_VERSION],
906                                  [have_sqlite=yes],
907                                  [have_sqlite=no])
908   fi
909   if test "$have_sqlite" = "yes"; then
910     :
911     AC_SUBST([SQLITE3_CFLAGS])
912     AC_SUBST([SQLITE3_LIBS])
913   else
914     use_tofu=no
915     tmp=$(echo "$SQLITE3_PKG_ERRORS" | tr '\n' '\v' | sed 's/\v/\n*** /g')
916     AC_MSG_WARN([[
917 ***
918 *** Building without SQLite support - TOFU disabled
919 ***
920 *** $tmp]])
921   fi
922 fi
923
924 AM_CONDITIONAL(SQLITE3, test "$have_sqlite" = "yes")
925
926 if test x"$use_tofu" = xyes ; then
927     AC_DEFINE(USE_TOFU, 1, [Enable to build the TOFU code])
928 fi
929
930
931 # Checks for g13
932
933 AC_PATH_PROG(ENCFS, encfs, /usr/bin/encfs)
934 AC_DEFINE_UNQUOTED(ENCFS,
935         "${ENCFS}", [defines the filename of the encfs program])
936
937 AC_PATH_PROG(FUSERMOUNT, fusermount, /usr/bin/fusermount)
938 AC_DEFINE_UNQUOTED(FUSERMOUNT,
939         "${FUSERMOUNT}", [defines the filename of the fusermount program])
940
941
942 # Checks for dirmngr
943
944
945 #
946 # Checks for symcryptrun:
947 #
948
949 # libutil has openpty() and login_tty().
950 AC_CHECK_LIB(util, openpty,
951               [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil"
952                 AC_DEFINE(HAVE_LIBUTIL,1,
953                          [defined if libutil is available])
954              ])
955 AC_SUBST(LIBUTIL_LIBS)
956
957 # shred is used to clean temporary plain text files.
958 AC_PATH_PROG(SHRED, shred, /usr/bin/shred)
959 AC_DEFINE_UNQUOTED(SHRED,
960         "${SHRED}", [defines the filename of the shred program])
961
962
963 #
964 # Check whether the nPth library is available
965 #
966 AM_PATH_NPTH("$NEED_NPTH_API:$NEED_NPTH_VERSION",have_npth=yes,have_npth=no)
967 if test "$have_npth" = "yes"; then
968   AC_DEFINE(HAVE_NPTH, 1,
969               [Defined if the New Portable Thread Library is available])
970   AC_DEFINE(USE_NPTH, 1,
971               [Defined if support for nPth is requested and nPth is available])
972 else
973   AC_MSG_WARN([[
974 ***
975 *** To support concurrent access for example in gpg-agent and the SCdaemon
976 *** we need the support of the New Portable Threads Library.
977 ***]])
978 fi
979
980
981 #
982 # NTBTLS is our TLS library.  If it is not available fallback to
983 # GNUTLS.
984 #
985 AC_ARG_ENABLE(ntbtls,
986               AC_HELP_STRING([--disable-ntbtls],
987                              [disable the use of NTBTLS as TLS library]),
988               try_ntbtls=$enableval, try_ntbtls=yes)
989 if test x"$try_ntbtls" = xyes ; then
990   AM_PATH_NTBTLS("$NEED_NTBTLS_API:$NEED_NTBTLS_VERSION",
991                  [have_ntbtls=yes],[have_ntbtls=no])
992 fi
993 if test "$have_ntbtls" = yes ; then
994    use_tls_library=ntbtls
995    AC_DEFINE(HTTP_USE_NTBTLS, 1, [Enable NTBTLS support in http.c])
996 else
997   AC_ARG_ENABLE(gnutls,
998                 AC_HELP_STRING([--disable-gnutls],
999                                [disable GNUTLS as fallback TLS library]),
1000                 try_gnutls=$enableval, try_gnutls=yes)
1001   if test x"$try_gnutls" = xyes ; then
1002     PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= $NEED_GNUTLS_VERSION],
1003                                    [have_gnutls=yes],
1004                                    [have_gnutls=no])
1005   fi
1006   if test "$have_gnutls" = "yes"; then
1007     AC_SUBST([LIBGNUTLS_CFLAGS])
1008     AC_SUBST([LIBGNUTLS_LIBS])
1009     use_tls_library=gnutls
1010     AC_DEFINE(HTTP_USE_GNUTLS, 1, [Enable GNUTLS support in http.c])
1011   else
1012     tmp=$(echo "$LIBGNUTLS_PKG_ERRORS" | tr '\n' '\v' | sed 's/\v/\n*** /g')
1013     AC_MSG_WARN([[
1014 ***
1015 *** Building without NTBTLS and GNUTLS - no TLS access to keyservers.
1016 ***
1017 *** $tmp]])
1018   fi
1019 fi
1020
1021 #
1022 # Allow to set a fixed trust store file for system provided certificates.
1023 #
1024 AC_ARG_WITH([default-trust-store-file],
1025             [AC_HELP_STRING([--with-default-trust-store-file=FILE],
1026                             [Use FILE as system trust store])],
1027             default_trust_store_file="$withval",
1028             default_trust_store_file="")
1029 if test x"$default_trust_store_file" = xno;then
1030   default_trust_store_file=""
1031 fi
1032 if test x"$default_trust_store_file" != x ; then
1033   AC_DEFINE_UNQUOTED([DEFAULT_TRUST_STORE_FILE],
1034     ["$default_trust_store_file"], [Use as default system trust store file])
1035 fi
1036
1037
1038 AC_MSG_NOTICE([checking for networking options])
1039
1040 #
1041 # Must check for network library requirements before doing link tests
1042 # for ldap, for example. If ldap libs are static (or dynamic and without
1043 # ELF runtime link paths), then link will fail and LDAP support won't
1044 # be detected.
1045 #
1046 AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
1047         [NETLIBS="-lnsl $NETLIBS"]))
1048 AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
1049         [NETLIBS="-lsocket $NETLIBS"]))
1050
1051
1052 #
1053 # Check standard resolver functions.
1054 #
1055 if test "$build_dirmngr" = "yes"; then
1056   _dns_save_libs=$LIBS
1057   LIBS=""
1058
1059   # Find the system resolver which can always be enabled with
1060   # the dirmngr option --standard-resolver.
1061
1062   # the double underscore thing is a glibc-ism?
1063   AC_SEARCH_LIBS(res_query,resolv bind,,
1064                  AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no))
1065   AC_SEARCH_LIBS(dn_expand,resolv bind,,
1066                  AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no))
1067
1068   # macOS renames dn_skipname into res_9_dn_skipname in <resolv.h>,
1069   # and for some reason fools us into believing we don't need
1070   # -lresolv even if we do.  Since the test program checking for the
1071   # symbol does not include <resolv.h>, we need to check for the
1072   # renamed symbol explicitly.
1073   AC_SEARCH_LIBS(res_9_dn_skipname,resolv bind,,
1074       AC_SEARCH_LIBS(dn_skipname,resolv bind,,
1075           AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no)))
1076
1077   if test x"$have_resolver" != xno ; then
1078
1079       # Make sure that the BIND 4 resolver interface is workable before
1080       # enabling any code that calls it.  At some point I'll rewrite the
1081       # code to use the BIND 8 resolver API.
1082       # We might also want to use libdns instead.
1083
1084     AC_MSG_CHECKING([whether the resolver is usable])
1085     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1086 #include <netinet/in.h>
1087 #include <arpa/nameser.h>
1088 #include <resolv.h>]],
1089 [[unsigned char answer[PACKETSZ];
1090   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
1091   dn_skipname(0,0);
1092   dn_expand(0,0,0,0,0);
1093 ]])],have_resolver=yes,have_resolver=no)
1094     AC_MSG_RESULT($have_resolver)
1095
1096     # This is Apple-specific and somewhat bizarre as they changed the
1097     # define in bind 8 for some reason.
1098
1099     if test x"$have_resolver" != xyes ; then
1100       AC_MSG_CHECKING(
1101            [whether I can make the resolver usable with BIND_8_COMPAT])
1102       AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define BIND_8_COMPAT
1103 #include <sys/types.h>
1104 #include <netinet/in.h>
1105 #include <arpa/nameser.h>
1106 #include <resolv.h>]],
1107 [[unsigned char answer[PACKETSZ];
1108   res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
1109   dn_skipname(0,0); dn_expand(0,0,0,0,0);
1110 ]])],[have_resolver=yes ; need_compat=yes])
1111       AC_MSG_RESULT($have_resolver)
1112     fi
1113   fi
1114
1115   if test x"$have_resolver" = xyes ; then
1116     AC_DEFINE(HAVE_SYSTEM_RESOLVER,1,[The system's resolver is usable.])
1117     DNSLIBS="$DNSLIBS $LIBS"
1118     if test x"$need_compat" = xyes ; then
1119       AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism])
1120     fi
1121     if test "$use_libdns" = yes; then
1122      show_tor_support=yes
1123     fi
1124   elif test "$use_libdns" = yes; then
1125     show_tor_support=yes
1126   else
1127     AC_MSG_WARN([[
1128 ***
1129 *** The system's DNS resolver is not usable.
1130 *** Dirmngr functionality is limited.
1131 ***]])
1132     show_tor_support="${show_tor_support} (no system resolver)"
1133   fi
1134
1135   if test "$have_w32_system" = yes; then
1136     if test "$use_libdns" = yes; then
1137       DNSLIBS="$DNSLIBS -liphlpapi"
1138     fi
1139   fi
1140
1141   LIBS=$_dns_save_libs
1142 fi
1143
1144 AC_SUBST(DNSLIBS)
1145
1146
1147 #
1148 # Check for LDAP
1149 #
1150 # Note that running the check changes the variable
1151 # gnupg_have_ldap from "n/a" to "no" or "yes".
1152
1153 AC_ARG_ENABLE(ldap,
1154     AC_HELP_STRING([--disable-ldap],[disable LDAP support]),
1155     [if test "$enableval" = "no"; then gnupg_have_ldap=no; fi])
1156
1157 if test "$gnupg_have_ldap" != "no" ; then
1158   if test "$build_dirmngr" = "yes" ; then
1159      GNUPG_CHECK_LDAP($NETLIBS)
1160      AC_CHECK_LIB(lber, ber_free,
1161                   [ LBER_LIBS="$LBER_LIBS -llber"
1162                     AC_DEFINE(HAVE_LBER,1,
1163                              [defined if liblber is available])
1164                     have_lber=yes
1165                  ])
1166   fi
1167 fi
1168 AC_SUBST(LBER_LIBS)
1169 if test "$gnupg_have_ldap" = "no"; then
1170     AC_MSG_WARN([[
1171 ***
1172 *** Building without LDAP support.
1173 *** No CRL access or X.509 certificate search available.
1174 ***]])
1175 fi
1176
1177 AM_CONDITIONAL(USE_LDAP, [test "$gnupg_have_ldap" = yes])
1178 if test "$gnupg_have_ldap" = yes ; then
1179   AC_DEFINE(USE_LDAP,1,[Defined if LDAP is support])
1180 else
1181  use_ldapwrapper=no
1182 fi
1183
1184 if test "$use_ldapwrapper" = yes; then
1185    AC_DEFINE(USE_LDAPWRAPPER,1, [Build dirmngr with LDAP wrapper process])
1186 fi
1187 AM_CONDITIONAL(USE_LDAPWRAPPER, test "$use_ldapwrapper" = yes)
1188
1189
1190
1191
1192 #
1193 # Check for sendmail
1194 #
1195 # This isn't necessarily sendmail itself, but anything that gives a
1196 # sendmail-ish interface to the outside world.  That includes Exim,
1197 # Postfix, etc.  Basically, anything that can handle "sendmail -t".
1198 AC_ARG_WITH(mailprog,
1199       AC_HELP_STRING([--with-mailprog=NAME],
1200                      [use "NAME -t" for mail transport]),
1201              ,with_mailprog=yes)
1202 if test x"$with_mailprog" = xyes ; then
1203     AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib)
1204 elif test x"$with_mailprog" != xno ; then
1205     AC_MSG_CHECKING([for a mail transport program])
1206     AC_SUBST(SENDMAIL,$with_mailprog)
1207     AC_MSG_RESULT($with_mailprog)
1208 fi
1209
1210
1211 #
1212 # Construct a printable name of the OS
1213 #
1214 case "${host}" in
1215     *-mingw32ce*)
1216         PRINTABLE_OS_NAME="W32CE"
1217         ;;
1218     *-mingw32*)
1219         PRINTABLE_OS_NAME="MingW32"
1220         ;;
1221     *-*-cygwin*)
1222         PRINTABLE_OS_NAME="Cygwin"
1223         ;;
1224     i?86-emx-os2 | i?86-*-os2*emx )
1225         PRINTABLE_OS_NAME="OS/2"
1226         ;;
1227     i?86-*-msdosdjgpp*)
1228         PRINTABLE_OS_NAME="MSDOS/DJGPP"
1229         try_dynload=no
1230         ;;
1231     *-linux*)
1232         PRINTABLE_OS_NAME="GNU/Linux"
1233         ;;
1234     *)
1235         PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
1236         ;;
1237 esac
1238 AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
1239                    [A human readable text with the name of the OS])
1240
1241
1242 #
1243 # Checking for iconv
1244 #
1245 if test "$require_iconv" = yes; then
1246   AM_ICONV
1247 else
1248   LIBICONV=
1249   LTLIBICONV=
1250   AC_SUBST(LIBICONV)
1251   AC_SUBST(LTLIBICONV)
1252 fi
1253
1254
1255 #
1256 # Check for gettext
1257 #
1258 # This is "GNU gnupg" - The project-id script from gettext
1259 #                       needs this string
1260 #
1261 AC_MSG_NOTICE([checking for gettext])
1262 AM_PO_SUBDIRS
1263 AM_GNU_GETTEXT_VERSION([0.17])
1264 if test "$try_gettext" = yes; then
1265   AM_GNU_GETTEXT([external],[need-ngettext])
1266
1267   # gettext requires some extra checks.  These really should be part of
1268   # the basic AM_GNU_GETTEXT macro.  TODO: move other gettext-specific
1269   # function checks to here.
1270
1271   AC_CHECK_FUNCS(strchr)
1272 else
1273   USE_NLS=no
1274   USE_INCLUDED_LIBINTL=no
1275   BUILD_INCLUDED_LIBINTL=no
1276   POSUB=po
1277   AC_SUBST(USE_NLS)
1278   AC_SUBST(USE_INCLUDED_LIBINTL)
1279   AC_SUBST(BUILD_INCLUDED_LIBINTL)
1280   AC_SUBST(POSUB)
1281 fi
1282
1283 # We use HAVE_LANGINFO_CODESET in a couple of places.
1284 AM_LANGINFO_CODESET
1285
1286 # Checks required for our use of locales
1287 gt_LC_MESSAGES
1288
1289
1290 #
1291 # SELinux support
1292 #
1293 if test "$selinux_support" = yes ; then
1294   AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support])
1295 fi
1296
1297
1298 #
1299 # Checks for header files.
1300 #
1301 AC_MSG_NOTICE([checking for header files])
1302 AC_HEADER_STDC
1303 AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \
1304                   pty.h utmp.h pwd.h inttypes.h signal.h sys/select.h     \
1305                   stdint.h signal.h util.h libutil.h termios.h \
1306                   ucred.h sys/ucred.h sys/sysmacros.h sys/mkdev.h])
1307
1308 AC_HEADER_TIME
1309
1310
1311 #
1312 # Checks for typedefs, structures, and compiler characteristics.
1313 #
1314 AC_MSG_NOTICE([checking for system characteristics])
1315 AC_C_CONST
1316 AC_C_INLINE
1317 AC_C_VOLATILE
1318 AC_TYPE_SIZE_T
1319 AC_TYPE_MODE_T
1320 AC_TYPE_SIGNAL
1321 AC_DECL_SYS_SIGLIST
1322
1323 gl_HEADER_SYS_SOCKET
1324 gl_TYPE_SOCKLEN_T
1325
1326 AC_SEARCH_LIBS([inet_addr], [nsl])
1327
1328 AC_ARG_ENABLE(endian-check,
1329               AC_HELP_STRING([--disable-endian-check],
1330               [disable the endian check and trust the OS provided macros]),
1331               endiancheck=$enableval,endiancheck=yes)
1332
1333 if test x"$endiancheck" = xyes ; then
1334   GNUPG_CHECK_ENDIAN
1335 fi
1336
1337 # fixme: we should get rid of the byte type
1338 GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
1339 GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
1340 GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
1341 GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
1342 GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)
1343
1344 AC_CHECK_SIZEOF(unsigned short)
1345 AC_CHECK_SIZEOF(unsigned int)
1346 AC_CHECK_SIZEOF(unsigned long)
1347 AC_CHECK_SIZEOF(unsigned long long)
1348 AC_HEADER_TIME
1349 AC_CHECK_SIZEOF(time_t,,[[
1350 #include <stdio.h>
1351 #if TIME_WITH_SYS_TIME
1352 # include <sys/time.h>
1353 # include <time.h>
1354 #else
1355 # if HAVE_SYS_TIME_H
1356 #  include <sys/time.h>
1357 # else
1358 #  include <time.h>
1359 # endif
1360 #endif
1361 ]])
1362 GNUPG_TIME_T_UNSIGNED
1363
1364
1365 if test "$ac_cv_sizeof_unsigned_short" = "0" \
1366    || test "$ac_cv_sizeof_unsigned_int" = "0" \
1367    || test "$ac_cv_sizeof_unsigned_long" = "0"; then
1368     AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
1369 fi
1370
1371
1372 #
1373 # Checks for library functions.
1374 #
1375 AC_MSG_NOTICE([checking for library functions])
1376 AC_CHECK_DECLS(getpagesize)
1377 AC_FUNC_FSEEKO
1378 AC_FUNC_VPRINTF
1379 AC_FUNC_FORK
1380 AC_CHECK_FUNCS([strerror strlwr tcgetattr mmap canonicalize_file_name])
1381 AC_CHECK_FUNCS([strcasecmp strncasecmp ctermid times gmtime_r strtoull])
1382 AC_CHECK_FUNCS([setenv unsetenv fcntl ftruncate inet_ntop])
1383 AC_CHECK_FUNCS([canonicalize_file_name])
1384 AC_CHECK_FUNCS([gettimeofday getrusage getrlimit setrlimit clock_gettime])
1385 AC_CHECK_FUNCS([atexit raise getpagesize strftime nl_langinfo setlocale])
1386 AC_CHECK_FUNCS([waitpid wait4 sigaction sigprocmask pipe getaddrinfo])
1387 AC_CHECK_FUNCS([ttyname rand ftello fsync stat lstat])
1388 AC_CHECK_FUNCS([memicmp stpcpy strsep strlwr strtoul memmove stricmp strtol \
1389                 memrchr isascii timegm getrusage setrlimit stat setlocale   \
1390                 flockfile funlockfile getpwnam getpwuid \
1391                 getenv inet_pton strpbrk])
1392
1393 # On some systems (e.g. Solaris) nanosleep requires linking to librl.
1394 # Given that we use nanosleep only as an optimization over a select
1395 # based wait function we want it only if it is available in libc.
1396 _save_libs="$LIBS"
1397 AC_SEARCH_LIBS([nanosleep], [],
1398                [AC_DEFINE(HAVE_NANOSLEEP,1,
1399                 [Define to 1 if you have the `nanosleep' function in libc.])])
1400 LIBS="$_save_libs"
1401
1402
1403 # See whether libc supports the Linux inotify interface
1404 case "${host}" in
1405     *-*-linux*)
1406         AC_CHECK_FUNCS([inotify_init])
1407         ;;
1408 esac
1409
1410
1411 if test "$have_android_system" = yes; then
1412    # On Android ttyname is a stub but prints an error message.
1413    AC_DEFINE(HAVE_BROKEN_TTYNAME,1,
1414              [Defined if ttyname does not work properly])
1415 fi
1416
1417 AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
1418
1419 # Dirmngr requires mmap on Unix systems.
1420 if test $ac_cv_func_mmap != yes -a $mmap_needed = yes; then
1421   AC_MSG_ERROR([[Sorry, the current implementation requires mmap.]])
1422 fi
1423
1424
1425 #
1426 # Check for the getsockopt SO_PEERCRED, etc.
1427 #
1428 AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.cr_pid, struct sockpeercred.pid], [], [], [#include <sys/types.h>
1429 #include <sys/socket.h> ])
1430
1431 # (Open)Solaris
1432 AC_CHECK_FUNCS([getpeerucred])
1433
1434
1435 #
1436 # W32 specific test
1437 #
1438 GNUPG_FUNC_MKDIR_TAKES_ONE_ARG
1439
1440 #
1441 # Sanity check regex.  Tests adapted from mutt.
1442 #
1443 AC_MSG_CHECKING([whether regular expression support is requested])
1444 AC_ARG_ENABLE(regex,
1445   AC_HELP_STRING([--disable-regex],
1446     [do not handle regular expressions in trust signatures]),
1447   use_regex=$enableval, use_regex=yes)
1448 AC_MSG_RESULT($use_regex)
1449
1450 if test "$use_regex" = yes ; then
1451   _cppflags="${CPPFLAGS}"
1452   _ldflags="${LDFLAGS}"
1453   AC_ARG_WITH(regex,
1454      AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]),
1455       [
1456       if test -d "$withval" ; then
1457         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1458         LDFLAGS="${LDFLAGS} -L$withval/lib"
1459       fi
1460       ],withval="")
1461
1462   # Does the system have regex functions at all?
1463   AC_SEARCH_LIBS([regcomp], [regex])
1464   AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no)
1465
1466   if test $gnupg_cv_have_regex = no; then
1467     use_regex=no
1468   else
1469     if test x"$cross_compiling" = xyes; then
1470       AC_MSG_WARN([cross compiling; assuming regexp libray is not broken])
1471     else
1472       AC_CACHE_CHECK([whether your system's regexp library is broken],
1473        [gnupg_cv_regex_broken],
1474        AC_TRY_RUN([
1475 #include <unistd.h>
1476 #include <regex.h>
1477 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); }],
1478        gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes))
1479
1480       if test $gnupg_cv_regex_broken = yes; then
1481         AC_MSG_WARN([your regex is broken - disabling regex use])
1482         use_regex=no
1483       fi
1484     fi
1485   fi
1486   CPPFLAGS="${_cppflags}"
1487   LDFLAGS="${_ldflags}"
1488 fi
1489
1490 if test "$use_regex" != yes ; then
1491   AC_DEFINE(DISABLE_REGEX,1, [Define to disable regular expression support])
1492 fi
1493 AM_CONDITIONAL(DISABLE_REGEX, test x"$use_regex" != xyes)
1494
1495
1496
1497 #
1498 # Do we have zlib? Must do it here because Solaris failed
1499 # when compiling a conftest (due to the "-lz" from LIBS).
1500 # Note that we combine zlib and bzlib2 in ZLIBS.
1501 #
1502 if test "$use_zip" = yes ; then
1503   _cppflags="${CPPFLAGS}"
1504   _ldflags="${LDFLAGS}"
1505   AC_ARG_WITH(zlib,
1506     [  --with-zlib=DIR         use libz in DIR],[
1507       if test -d "$withval"; then
1508         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1509         LDFLAGS="${LDFLAGS} -L$withval/lib"
1510       fi
1511     ])
1512
1513   AC_CHECK_HEADER(zlib.h,
1514      AC_CHECK_LIB(z, deflateInit2_,
1515        [
1516        ZLIBS="-lz"
1517        AC_DEFINE(HAVE_ZIP,1, [Defined if ZIP and ZLIB are supported])
1518        ],
1519        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1520        CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags})
1521 fi
1522
1523
1524 #
1525 # Check whether we can support bzip2
1526 #
1527 if test "$use_bzip2" = yes ; then
1528   _cppflags="${CPPFLAGS}"
1529   _ldflags="${LDFLAGS}"
1530   AC_ARG_WITH(bzip2,
1531      AC_HELP_STRING([--with-bzip2=DIR],[look for bzip2 in DIR]),
1532       [
1533       if test -d "$withval" ; then
1534         CPPFLAGS="${CPPFLAGS} -I$withval/include"
1535         LDFLAGS="${LDFLAGS} -L$withval/lib"
1536       fi
1537       ],withval="")
1538
1539   # Checking alongside stdio.h as an early version of bzip2 (1.0)
1540   # required stdio.h to be included before bzlib.h, and Solaris 9 is
1541   # woefully out of date.
1542   if test "$withval" != no ; then
1543      AC_CHECK_HEADER(bzlib.h,
1544         AC_CHECK_LIB(bz2,BZ2_bzCompressInit,
1545           [
1546           have_bz2=yes
1547           ZLIBS="$ZLIBS -lbz2"
1548           AC_DEFINE(HAVE_BZIP2,1,
1549                   [Defined if the bz2 compression library is available])
1550           ],
1551           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags}),
1552           CPPFLAGS=${_cppflags} LDFLAGS=${_ldflags},[#include <stdio.h>])
1553   fi
1554 fi
1555 AM_CONDITIONAL(ENABLE_BZIP2_SUPPORT,test x"$have_bz2" = "xyes")
1556 AC_SUBST(ZLIBS)
1557
1558
1559 # Check for readline support
1560 GNUPG_CHECK_READLINE
1561
1562
1563 if test "$development_version" = yes; then
1564     AC_DEFINE(IS_DEVELOPMENT_VERSION,1,
1565             [Defined if this is not a regular release])
1566 fi
1567
1568 if test "$USE_MAINTAINER_MODE" = "yes"; then
1569     AC_DEFINE(MAINTAINER_MODE,1,
1570             [Defined if this build is in maintainer mode])
1571 fi
1572
1573 AM_CONDITIONAL(CROSS_COMPILING, test x$cross_compiling = xyes)
1574
1575 GNUPG_CHECK_GNUMAKE
1576
1577 # Add some extra libs here so that previous tests don't fail for
1578 # mysterious reasons - the final link step should bail out.
1579 # W32SOCKLIBS is also defined so that if can be used for tools not
1580 # requiring any network stuff but linking to code in libcommon which
1581 # tracks in winsock stuff (e.g. init_common_subsystems).
1582 if test "$have_w32_system" = yes; then
1583    if test "$have_w32ce_system" = yes; then
1584      W32SOCKLIBS="-lws2"
1585    else
1586      W32SOCKLIBS="-lws2_32"
1587    fi
1588    NETLIBS="${NETLIBS} ${W32SOCKLIBS}"
1589 fi
1590
1591 AC_SUBST(NETLIBS)
1592 AC_SUBST(W32SOCKLIBS)
1593
1594 #
1595 # Setup gcc specific options
1596 #
1597 USE_C99_CFLAGS=
1598 AC_MSG_NOTICE([checking for cc features])
1599 if test "$GCC" = yes; then
1600     mycflags=
1601     mycflags_save=$CFLAGS
1602
1603     # Check whether gcc does not emit a diagnositc for unknown -Wno-*
1604     # options.  This is the case for gcc >= 4.6
1605     AC_MSG_CHECKING([if gcc ignores unknown -Wno-* options])
1606     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1607 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6 )
1608 #kickerror
1609 #endif]],[])],[_gcc_silent_wno=yes],[_gcc_silent_wno=no])
1610     AC_MSG_RESULT($_gcc_silent_wno)
1611
1612     # Note that it is okay to use CFLAGS here because these are just
1613     # warning options and the user should have a chance of overriding
1614     # them.
1615     if test "$USE_MAINTAINER_MODE" = "yes"; then
1616         mycflags="$mycflags -O3 -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
1617         mycflags="$mycflags -Wformat -Wno-format-y2k -Wformat-security"
1618         if test x"$_gcc_silent_wno" = xyes ; then
1619           _gcc_wopt=yes
1620         else
1621           AC_MSG_CHECKING([if gcc supports -Wno-missing-field-initializers])
1622           CFLAGS="-Wno-missing-field-initializers"
1623           AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1624                             [_gcc_wopt=yes],[_gcc_wopt=no])
1625           AC_MSG_RESULT($_gcc_wopt)
1626         fi
1627         if test x"$_gcc_wopt" = xyes ; then
1628           mycflags="$mycflags -W -Wno-sign-compare -Wno-format-zero-length"
1629           mycflags="$mycflags -Wno-missing-field-initializers"
1630         fi
1631
1632         AC_MSG_CHECKING([if gcc supports -Wdeclaration-after-statement])
1633         CFLAGS="-Wdeclaration-after-statement"
1634         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1635         AC_MSG_RESULT($_gcc_wopt)
1636         if test x"$_gcc_wopt" = xyes ; then
1637           mycflags="$mycflags -Wdeclaration-after-statement"
1638         fi
1639
1640         AC_MSG_CHECKING([if gcc supports -Wlogical-op])
1641         CFLAGS="-Wlogical-op -Werror"
1642         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1643         AC_MSG_RESULT($_gcc_wopt)
1644         if test x"$_gcc_wopt" = xyes ; then
1645           mycflags="$mycflags -Wlogical-op"
1646         fi
1647
1648         AC_MSG_CHECKING([if gcc supports -Wvla])
1649         CFLAGS="-Wvla"
1650         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_wopt=yes,_gcc_wopt=no)
1651         AC_MSG_RESULT($_gcc_wopt)
1652         if test x"$_gcc_wopt" = xyes ; then
1653           mycflags="$mycflags -Wvla"
1654         fi
1655
1656     else
1657         mycflags="$mycflags -Wall"
1658     fi
1659
1660     if test x"$_gcc_silent_wno" = xyes ; then
1661       _gcc_psign=yes
1662     else
1663       AC_MSG_CHECKING([if gcc supports -Wno-pointer-sign])
1664       CFLAGS="-Wno-pointer-sign"
1665       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],
1666                         [_gcc_psign=yes],[_gcc_psign=no])
1667       AC_MSG_RESULT($_gcc_psign)
1668     fi
1669     if test x"$_gcc_psign" = xyes ; then
1670        mycflags="$mycflags -Wno-pointer-sign"
1671     fi
1672
1673     AC_MSG_CHECKING([if gcc supports -Wpointer-arith])
1674     CFLAGS="-Wpointer-arith"
1675     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],_gcc_psign=yes,_gcc_psign=no)
1676     AC_MSG_RESULT($_gcc_psign)
1677     if test x"$_gcc_psign" = xyes ; then
1678        mycflags="$mycflags -Wpointer-arith"
1679     fi
1680
1681     CFLAGS="$mycflags $mycflags_save"
1682     if test "$use_libdns" = yes; then
1683        # dirmngr/dns.{c,h} require C99 and GNU extensions.  */
1684        USE_C99_CFLAGS="-std=gnu99"
1685     fi
1686 fi
1687
1688 AC_SUBST(USE_C99_CFLAGS)
1689
1690
1691 #
1692 # This is handy for debugging so the compiler doesn't rearrange
1693 # things and eliminate variables.
1694 #
1695 AC_ARG_ENABLE(optimization,
1696    AC_HELP_STRING([--disable-optimization],
1697                   [disable compiler optimization]),
1698                   [if test $enableval = no ; then
1699                       CFLAGS=`echo $CFLAGS | sed s/-O[[1-9]]\ /-O0\ /g`
1700                    fi])
1701
1702 #
1703 # log_debug has certain requirements which might hamper portability.
1704 # Thus we use an option to enable it.
1705 #
1706 AC_MSG_CHECKING([whether to enable log_clock])
1707 AC_ARG_ENABLE(log_clock,
1708               AC_HELP_STRING([--enable-log-clock],
1709                              [enable log_clock timestamps]),
1710               enable_log_clock=$enableval, enable_log_clock=no)
1711 AC_MSG_RESULT($enable_log_clock)
1712 if test "$enable_log_clock" = yes ; then
1713   AC_DEFINE(ENABLE_LOG_CLOCK,1,[Defined to use log_clock timestamps])
1714 fi
1715
1716 # Add -Werror to CFLAGS.  This hack can be used to avoid problems with
1717 # misbehaving autoconf tests in case the user supplied -Werror.
1718 #
1719 AC_ARG_ENABLE(werror,
1720    AC_HELP_STRING([--enable-werror],
1721                   [append -Werror to CFLAGS]),
1722                   [if test $enableval = yes ; then
1723                       CFLAGS="$CFLAGS -Werror"
1724                    fi])
1725
1726 #
1727 # Configure option --enable-all-tests
1728 #
1729 AC_MSG_CHECKING([whether "make check" shall run all tests])
1730 AC_ARG_ENABLE(all-tests,
1731               AC_HELP_STRING([--enable-all-tests],
1732                              [let "make check" run all tests]),
1733               run_all_tests=$enableval, run_all_tests=no)
1734 AC_MSG_RESULT($run_all_tests)
1735 if test "$run_all_tests" = "yes"; then
1736     AC_DEFINE(RUN_ALL_TESTS,1,
1737             [Defined if "make check" shall run all tests])
1738 fi
1739
1740 #
1741 # We do not want support for the GNUPG_BUILDDIR environment variable
1742 # in a released version.  However, our regression tests suite requires
1743 # this and thus we build with support for it during "make distcheck".
1744 # This configure option implements this along with the top Makefile's
1745 # AM_DISTCHECK_CONFIGURE_FLAGS.
1746 #
1747 gnupg_builddir_envvar=no
1748 AC_ARG_ENABLE(gnupg-builddir-envvar,,
1749               gnupg_builddir_envvar=$enableval)
1750 if test x"$gnupg_builddir_envvar" = x"yes"; then
1751    AC_DEFINE(ENABLE_GNUPG_BUILDDIR_ENVVAR, 1,
1752       [This is only used with "make distcheck"])
1753 fi
1754
1755
1756 #
1757 # To avoid problems with systemd cleaning up the /run/user directory,
1758 # this option will make GnuPG try to use /run/gnupg/user as socket dir
1759 # before /run/user
1760 #
1761 AC_ARG_ENABLE(run-gnupg-user-socket,
1762     AC_HELP_STRING([--enable-run-gnupg-user-socket],
1763                    [try /run/gnupg/user for sockets prior to /run/user]),
1764     use_run_gnupg_user_socket=$enableval)
1765 if test x"$use_run_gnupg_user_socket" = x"yes"; then
1766    AC_DEFINE(USE_RUN_GNUPG_USER_SOCKET, 1,
1767             [If defined try /run/gnupg/user before /run/user])
1768 fi
1769
1770
1771 #
1772 # Decide what to build
1773 #
1774
1775 build_scdaemon_extra=""
1776 if test "$build_scdaemon" = "yes"; then
1777   if test $have_libusb = no; then
1778      build_scdaemon_extra="without internal CCID driver"
1779   fi
1780   if test -n "$build_scdaemon_extra"; then
1781      build_scdaemon_extra="(${build_scdaemon_extra})"
1782   fi
1783 fi
1784
1785
1786 #
1787 # Set variables for use by automake makefiles.
1788 #
1789 AM_CONDITIONAL(BUILD_GPG,         test "$build_gpg" = "yes")
1790 AM_CONDITIONAL(BUILD_GPGSM,       test "$build_gpgsm" = "yes")
1791 AM_CONDITIONAL(BUILD_AGENT,       test "$build_agent" = "yes")
1792 AM_CONDITIONAL(BUILD_SCDAEMON,    test "$build_scdaemon" = "yes")
1793 AM_CONDITIONAL(BUILD_G13,         test "$build_g13" = "yes")
1794 AM_CONDITIONAL(BUILD_DIRMNGR,     test "$build_dirmngr" = "yes")
1795 AM_CONDITIONAL(BUILD_DOC,         test "$build_doc" = "yes")
1796 AM_CONDITIONAL(BUILD_SYMCRYPTRUN, test "$build_symcryptrun" = "yes")
1797 AM_CONDITIONAL(BUILD_GPGTAR,      test "$build_gpgtar" = "yes")
1798 AM_CONDITIONAL(BUILD_WKS_TOOLS,   test "$build_wks_tools" = "yes")
1799
1800 AM_CONDITIONAL(ENABLE_CARD_SUPPORT, test "$card_support" = yes)
1801 AM_CONDITIONAL(NO_TRUST_MODELS,     test "$use_trust_models" = no)
1802 AM_CONDITIONAL(USE_TOFU,            test "$use_tofu" = yes)
1803
1804 #
1805 # Set some defines for use gpgconf.
1806 #
1807 if test "$build_gpg" = yes ; then
1808     AC_DEFINE(BUILD_WITH_GPG,1,[Defined if GPG is to be build])
1809 fi
1810 if test "$build_gpgsm" = yes ; then
1811     AC_DEFINE(BUILD_WITH_GPGSM,1,[Defined if GPGSM is to be build])
1812 fi
1813 if test "$build_agent" = yes ; then
1814     AC_DEFINE(BUILD_WITH_AGENT,1,[Defined if GPG-AGENT is to be build])
1815 fi
1816 if test "$build_scdaemon" = yes ; then
1817     AC_DEFINE(BUILD_WITH_SCDAEMON,1,[Defined if SCDAEMON is to be build])
1818 fi
1819 if test "$build_dirmngr" = yes ; then
1820     AC_DEFINE(BUILD_WITH_DIRMNGR,1,[Defined if DIRMNGR is to be build])
1821 fi
1822 if test "$build_g13" = yes ; then
1823     AC_DEFINE(BUILD_WITH_G13,1,[Defined if G13 is to be build])
1824 fi
1825
1826
1827 #
1828 # Define Name strings
1829 #
1830 AC_DEFINE_UNQUOTED(GNUPG_NAME, "GnuPG", [The name of the project])
1831
1832 AC_DEFINE_UNQUOTED(GPG_NAME, "gpg", [The name of the OpenPGP tool])
1833 AC_DEFINE_UNQUOTED(GPG_DISP_NAME, "GnuPG", [The displayed name of gpg])
1834
1835 AC_DEFINE_UNQUOTED(GPGSM_NAME, "gpgsm", [The name of the S/MIME tool])
1836 AC_DEFINE_UNQUOTED(GPGSM_DISP_NAME, "GPGSM", [The displayed name of gpgsm])
1837
1838 AC_DEFINE_UNQUOTED(GPG_AGENT_NAME, "gpg-agent", [The name of the agent])
1839 AC_DEFINE_UNQUOTED(GPG_AGENT_DISP_NAME, "GPG Agent",
1840                                         [The displayed name of gpg-agent])
1841
1842 AC_DEFINE_UNQUOTED(SCDAEMON_NAME, "scdaemon", [The name of the scdaemon])
1843 AC_DEFINE_UNQUOTED(SCDAEMON_DISP_NAME, "SCDaemon",
1844                                        [The displayed name of scdaemon])
1845
1846 AC_DEFINE_UNQUOTED(DIRMNGR_NAME, "dirmngr", [The name of the dirmngr])
1847 AC_DEFINE_UNQUOTED(DIRMNGR_DISP_NAME, "DirMngr",
1848                                       [The displayed name of dirmngr])
1849
1850 AC_DEFINE_UNQUOTED(G13_NAME, "g13", [The name of the g13 tool])
1851 AC_DEFINE_UNQUOTED(G13_DISP_NAME, "G13", [The displayed name of g13])
1852
1853 AC_DEFINE_UNQUOTED(GPGCONF_NAME, "gpgconf", [The name of the gpgconf tool])
1854 AC_DEFINE_UNQUOTED(GPGCONF_DISP_NAME, "GPGConf",
1855                                       [The displayed name of gpgconf])
1856
1857 AC_DEFINE_UNQUOTED(GPGTAR_NAME, "gpgtar", [The name of the gpgtar tool])
1858
1859 AC_DEFINE_UNQUOTED(GPG_AGENT_SOCK_NAME, "S.gpg-agent",
1860                    [The name of the agent socket])
1861 AC_DEFINE_UNQUOTED(GPG_AGENT_EXTRA_SOCK_NAME, "S.gpg-agent.extra",
1862                    [The name of the agent socket for remote access])
1863 AC_DEFINE_UNQUOTED(GPG_AGENT_BROWSER_SOCK_NAME, "S.gpg-agent.browser",
1864                    [The name of the agent socket for browsers])
1865 AC_DEFINE_UNQUOTED(GPG_AGENT_SSH_SOCK_NAME, "S.gpg-agent.ssh",
1866                    [The name of the agent socket for ssh])
1867 AC_DEFINE_UNQUOTED(DIRMNGR_INFO_NAME, "DIRMNGR_INFO",
1868                    [The name of the dirmngr info envvar])
1869 AC_DEFINE_UNQUOTED(SCDAEMON_SOCK_NAME, "S.scdaemon",
1870                    [The name of the SCdaemon socket])
1871 AC_DEFINE_UNQUOTED(DIRMNGR_SOCK_NAME, "S.dirmngr",
1872                    [The name of the dirmngr socket])
1873 AC_DEFINE_UNQUOTED(DIRMNGR_DEFAULT_KEYSERVER,
1874                    "hkps://hkps.pool.sks-keyservers.net",
1875       [The default keyserver for dirmngr to use, if none is explicitly given])
1876
1877 AC_DEFINE_UNQUOTED(GPGEXT_GPG, "gpg", [The standard binary file suffix])
1878
1879 if test "$have_w32_system" = yes; then
1880   AC_DEFINE_UNQUOTED(GNUPG_REGISTRY_DIR, "Software\\\\GNU\\\\GnuPG",
1881                      [The directory part of the W32 registry keys])
1882 fi
1883
1884
1885 #
1886 # Provide information about the build.
1887 #
1888 BUILD_REVISION="mym4_revision"
1889 AC_SUBST(BUILD_REVISION)
1890 AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION",
1891                    [GIT commit id revision used to build this package])
1892
1893 changequote(,)dnl
1894 BUILD_VERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./'`
1895 changequote([,])dnl
1896 BUILD_VERSION="${BUILD_VERSION}mym4_revision_dec"
1897 BUILD_FILEVERSION=`echo "${BUILD_VERSION}" | tr . ,`
1898 AC_SUBST(BUILD_VERSION)
1899 AC_SUBST(BUILD_FILEVERSION)
1900
1901 AC_ARG_ENABLE([build-timestamp],
1902   AC_HELP_STRING([--enable-build-timestamp],
1903                  [set an explicit build timestamp for reproducibility.
1904                   (default is the current time in ISO-8601 format)]),
1905      [if test "$enableval" = "yes"; then
1906         BUILD_TIMESTAMP=`date -u +%Y-%m-%dT%H:%M+0000 2>/dev/null || date`
1907       else
1908         BUILD_TIMESTAMP="$enableval"
1909       fi
1910       BUILD_HOSTNAME="$ac_hostname"],
1911      [BUILD_TIMESTAMP="<none>"
1912       BUILD_HOSTNAME="<anon>"])
1913 AC_SUBST(BUILD_TIMESTAMP)
1914 AC_DEFINE_UNQUOTED(BUILD_TIMESTAMP, "$BUILD_TIMESTAMP",
1915                    [The time this package was configured for a build])
1916 AC_SUBST(BUILD_HOSTNAME)
1917
1918
1919 #
1920 # Print errors here so that they are visible all
1921 # together and the user can acquire them all together.
1922 #
1923 die=no
1924 if test "$have_gpg_error" = "no"; then
1925    die=yes
1926    AC_MSG_NOTICE([[
1927 ***
1928 *** You need libgpg-error to build this program.
1929 **  This library is for example available at
1930 ***   https://gnupg.org/ftp/gcrypt/libgpg-error
1931 *** (at least version $NEED_GPG_ERROR_VERSION is required.)
1932 ***]])
1933 fi
1934 if test "$have_libgcrypt" = "no"; then
1935    die=yes
1936    AC_MSG_NOTICE([[
1937 ***
1938 *** You need libgcrypt to build this program.
1939 **  This library is for example available at
1940 ***   https://gnupg.org/ftp/gcrypt/libgcrypt/
1941 *** (at least version $NEED_LIBGCRYPT_VERSION (API $NEED_LIBGCRYPT_API) is required.)
1942 ***]])
1943 fi
1944 if test "$have_libassuan" = "no"; then
1945    die=yes
1946    AC_MSG_NOTICE([[
1947 ***
1948 *** You need libassuan to build this program.
1949 *** This library is for example available at
1950 ***   https://gnupg.org/ftp/gcrypt/libassuan/
1951 *** (at least version $NEED_LIBASSUAN_VERSION (API $NEED_LIBASSUAN_API) is required).
1952 ***]])
1953 fi
1954 if test "$have_ksba" = "no"; then
1955     die=yes
1956     AC_MSG_NOTICE([[
1957 ***
1958 *** You need libksba to build this program.
1959 *** This library is for example available at
1960 ***   https://gnupg.org/ftp/gcrypt/libksba/
1961 *** (at least version $NEED_KSBA_VERSION using API $NEED_KSBA_API is required).
1962 ***]])
1963 fi
1964 if test "$gnupg_have_ldap" = yes; then
1965   if test "$have_w32ce_system" = yes; then
1966     AC_MSG_NOTICE([[
1967 *** Note that CeGCC might be broken, a package fixing this is:
1968 ***    http://files.kolab.org/local/windows-ce/
1969 ***                           source/wldap32_0.1-mingw32ce.orig.tar.gz
1970 ***                           binary/wldap32-ce-arm-dev_0.1-1_all.deb
1971 ***]])
1972    fi
1973 fi
1974 if test "$have_npth" = "no"; then
1975     die=yes
1976     AC_MSG_NOTICE([[
1977 ***
1978 *** It is now required to build with support for the
1979 *** New Portable Threads Library (nPth). Please install this
1980 *** library first.  The library is for example available at
1981 ***   https://gnupg.org/ftp/gcrypt/npth/
1982 *** (at least version $NEED_NPTH_VERSION (API $NEED_NPTH_API) is required).
1983 ***]])
1984 fi
1985
1986 if test "$require_iconv" = yes; then
1987   if test "$am_func_iconv" != yes; then
1988     die=yes
1989     AC_MSG_NOTICE([[
1990 ***
1991 *** The system does not provide a working iconv function.  Please
1992 *** install a suitable library; for example GNU Libiconv which is
1993 *** available at:
1994 ***   https://ftp.gnu.org/gnu/libiconv/
1995 ***]])
1996   fi
1997 fi
1998
1999 if test "$use_ccid_driver" = yes; then
2000   if test "$have_libusb" != yes; then
2001     die=yes
2002     AC_MSG_NOTICE([[
2003 ***
2004 *** You need libusb to build the internal ccid driver.  Please
2005 *** install a libusb suitable for your system.
2006 ***]])
2007   fi
2008 fi
2009
2010 if test "$die" = "yes"; then
2011     AC_MSG_ERROR([[
2012 ***
2013 *** Required libraries not found. Please consult the above messages
2014 *** and install them before running configure again.
2015 ***]])
2016 fi
2017
2018
2019
2020 AC_CONFIG_FILES([ m4/Makefile
2021 Makefile
2022 po/Makefile.in
2023 common/Makefile
2024 common/w32info-rc.h
2025 kbx/Makefile
2026 g10/Makefile
2027 sm/Makefile
2028 agent/Makefile
2029 scd/Makefile
2030 g13/Makefile
2031 dirmngr/Makefile
2032 tools/gpg-zip
2033 tools/Makefile
2034 doc/Makefile
2035 tests/Makefile
2036 tests/gpgscm/Makefile
2037 tests/openpgp/Makefile
2038 tests/migrations/Makefile
2039 tests/gpgsm/Makefile
2040 tests/gpgme/Makefile
2041 tests/pkits/Makefile
2042 g10/gpg.w32-manifest
2043 ])
2044
2045
2046 AC_OUTPUT
2047
2048
2049 echo "
2050         GnuPG v${VERSION} has been configured as follows:
2051
2052         Revision:  mym4_revision  (mym4_revision_dec)
2053         Platform:  $PRINTABLE_OS_NAME ($host)
2054
2055         OpenPGP:   $build_gpg
2056         S/MIME:    $build_gpgsm
2057         Agent:     $build_agent
2058         Smartcard: $build_scdaemon $build_scdaemon_extra
2059         G13:       $build_g13
2060         Dirmngr:   $build_dirmngr
2061         Gpgtar:    $build_gpgtar
2062         WKS tools: $build_wks_tools
2063
2064         Protect tool:      $show_gnupg_protect_tool_pgm
2065         LDAP wrapper:      $show_gnupg_dirmngr_ldap_pgm
2066         Default agent:     $show_gnupg_agent_pgm
2067         Default pinentry:  $show_gnupg_pinentry_pgm
2068         Default scdaemon:  $show_gnupg_scdaemon_pgm
2069         Default dirmngr:   $show_gnupg_dirmngr_pgm
2070
2071         Dirmngr auto start:  $dirmngr_auto_start
2072         Readline support:    $gnupg_cv_have_readline
2073         LDAP support:        $gnupg_have_ldap
2074         TLS support:         $use_tls_library
2075         TOFU support:        $use_tofu
2076         Tor support:         $show_tor_support
2077 "
2078 if test x"$use_regex" != xyes ; then
2079 echo "
2080         Warning: No regular expression support available.
2081                  OpenPGP trust signatures won't work.
2082                  gpg-check-pattern will not be built.
2083 "
2084 fi
2085 if test "x${gpg_config_script_warn}" != x; then
2086 cat <<G10EOF
2087         Warning: Mismatches between the target platform and the
2088                  to be used libraries have been detected for:
2089                   ${gpg_config_script_warn}
2090                  Please check above for more warning messages.
2091
2092 G10EOF
2093 fi