configure.ac 64.5 KB
Newer Older
1
# configure.ac - for GnuPG 2.1
Werner Koch's avatar
Werner Koch committed
2 3
# Copyright (C) 1998-2018 Free Software Foundation, Inc.
# Copyright (C) 1998-2018 Werner Koch
4
#
5
# This file is part of GnuPG.
6
#
7 8
# GnuPG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Werner Koch's avatar
Werner Koch committed
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12 13 14 15
# GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# 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.
Werner Koch's avatar
Werner Koch committed
21
AC_PREREQ(2.61)
22
min_automake_version="1.14"
23

24 25 26 27
# To build a release you need to create a tag with the version number
# (git tag -s gnupg-2.n.m) and run "./autogen.sh --force".  Please
# bump the version number immediately *after* the release and do
# another commit and push so that the git magic is able to work.
28 29
m4_define([mym4_package],[gnupg])
m4_define([mym4_major], [2])
Werner Koch's avatar
Werner Koch committed
30
m4_define([mym4_minor], [2])
Werner Koch's avatar
Werner Koch committed
31
m4_define([mym4_micro], [12])
32 33 34 35 36 37

# To start a new development series, i.e a new major or minor number
# you need to mark an arbitrary commit before the first beta release
# with an annotated tag.  For example the 2.1 branch starts off with
# the tag "gnupg-2.1-base".  This is used as the base for counting
# beta numbers before the first release of a series.
38 39 40

# Below is m4 magic to extract and compute the git revision number,
# 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 44 45 46 47 48
m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
                           mym4_package mym4_major mym4_minor mym4_micro),[:]))
m4_define([mym4_isbeta],       m4_argn(2, mym4_verslist))
m4_define([mym4_version],      m4_argn(4, mym4_verslist))
m4_define([mym4_revision],     m4_argn(7, mym4_verslist))
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 53 54 55
# When changing the SWDB tag please also adjust the hard coded tags in
# build-aux/speedo.mk and Makefile.am
AC_DEFINE_UNQUOTED(GNUPG_SWDB_TAG, "gnupg22", [swdb tag for this branch])

56
NEED_GPG_ERROR_VERSION=1.24
Werner Koch's avatar
Werner Koch committed
57 58

NEED_LIBGCRYPT_API=1
59
NEED_LIBGCRYPT_VERSION=1.7.0
Werner Koch's avatar
Werner Koch committed
60

61
NEED_LIBASSUAN_API=2
62
NEED_LIBASSUAN_VERSION=2.5.0
Werner Koch's avatar
Werner Koch committed
63

64
NEED_KSBA_API=1
65
NEED_KSBA_VERSION=1.3.4
Werner Koch's avatar
Werner Koch committed
66

67 68 69
NEED_NTBTLS_API=1
NEED_NTBTLS_VERSION=0.1.0

Marcus Brinkmann's avatar
Marcus Brinkmann committed
70
NEED_NPTH_API=1
71
NEED_NPTH_VERSION=1.2
Marcus Brinkmann's avatar
Marcus Brinkmann committed
72

73

Werner Koch's avatar
Werner Koch committed
74 75
NEED_GNUTLS_VERSION=3.0

76
NEED_SQLITE_VERSION=3.7
Werner Koch's avatar
Werner Koch committed
77

78
development_version=mym4_isbeta
79
PACKAGE=$PACKAGE_NAME
80
PACKAGE_GT=${PACKAGE_NAME}2
81 82
VERSION=$PACKAGE_VERSION

83
AC_CONFIG_AUX_DIR([build-aux])
84 85
AC_CONFIG_SRCDIR([sm/gpgsm.c])
AC_CONFIG_HEADER([config.h])
86
AM_INIT_AUTOMAKE([serial-tests dist-bzip2 no-dist-gzip])
87
AC_CANONICAL_HOST
Werner Koch's avatar
Werner Koch committed
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
Marcus Brinkmann's avatar
Marcus Brinkmann committed
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 108
use_bzip2=yes
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 118
show_tor_support=no

119
GNUPG_BUILD_PROGRAM(gpg, yes)
120
GNUPG_BUILD_PROGRAM(gpgsm, yes)
121 122
# The agent is a required part and can't be disabled anymore.
build_agent=yes
123
GNUPG_BUILD_PROGRAM(scdaemon, yes)
124
GNUPG_BUILD_PROGRAM(g13, no)
Werner Koch's avatar
Werner Koch committed
125
GNUPG_BUILD_PROGRAM(dirmngr, yes)
Werner Koch's avatar
Werner Koch committed
126
GNUPG_BUILD_PROGRAM(doc, yes)
127
GNUPG_BUILD_PROGRAM(symcryptrun, no)
128 129
# We use gpgtar to unpack test data, hence we always build it.  If the
# user opts out, we simply don't install it.
130
GNUPG_BUILD_PROGRAM(gpgtar, yes)
131 132 133 134
# We also install the gpg-wks-server tool by default but disable it
# later for platforms where it can't be build.
GNUPG_BUILD_PROGRAM(wks-tools, yes)

135

136
AC_SUBST(PACKAGE)
137
AC_SUBST(PACKAGE_GT)
138 139
AC_SUBST(VERSION)
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of this package])
140 141
AC_DEFINE_UNQUOTED(PACKAGE_GT, "$PACKAGE_GT",
                                [Name of this package for gettext])
142 143 144 145 146 147 148
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version of this package])
AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$PACKAGE_BUGREPORT",
                                        [Bug report address])
AC_DEFINE_UNQUOTED(NEED_LIBGCRYPT_VERSION, "$NEED_LIBGCRYPT_VERSION",
                                       [Required version of Libgcrypt])
AC_DEFINE_UNQUOTED(NEED_KSBA_VERSION, "$NEED_KSBA_VERSION",
                                       [Required version of Libksba])
149 150
AC_DEFINE_UNQUOTED(NEED_NTBTLS_VERSION, "$NEED_NTBTLS_VERSION",
                                       [Required version of NTBTLS])
151 152 153



Werner Koch's avatar
Werner Koch committed
154 155 156 157 158
# The default is to use the modules from this package and the few
# other packages in a standard place; i.e where this package gets
# installed.  With these options it is possible to override these
# ${prefix} depended values with fixed paths, which can't be replaced
# at make time.  See also am/cmacros.am and the defaults in AH_BOTTOM.
159
AC_ARG_WITH(agent-pgm,
Werner Koch's avatar
Werner Koch committed
160 161 162 163 164 165 166
    [  --with-agent-pgm=PATH  Use PATH as the default for the agent)],
          GNUPG_AGENT_PGM="$withval", GNUPG_AGENT_PGM="" )
AC_SUBST(GNUPG_AGENT_PGM)
AM_CONDITIONAL(GNUPG_AGENT_PGM, test -n "$GNUPG_AGENT_PGM")
show_gnupg_agent_pgm="(default)"
test -n "$GNUPG_AGENT_PGM" && show_gnupg_agent_pgm="$GNUPG_AGENT_PGM"

167 168
AC_ARG_WITH(pinentry-pgm,
    [  --with-pinentry-pgm=PATH  Use PATH as the default for the pinentry)],
Werner Koch's avatar
Werner Koch committed
169 170 171 172 173 174 175
          GNUPG_PINENTRY_PGM="$withval", GNUPG_PINENTRY_PGM="" )
AC_SUBST(GNUPG_PINENTRY_PGM)
AM_CONDITIONAL(GNUPG_PINENTRY_PGM, test -n "$GNUPG_PINENTRY_PGM")
show_gnupg_pinentry_pgm="(default)"
test -n "$GNUPG_PINENTRY_PGM" && show_gnupg_pinentry_pgm="$GNUPG_PINENTRY_PGM"


176 177
AC_ARG_WITH(scdaemon-pgm,
    [  --with-scdaemon-pgm=PATH  Use PATH as the default for the scdaemon)],
Werner Koch's avatar
Werner Koch committed
178 179 180 181 182 183 184
          GNUPG_SCDAEMON_PGM="$withval", GNUPG_SCDAEMON_PGM="" )
AC_SUBST(GNUPG_SCDAEMON_PGM)
AM_CONDITIONAL(GNUPG_SCDAEMON_PGM, test -n "$GNUPG_SCDAEMON_PGM")
show_gnupg_scdaemon_pgm="(default)"
test -n "$GNUPG_SCDAEMON_PGM" && show_gnupg_scdaemon_pgm="$GNUPG_SCDAEMON_PGM"


185 186
AC_ARG_WITH(dirmngr-pgm,
    [  --with-dirmngr-pgm=PATH  Use PATH as the default for the dirmngr)],
Werner Koch's avatar
Werner Koch committed
187 188 189 190 191
          GNUPG_DIRMNGR_PGM="$withval", GNUPG_DIRMNGR_PGM="" )
AC_SUBST(GNUPG_DIRMNGR_PGM)
AM_CONDITIONAL(GNUPG_DIRMNGR_PGM, test -n "$GNUPG_DIRMNGR_PGM")
show_gnupg_dirmngr_pgm="(default)"
test -n "$GNUPG_DIRMNGR_PGM" && show_gnupg_dirmngr_pgm="$GNUPG_DIRMNGR_PGM"
192

Werner Koch's avatar
Werner Koch committed
193 194 195 196 197 198 199 200
AC_ARG_WITH(protect-tool-pgm,
    [  --with-protect-tool-pgm=PATH  Use PATH as the default for the protect-tool)],
          GNUPG_PROTECT_TOOL_PGM="$withval", GNUPG_PROTECT_TOOL_PGM="" )
AC_SUBST(GNUPG_PROTECT_TOOL_PGM)
AM_CONDITIONAL(GNUPG_PROTECT_TOOL_PGM, test -n "$GNUPG_PROTECT_TOOL_PGM")
show_gnupg_protect_tool_pgm="(default)"
test -n "$GNUPG_PROTECT_TOOL_PGM" \
      && show_gnupg_protect_tool_pgm="$GNUPG_PROTECT_TOOL_PGM"
201

Werner Koch's avatar
Werner Koch committed
202
AC_ARG_WITH(dirmngr-ldap-pgm,
203
    [  --with-dirmngr-ldap-pgm=PATH  Use PATH as the default for the dirmngr ldap wrapper)],
Werner Koch's avatar
Werner Koch committed
204 205 206 207 208 209 210
          GNUPG_DIRMNGR_LDAP_PGM="$withval", GNUPG_DIRMNGR_LDAP_PGM="" )
AC_SUBST(GNUPG_DIRMNGR_LDAP_PGM)
AM_CONDITIONAL(GNUPG_DIRMNGR_LDAP_PGM, test -n "$GNUPG_DIRMNGR_LDAP_PGM")
show_gnupg_dirmngr_ldap_pgm="(default)"
test -n "$GNUPG_DIRMNGR_LDAP_PGM" \
      && show_gnupg_dirmngr_ldap_pgm="$GNUPG_DIRMNGR_LDAP_PGM"

211

212
#
213 214
# For a long time gpg 2.x was installed as gpg2.  This changed with
# 2.2.  This option can be used to install gpg under the name gpg2.
215
#
216 217 218 219
AC_ARG_ENABLE(gpg-is-gpg2,
    AC_HELP_STRING([--enable-gpg-is-gpg2],[Set installed name of gpg to gpg2]),
    gpg_is_gpg2=$enableval)
if test "$gpg_is_gpg2" = "yes"; then
220
   AC_DEFINE(USE_GPG2_HACK, 1, [Define to install gpg as gpg2])
221
fi
222
AM_CONDITIONAL(USE_GPG2_HACK, test "$gpg_is_gpg2" = "yes")
223

224

225 226 227 228 229 230 231 232 233
# SELinux support includes tracking of sensitive files to avoid
# leaking their contents through processing these files by gpg itself
AC_MSG_CHECKING([whether SELinux support is requested])
AC_ARG_ENABLE(selinux-support,
              AC_HELP_STRING([--enable-selinux-support],
                             [enable SELinux support]),
              selinux_support=$enableval, selinux_support=no)
AC_MSG_RESULT($selinux_support)

234

235 236 237 238 239 240 241 242 243 244 245 246 247 248
AC_MSG_CHECKING([whether to allocate extra secure memory])
AC_ARG_ENABLE(large-secmem,
              AC_HELP_STRING([--enable-large-secmem],
                             [allocate extra secure memory]),
              large_secmem=$enableval, large_secmem=no)
AC_MSG_RESULT($large_secmem)
if test "$large_secmem" = yes ; then
   SECMEM_BUFFER_SIZE=65536
else
   SECMEM_BUFFER_SIZE=32768
fi
AC_DEFINE_UNQUOTED(SECMEM_BUFFER_SIZE,$SECMEM_BUFFER_SIZE,
                   [Size of secure memory buffer])

249 250 251 252 253 254 255 256 257
AC_MSG_CHECKING([calibrated passphrase-stretching (s2k) duration])
AC_ARG_WITH(agent-s2k-calibration,
              AC_HELP_STRING([--with-agent-s2k-calibration=MSEC],
                             [calibrate passphrase stretching (s2k) to MSEC milliseconds]),
              agent_s2k_calibration=$withval, agent_s2k_calibration=100)
AC_MSG_RESULT($agent_s2k_calibration milliseconds)
AC_DEFINE_UNQUOTED(AGENT_S2K_CALIBRATION, $agent_s2k_calibration,
                   [Agent s2k calibration time (ms)])

258 259 260 261 262 263 264 265 266 267 268
AC_MSG_CHECKING([whether to enable trust models])
AC_ARG_ENABLE(trust-models,
              AC_HELP_STRING([--disable-trust-models],
                             [disable all trust models except "always"]),
              use_trust_models=$enableval)
AC_MSG_RESULT($use_trust_models)
if test "$use_trust_models" = no ; then
    AC_DEFINE(NO_TRUST_MODELS, 1,
             [Define to include only trust-model always])
fi

269 270 271 272
AC_MSG_CHECKING([whether to enable TOFU])
AC_ARG_ENABLE(tofu,
                AC_HELP_STRING([--disable-tofu],
                               [disable the TOFU trust model]),
273
              use_tofu=$enableval, use_tofu=$use_trust_models)
274
AC_MSG_RESULT($use_tofu)
275 276 277
if test "$use_trust_models" = no && test "$use_tofu" = yes; then
    AC_MSG_ERROR([both --disable-trust-models and --enable-tofu given])
fi
278

279 280 281 282 283 284 285 286 287 288
AC_MSG_CHECKING([whether to enable libdns])
AC_ARG_ENABLE(libdns,
                AC_HELP_STRING([--disable-libdns],
                               [do not build with libdns support]),
              use_libdns=$enableval, use_libdns=yes)
AC_MSG_RESULT($use_libdns)
if test x"$use_libdns" = xyes ; then
    AC_DEFINE(USE_LIBDNS, 1, [Build with integrated libdns support])
fi
AM_CONDITIONAL(USE_LIBDNS, test "$use_libdns" = yes)
289

290

291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
#
# Options to disable algorithm
#

GNUPG_GPG_DISABLE_ALGO([rsa],[RSA public key])
# Elgamal is a MUST algorithm
# DSA is a MUST algorithm
GNUPG_GPG_DISABLE_ALGO([ecdh],[ECDH public key])
GNUPG_GPG_DISABLE_ALGO([ecdsa],[ECDSA public key])
GNUPG_GPG_DISABLE_ALGO([eddsa],[EdDSA public key])

GNUPG_GPG_DISABLE_ALGO([idea],[IDEA cipher])
# 3DES is a MUST algorithm
GNUPG_GPG_DISABLE_ALGO([cast5],[CAST5 cipher])
GNUPG_GPG_DISABLE_ALGO([blowfish],[BLOWFISH cipher])
GNUPG_GPG_DISABLE_ALGO([aes128],[AES128 cipher])
GNUPG_GPG_DISABLE_ALGO([aes192],[AES192 cipher])
GNUPG_GPG_DISABLE_ALGO([aes256],[AES256 cipher])
GNUPG_GPG_DISABLE_ALGO([twofish],[TWOFISH cipher])
GNUPG_GPG_DISABLE_ALGO([camellia128],[CAMELLIA128 cipher])
GNUPG_GPG_DISABLE_ALGO([camellia192],[CAMELLIA192 cipher])
GNUPG_GPG_DISABLE_ALGO([camellia256],[CAMELLIA256 cipher])

GNUPG_GPG_DISABLE_ALGO([md5],[MD5 hash])
315
# SHA1 is a MUST algorithm
316 317
GNUPG_GPG_DISABLE_ALGO([rmd160],[RIPE-MD160 hash])
GNUPG_GPG_DISABLE_ALGO([sha224],[SHA-224 hash])
318
# SHA256 is a MUST algorithm for GnuPG.
319 320 321 322
GNUPG_GPG_DISABLE_ALGO([sha384],[SHA-384 hash])
GNUPG_GPG_DISABLE_ALGO([sha512],[SHA-512 hash])


323 324 325 326 327 328 329 330 331 332
# Allow disabling of zip support.
# This is in general not a good idea because according to rfc4880 OpenPGP
# implementations SHOULD support ZLIB.
AC_MSG_CHECKING([whether to enable the ZIP and ZLIB compression algorithm])
AC_ARG_ENABLE(zip,
   AC_HELP_STRING([--disable-zip],
                  [disable the ZIP and ZLIB compression algorithm]),
   use_zip=$enableval)
AC_MSG_RESULT($use_zip)

Werner Koch's avatar
Werner Koch committed
333 334 335 336 337 338 339 340
# Allow disabling of bzib2 support.
# It is defined only after we confirm the library is available later
AC_MSG_CHECKING([whether to enable the BZIP2 compression algorithm])
AC_ARG_ENABLE(bzip2,
   AC_HELP_STRING([--disable-bzip2],[disable the BZIP2 compression algorithm]),
   use_bzip2=$enableval)
AC_MSG_RESULT($use_bzip2)

341
# Configure option to allow or disallow execution of external
Werner Koch's avatar
Werner Koch committed
342
# programs, like a photo viewer.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
AC_MSG_CHECKING([whether to enable external program execution])
AC_ARG_ENABLE(exec,
    AC_HELP_STRING([--disable-exec],[disable all external program execution]),
    use_exec=$enableval)
AC_MSG_RESULT($use_exec)
if test "$use_exec" = no ; then
    AC_DEFINE(NO_EXEC,1,[Define to disable all external program execution])
fi

if test "$use_exec" = yes ; then
  AC_MSG_CHECKING([whether to enable photo ID viewing])
  AC_ARG_ENABLE(photo-viewers,
      [  --disable-photo-viewers disable photo ID viewers],
      [if test "$enableval" = no ; then
         AC_DEFINE(DISABLE_PHOTO_VIEWER,1,[define to disable photo viewing])
      fi],enableval=yes)
  gnupg_cv_enable_photo_viewers=$enableval
  AC_MSG_RESULT($enableval)

  if test "$gnupg_cv_enable_photo_viewers" = yes ; then
    AC_MSG_CHECKING([whether to use a fixed photo ID viewer])
    AC_ARG_WITH(photo-viewer,
        [  --with-photo-viewer=FIXED_VIEWER  set a fixed photo ID viewer],
        [if test "$withval" = yes ; then
           withval=no
        elif test "$withval" != no ; then
           AC_DEFINE_UNQUOTED(FIXED_PHOTO_VIEWER,"$withval",
  	                    [if set, restrict photo-viewer to this])
        fi],withval=no)
    AC_MSG_RESULT($withval)
  fi
374
fi
375

376

377 378 379 380
#
# Check for the key/uid cache size.  This can't be zero, but can be
# pretty small on embedded systems.  This is used for the gpg part.
#
381 382
AC_MSG_CHECKING([for the size of the key and uid cache])
AC_ARG_ENABLE(key-cache,
383 384
        AC_HELP_STRING([--enable-key-cache=SIZE],
                       [Set key cache to SIZE (default 4096)]),,enableval=4096)
385 386 387 388 389 390 391 392 393 394 395 396
if test "$enableval" = "no"; then
   enableval=5
elif test "$enableval" = "yes" || test "$enableval" = ""; then
   enableval=4096
fi
changequote(,)dnl
key_cache_size=`echo "$enableval" | sed 's/[A-Za-z]//g'`
changequote([,])dnl
if test "$enableval" != "$key_cache_size" || test "$key_cache_size" -lt 5; then
   AC_MSG_ERROR([invalid key-cache size])
fi
AC_MSG_RESULT($key_cache_size)
397 398
AC_DEFINE_UNQUOTED(PK_UID_CACHE_SIZE,$key_cache_size,
                  [Size of the key and UID caches])
399 400 401



402 403 404
#
# Check whether we want to use Linux capabilities
#
405 406 407 408 409 410
AC_MSG_CHECKING([whether use of capabilities is requested])
AC_ARG_WITH(capabilities,
    [  --with-capabilities     use linux capabilities [default=no]],
[use_capabilities="$withval"],[use_capabilities=no])
AC_MSG_RESULT($use_capabilities)

411 412 413 414 415 416 417 418 419 420 421 422 423
#
# Check whether to disable the card support
AC_MSG_CHECKING([whether smartcard support is requested])
AC_ARG_ENABLE(card-support,
              AC_HELP_STRING([--disable-card-support],
                             [disable smartcard support]),
              card_support=$enableval)
AC_MSG_RESULT($card_support)
if test "$card_support" = yes ; then
  AC_DEFINE(ENABLE_CARD_SUPPORT,1,[Define to include smartcard support])
else
  build_scdaemon=no
fi
424 425 426 427 428 429 430 431 432 433 434 435

#
# Allow disabling of internal CCID support.
# It is defined only after we confirm the library is available later
#
AC_MSG_CHECKING([whether to enable the internal CCID driver])
AC_ARG_ENABLE(ccid-driver,
              AC_HELP_STRING([--disable-ccid-driver],
                             [disable the internal CCID driver]),
              use_ccid_driver=$enableval)
AC_MSG_RESULT($use_ccid_driver)

436 437
AC_MSG_CHECKING([whether to auto start dirmngr])
AC_ARG_ENABLE(dirmngr-auto-start,
438 439
              AC_HELP_STRING([--disable-dirmngr-auto-start],
                             [disable auto starting of the dirmngr]),
440 441 442 443 444 445 446
              dirmngr_auto_start=$enableval)
AC_MSG_RESULT($dirmngr_auto_start)
if test "$dirmngr_auto_start" = yes ; then
    AC_DEFINE(USE_DIRMNGR_AUTO_START,1,
              [Define to enable auto starting of the dirmngr])
fi

447

448 449 450 451 452 453 454 455 456
#
# To avoid double inclusion of config.h which might happen at some
# places, we add the usual double inclusion protection at the top of
# config.h.
#
AH_TOP([
#ifndef GNUPG_CONFIG_H_INCLUDED
#define GNUPG_CONFIG_H_INCLUDED
])
457

458 459 460
#
# Stuff which goes at the bottom of config.h.
#
461
AH_BOTTOM([
462
/* This is the major version number of GnuPG so that
463
   source included files can test for this.  Note, that
464 465 466
   we use 2 here even for GnuPG 1.9.x. */
#define GNUPG_MAJOR_VERSION 2

Werner Koch's avatar
Werner Koch committed
467 468 469 470 471 472
/* Now to separate file name parts.
   Please note that the string version must not contain more
   than one character because the code assumes strlen()==1 */
#ifdef HAVE_DOSISH_SYSTEM
#define DIRSEP_C '\\'
#define DIRSEP_S "\\"
473
#define EXTSEP_C '.'
Werner Koch's avatar
Werner Koch committed
474
#define EXTSEP_S "."
475 476
#define PATHSEP_C ';'
#define PATHSEP_S ";"
477
#define EXEEXT_S ".exe"
Werner Koch's avatar
Werner Koch committed
478 479 480
#else
#define DIRSEP_C '/'
#define DIRSEP_S "/"
481
#define EXTSEP_C '.'
Werner Koch's avatar
Werner Koch committed
482
#define EXTSEP_S "."
483 484
#define PATHSEP_C ':'
#define PATHSEP_S ":"
485
#define EXEEXT_S ""
Werner Koch's avatar
Werner Koch committed
486 487 488
#endif

/* This is the same as VERSION, but should be overridden if the
489 490 491
   platform cannot handle things like dots '.' in filenames. Set
   SAFE_VERSION_DOT and SAFE_VERSION_DASH to whatever SAFE_VERSION
   uses for dots and dashes. */
Werner Koch's avatar
Werner Koch committed
492
#define SAFE_VERSION VERSION
493 494
#define SAFE_VERSION_DOT  '.'
#define SAFE_VERSION_DASH '-'
Werner Koch's avatar
Werner Koch committed
495

496 497
/* Some global constants.
 * Note that the homedir must not end in a slash.  */
498 499 500 501 502 503
#ifdef HAVE_DOSISH_SYSTEM
# ifdef HAVE_DRIVE_LETTERS
#  define GNUPG_DEFAULT_HOMEDIR "c:/gnupg"
# else
#  define GNUPG_DEFAULT_HOMEDIR "/gnupg"
# endif
504
#elif defined(__VMS)
505
#define GNUPG_DEFAULT_HOMEDIR "/SYS$LOGIN/gnupg"
506 507
#else
#define GNUPG_DEFAULT_HOMEDIR "~/.gnupg"
508
#endif
509 510
#define GNUPG_PRIVATE_KEYS_DIR  "private-keys-v1.d"
#define GNUPG_OPENPGP_REVOC_DIR "openpgp-revocs.d"
511

Werner Koch's avatar
Werner Koch committed
512 513 514
/* For some systems (DOS currently), we hardcode the path here.  For
   POSIX systems the values are constructed by the Makefiles, so that
   the values may be overridden by the make invocations; this is to
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
   comply with the GNU coding standards.  Note that these values are
   only defaults.  */
#ifdef HAVE_DOSISH_SYSTEM
# ifdef HAVE_DRIVE_LETTERS
#  define GNUPG_BINDIR      "c:\\gnupg"
#  define GNUPG_LIBEXECDIR  "c:\\gnupg"
#  define GNUPG_LIBDIR      "c:\\gnupg"
#  define GNUPG_DATADIR     "c:\\gnupg"
#  define GNUPG_SYSCONFDIR  "c:\\gnupg"
# else
#  define GNUPG_BINDIR      "\\gnupg"
#  define GNUPG_LIBEXECDIR  "\\gnupg"
#  define GNUPG_LIBDIR      "\\gnupg"
#  define GNUPG_DATADIR     "\\gnupg"
#  define GNUPG_SYSCONFDIR  "\\gnupg"
# endif
Werner Koch's avatar
Werner Koch committed
531 532 533 534 535 536
#endif

/* Derive some other constants. */
#if !(defined(HAVE_FORK) && defined(HAVE_PIPE) && defined(HAVE_WAITPID))
#define EXEC_TEMPFILE_ONLY
#endif
537

538 539 540 541 542 543 544 545 546 547

/* We didn't define endianness above, so get it from OS macros.  This
   is intended for making fat binary builds on OS X. */
#if !defined(BIG_ENDIAN_HOST) && !defined(LITTLE_ENDIAN_HOST)
#if defined(__BIG_ENDIAN__)
#define BIG_ENDIAN_HOST 1
#elif defined(__LITTLE_ENDIAN__)
#define LITTLE_ENDIAN_HOST 1
#else
#error "No endianness found"
548
#endif
549 550 551
#endif


Werner Koch's avatar
Werner Koch committed
552 553 554 555 556 557 558 559 560 561
/* Hack used for W32: ldap.m4 also tests for the ASCII version of
   ldap_start_tls_s because that is the actual symbol used in the
   library.  winldap.h redefines it to our commonly used value,
   thus we define our usual macro here.  */
#ifdef HAVE_LDAP_START_TLS_SA
# ifndef HAVE_LDAP_START_TLS_S
#  define HAVE_LDAP_START_TLS_S 1
# endif
#endif

562 563
/* Provide the es_ macro for estream.  */
#define GPGRT_ENABLE_ES_MACROS 1
Werner Koch's avatar
Werner Koch committed
564

565 566
/* Tell libgcrypt not to use its own libgpg-error implementation. */
#define USE_LIBGPG_ERROR 1
567

568 569 570
/* Tell Libgcrypt not to include deprecated definitions.  */
#define GCRYPT_NO_DEPRECATED 1

571 572 573
/* Our HTTP code is used in estream mode.  */
#define HTTP_USE_ESTREAM 1

574 575 576 577 578
/* Under W32 we do an explicit socket initialization, thus we need to
   avoid the on-demand initialization which would also install an atexit
   handler.  */
#define HTTP_NO_WSASTARTUP

579 580 581
/* Under Windows we use the gettext code from libgpg-error.  */
#define GPG_ERR_ENABLE_GETTEXT_MACROS

582 583 584
/* Under WindowsCE we use the strerror replacement from libgpg-error.  */
#define GPG_ERR_ENABLE_ERRNO_MACROS

585
#endif /*GNUPG_CONFIG_H_INCLUDED*/
586 587
])

588

589
AM_MAINTAINER_MODE
Werner Koch's avatar
Werner Koch committed
590
AC_ARG_VAR(SYSROOT,[locate config scripts also below that directory])
591 592

# Checks for programs.
593
AC_MSG_NOTICE([checking for programs])
594 595 596 597 598 599 600 601
AC_PROG_MAKE_SET
AM_SANITY_CHECK
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
602
AM_SILENT_RULES
603 604 605
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
Werner Koch's avatar
Werner Koch committed
606
AM_PROG_CC_C_O
Werner Koch's avatar
Werner Koch committed
607 608 609
if test "x$ac_cv_prog_cc_c89" = "xno" ; then
  AC_MSG_ERROR([[No C-89 compiler found]])
fi
610 611 612 613 614
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_RANLIB
AC_CHECK_TOOL(AR, ar, :)
AC_PATH_PROG(PERL,"perl")
615
AC_CHECK_TOOL(WINDRES, windres, :)
616
AC_PATH_PROG(YAT2M, "yat2m")
617
AC_ARG_VAR(YAT2M, [tool to convert texi to man pages])
618
AM_CONDITIONAL(HAVE_YAT2M, test -n "$ac_cv_path_YAT2M")
619 620
AC_ISC_POSIX
AC_SYS_LARGEFILE
621
GNUPG_CHECK_USTAR
622

623

624 625
# We need to compile and run a program on the build machine.  A
# comment in libgpg-error says that the AC_PROG_CC_FOR_BUILD macro in
626
# the AC archive is broken for autoconf 2.57.  Given that there is no
627 628 629 630 631 632 633 634 635 636 637 638
# newer version of that macro, we assume that it is also broken for
# autoconf 2.61 and thus we use a simple but usually sufficient
# approach.
AC_MSG_CHECKING(for cc for build)
if test "$cross_compiling" = "yes"; then
  CC_FOR_BUILD="${CC_FOR_BUILD-cc}"
else
  CC_FOR_BUILD="${CC_FOR_BUILD-$CC}"
fi
AC_MSG_RESULT($CC_FOR_BUILD)
AC_ARG_VAR(CC_FOR_BUILD,[build system C compiler])

639 640 641
# We need to call this macro because other pkg-config macros are
# not always used.
PKG_PROG_PKG_CONFIG
642

643 644

try_gettext=yes
645
require_iconv=yes
646
have_dosish_system=no
647
have_w32_system=no
648
have_w32ce_system=no
649
have_android_system=no
650
use_simple_gettext=no
Werner Koch's avatar
Werner Koch committed
651
use_ldapwrapper=yes
Werner Koch's avatar
Werner Koch committed
652
mmap_needed=yes
653
require_pipe_to_unblock_pselect=yes
Werner Koch's avatar
Werner Koch committed
654
case "${host}" in
655
    *-mingw32*)
656 657 658
        # special stuff for Windoze NT
        ac_cv_have_dev_random=no
        AC_DEFINE(USE_ONLY_8DOT3,1,
659
                  [Set this to limit filenames to the 8.3 format])
660
        AC_DEFINE(USE_SIMPLE_GETTEXT,1,
661
                  [Because the Unix gettext has too much overhead on
662 663 664
                   MingW32 systems and these systems lack Posix functions,
                   we use a simplified version of gettext])
        have_dosish_system=yes
665
        have_w32_system=yes
666
        require_iconv=no
667
        require_pipe_to_unblock_pselect=no
668
        case "${host}" in
669 670 671 672 673 674 675 676
          *-mingw32ce*)
            have_w32ce_system=yes
            ;;
          *)
            AC_DEFINE(HAVE_DRIVE_LETTERS,1,
                      [Defined if the OS supports drive letters.])
            ;;
        esac
677
        try_gettext="no"
678
	use_simple_gettext=yes
Werner Koch's avatar
Werner Koch committed
679
	mmap_needed=no
680
        build_wks_tools=no
681 682 683 684 685 686 687
        ;;
    i?86-emx-os2 | i?86-*-os2*emx )
        # OS/2 with the EMX environment
        ac_cv_have_dev_random=no
        AC_DEFINE(HAVE_DRIVE_LETTERS)
        have_dosish_system=yes
        try_gettext="no"
688
        build_wks_tools=no
689 690 691 692 693 694 695 696
        ;;

    i?86-*-msdosdjgpp*)
        # DOS with the DJGPP environment
        ac_cv_have_dev_random=no
        AC_DEFINE(HAVE_DRIVE_LETTERS)
        have_dosish_system=yes
        try_gettext="no"
697
        build_wks_tools=no
698 699 700 701
        ;;

    *-*-hpux*)
        if test -z "$GCC" ; then
702
            CFLAGS="-Ae -D_HPUX_SOURCE $CFLAGS"
703 704 705 706 707 708
        fi
        ;;
    *-dec-osf4*)
        if test -z "$GCC" ; then
            # Suppress all warnings
            # to get rid of the unsigned/signed char mismatch warnings.
709
            CFLAGS="-w $CFLAGS"
710 711 712 713
        fi
        ;;
    *-dec-osf5*)
        if test -z "$GCC" ; then
714
            # Use the newer compiler `-msg_disable ptrmismatch1' to
715 716 717
            # get rid of the unsigned/signed char mismatch warnings.
            # Using this may hide other pointer mismatch warnings, but
	    # it at least lets other warning classes through
718
            CFLAGS="-msg_disable ptrmismatch1 $CFLAGS"
719 720 721 722
        fi
        ;;
    m68k-atari-mint)
        ;;
723
    *-linux-android*)
724
        have_android_system=yes
725 726 727
        # Android is fully utf-8 and we do not want to use iconv to
        # keeps things simple
        require_iconv=no
728
        build_wks_tools=no
729
        ;;
730 731 732 733
    *-apple-darwin*)
        AC_DEFINE(_DARWIN_C_SOURCE, 900000L,
                  Expose all libc features (__DARWIN_C_FULL).)
        ;;
734 735 736
    *-*-netbsd*)
        require_pipe_to_unblock_pselect=yes
        ;;
737
    *)
738
        ;;
739 740
esac

741 742 743 744 745 746 747
if test "$require_pipe_to_unblock_pselect" = yes; then
   AC_DEFINE(HAVE_PSELECT_NO_EINTR, 1,
             [Defined if we run on systems like NetBSD, where
              pselect cannot be unblocked by signal from a thread
              within the same process.  We use pipe in this case, instead.])
fi

748 749
if test "$have_dosish_system" = yes; then
   AC_DEFINE(HAVE_DOSISH_SYSTEM,1,
750
             [Defined if we run on some of the PCDOS like systems
751
              (DOS, Windoze. OS/2) with special properties like
752 753
              no file modes, case insensitive file names and preferred
              use of backslashes as directory name separators.])
754 755 756
fi
AM_CONDITIONAL(HAVE_DOSISH_SYSTEM, test "$have_dosish_system" = yes)

757 758
AM_CONDITIONAL(USE_SIMPLE_GETTEXT, test x"$use_simple_gettext" = xyes)

759 760
if test "$have_w32_system" = yes; then
   AC_DEFINE(HAVE_W32_SYSTEM,1, [Defined if we run on a W32 API based system])
761 762 763
   if test "$have_w32ce_system" = yes; then
      AC_DEFINE(HAVE_W32CE_SYSTEM,1,[Defined if we run on WindowsCE])
   fi
764 765
fi
AM_CONDITIONAL(HAVE_W32_SYSTEM, test "$have_w32_system" = yes)
766
AM_CONDITIONAL(HAVE_W32CE_SYSTEM, test "$have_w32ce_system" = yes)
767

768 769 770 771 772
if test "$have_android_system" = yes; then
   AC_DEFINE(HAVE_ANDROID_SYSTEM,1, [Defined if we build for an Android system])
fi
AM_CONDITIONAL(HAVE_ANDROID_SYSTEM, test "$have_android_system" = yes)

773 774

# (These need to go after AC_PROG_CC so that $EXEEXT is defined)
Werner Koch's avatar
Werner Koch committed
775
AC_DEFINE_UNQUOTED(EXEEXT,"$EXEEXT",[The executable file extension, if any])
776

777

778
#
779
# Checks for libraries.
780
#
781
AC_MSG_NOTICE([checking for libraries])
782

783

784 785 786 787
#
# libgpg-error is a library with error codes shared between GnuPG
# related projects.
#
788
AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION",
789 790 791
                  have_gpg_error=yes,have_gpg_error=no)


792 793 794
#
# Libgcrypt is our generic crypto library
#
Werner Koch's avatar
Werner Koch committed
795
AM_PATH_LIBGCRYPT("$NEED_LIBGCRYPT_API:$NEED_LIBGCRYPT_VERSION",
796
        have_libgcrypt=yes,have_libgcrypt=no)
797

798

799 800 801
#
# libassuan is used for IPC
#
Werner Koch's avatar
Werner Koch committed
802
AM_PATH_LIBASSUAN("$NEED_LIBASSUAN_API:$NEED_LIBASSUAN_VERSION",
803
                  have_libassuan=yes,have_libassuan=no)
Werner Koch's avatar
Werner Koch committed
804
if test "$have_libassuan" = "yes"; then
805
  AC_DEFINE_UNQUOTED(GNUPG_LIBASSUAN_VERSION, "$libassuan_version",
Werner Koch's avatar
Werner Koch committed
806
                     [version of the libassuan library])
807
  show_tor_support="only .onion"
Werner Koch's avatar
Werner Koch committed
808
fi
809 810


811 812 813
#
# libksba is our X.509 support library
#
814
AM_PATH_KSBA("$NEED_KSBA_API:$NEED_KSBA_VERSION",have_ksba=yes,have_ksba=no)
815

816

817 818
#
# libusb allows us to use the integrated CCID smartcard reader driver.
819
#
820
# FiXME: Use GNUPG_CHECK_LIBUSB and modify to use separate AC_SUBSTs.
821
if test "$use_ccid_driver" = auto || test "$use_ccid_driver" = yes; then
822 823
   case "${host}" in
     *-mingw32*)
824
       LIBUSB_NAME=
825 826 827
       LIBUSB_LIBS=
       LIBUSB_CPPFLAGS=
       ;;
828
     *-*-darwin*)
829 830
       LIBUSB_NAME=usb-1.0
       LIBUSB_LIBS="-Wl,-framework,CoreFoundation -Wl,-framework,IOKit"
831 832 833
       ;;
     *-*-freebsd*)
       # FreeBSD has a native 1.0 compatible library by -lusb.
834 835
       LIBUSB_NAME=usb
       LIBUSB_LIBS=
836 837
       ;;
     *)
838 839
       LIBUSB_NAME=usb-1.0
       LIBUSB_LIBS=
840 841
       ;;
   esac
842
fi
843 844 845
if test x"$LIBUSB_NAME" != x ; then
   AC_CHECK_LIB($LIBUSB_NAME, libusb_init,
                [ LIBUSB_LIBS="-l$LIBUSB_NAME $LIBUSB_LIBS"
846
                  have_libusb=yes ])
847 848
   AC_MSG_CHECKING([libusb include dir])
   usb_incdir_found="no"
849 850
   for _incdir in "" "/usr/include/libusb-1.0" \
       "/usr/local/include/libusb-1.0" "/usr/pkg/include/libusb-1.0"; do
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865
     _libusb_save_cppflags=$CPPFLAGS
     if test -n "${_incdir}"; then
       CPPFLAGS="-I${_incdir} ${CPPFLAGS}"
     fi
     AC_PREPROC_IFELSE([AC_LANG_SOURCE([[@%:@include <libusb.h>]])],
     [usb_incdir=${_incdir}; usb_incdir_found="yes"], [])
     CPPFLAGS=${_libusb_save_cppflags}
     if test "$usb_incdir_found" = "yes"; then
       break
     fi
   done
   if test "$usb_incdir_found" = "yes"; then
     AC_MSG_RESULT([${usb_incdir}])
   else
     AC_MSG_RESULT([not found])
866 867
     usb_incdir=""
     have_libusb=no
868 869 870
     if test "$use_ccid_driver" != yes; then
       use_ccid_driver=no
     fi
871
     LIBUSB_LIBS=""
872
   fi
873 874 875 876 877

   if test "$have_libusb" = yes; then
     AC_DEFINE(HAVE_LIBUSB,1, [defined if libusb is available])
   fi
   if test x"$usb_incdir" = x; then
878 879 880 881
     LIBUSB_CPPFLAGS=""
   else
     LIBUSB_CPPFLAGS="-I${usb_incdir}"
   fi
882
fi
883
AC_SUBST(LIBUSB_LIBS)
884
AC_SUBST(LIBUSB_CPPFLAGS)
885

886
#
887
# Check whether it is necessary to link against libdl.
888
# (For example to load libpcsclite)
889
#
Werner Koch's avatar
Werner Koch committed
890
gnupg_dlopen_save_libs="$LIBS"
891 892 893 894
LIBS=""
AC_SEARCH_LIBS(dlopen, c dl,,,)
DL_LIBS=$LIBS
AC_SUBST(DL_LIBS)
Werner Koch's avatar
Werner Koch committed
895
LIBS="$gnupg_dlopen_save_libs"
896

897

898 899
# Checks for g10

900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
AC_ARG_ENABLE(sqlite,
                AC_HELP_STRING([--disable-sqlite],
                               [disable the use of SQLITE]),
              try_sqlite=$enableval, try_sqlite=yes)

if test x"$use_tofu" = xyes ; then
  if test x"$try_sqlite" = xyes ; then
    PKG_CHECK_MODULES([SQLITE3], [sqlite3 >= $NEED_SQLITE_VERSION],
                                 [have_sqlite=yes],
                                 [have_sqlite=no])
  fi
  if test "$have_sqlite" = "yes"; then
    :
    AC_SUBST([SQLITE3_CFLAGS])
    AC_SUBST([SQLITE3_LIBS])
  else
    use_tofu=no
    tmp=$(echo "$SQLITE3_PKG_ERRORS" | tr '\n' '\v' | sed 's/\v/\n*** /g')
    AC_MSG_WARN([[
***
*** Building without SQLite support - TOFU disabled
***
*** $tmp]])
  fi
fi

926 927
AM_CONDITIONAL(SQLITE3, test "$have_sqlite" = "yes")

928 929 930 931
if test x"$use_tofu" = xyes ; then
    AC_DEFINE(USE_TOFU, 1, [Enable to build the TOFU code])
fi

932

933 934 935 936 937 938 939 940 941 942
# Checks for g13

AC_PATH_PROG(ENCFS, encfs, /usr/bin/encfs)
AC_DEFINE_UNQUOTED(ENCFS,
	"${ENCFS}", [defines the filename of the encfs program])

AC_PATH_PROG(FUSERMOUNT, fusermount, /usr/bin/fusermount)
AC_DEFINE_UNQUOTED(FUSERMOUNT,
	"${FUSERMOUNT}", [defines the filename of the fusermount program])

Werner Koch's avatar
Werner Koch committed
943 944 945 946

# Checks for dirmngr


947 948
#
# Checks for symcryptrun:
949
#
950 951

# libutil has openpty() and login_tty().
952 953 954 955 956 957 958
AC_CHECK_LIB(util, openpty,
              [ LIBUTIL_LIBS="$LIBUTIL_LIBS -lutil"
                AC_DEFINE(HAVE_LIBUTIL,1,
                         [defined if libutil is available])
             ])
AC_SUBST(LIBUTIL_LIBS)

959 960 961 962
# shred is used to clean temporary plain text files.
AC_PATH_PROG(SHRED, shred, /usr/bin/shred)
AC_DEFINE_UNQUOTED(SHRED,
	"${SHRED}", [defines the filename of the shred program])
963

964 965

#
966
# Check whether the nPth library is available
967
#
Marcus Brinkmann's avatar
Marcus Brinkmann committed
968 969
AM_PATH_NPTH("$NEED_NPTH_API:$NEED_NPTH_VERSION",have_npth=yes,have_npth=no)
if test "$have_npth" = "yes"; then
970
  AC_DEFINE(HAVE_NPTH, 1,
971
              [Defined if the New Portable Thread Library is available])
972 973
  AC_DEFINE(USE_NPTH, 1,
              [Defined if support for nPth is requested and nPth is available])
Werner Koch's avatar
Werner Koch committed
974 975
else
  AC_MSG_WARN([[
976
***
977
*** To support concurrent access for example in gpg-agent and the SCdaemon
Marcus Brinkmann's avatar
Marcus Brinkmann committed
978
*** we need the support of the New Portable Threads Library.
979
***]])
980
fi
981 982 983 984 985 986 987 988 989 990 991
#
# Enable debugging of nPth
#
AC_ARG_ENABLE(npth-debug,
   AC_HELP_STRING([--enable-npth-debug],
                  [build with debug version of npth]),
                  [if test $enableval = yes ; then
                     AC_DEFINE(NPTH_ENABLE_DEBUG,1,
                              [Build with debug version of nPth])
                  fi])

Werner Koch's avatar
Werner Koch committed
992

993

Werner Koch's avatar
Werner Koch committed
994
#
995 996
# NTBTLS is our TLS library.  If it is not available fallback to
# GNUTLS.
Werner Koch's avatar
Werner Koch committed
997
#
998 999 1000 1001 1002 1003 1004 1005
AC_ARG_ENABLE(ntbtls,
              AC_HELP_STRING([--disable-ntbtls],
                             [disable the use of NTBTLS as TLS library]),
              try_ntbtls=$enableval, try_ntbtls=yes)
if test x"$try_ntbtls" = xyes ; then
  AM_PATH_NTBTLS("$NEED_NTBTLS_API:$NEED_NTBTLS_VERSION",
                 [have_ntbtls=yes],[have_ntbtls=no])
fi
1006 1007 1008
if test "$have_ntbtls" = yes ; then
   use_tls_library=ntbtls
   AC_DEFINE(HTTP_USE_NTBTLS, 1, [Enable NTBTLS support in http.c])
Werner Koch's avatar
Werner Koch committed
1009
else
1010 1011 1012 1013 1014 1015 1016 1017 1018
  AC_ARG_ENABLE(gnutls,
                AC_HELP_STRING([--disable-gnutls],
                               [disable GNUTLS as fallback TLS library]),
                try_gnutls=$enableval, try_gnutls=yes)
  if test x"$try_gnutls" = xyes ; then
    PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= $NEED_GNUTLS_VERSION],
                                   [have_gnutls=yes],
                                   [have_gnutls=no])
  fi
1019 1020 1021 1022 1023 1024 1025 1026
  if test "$have_gnutls" = "yes"; then
    AC_SUBST([LIBGNUTLS_CFLAGS])
    AC_SUBST([LIBGNUTLS_LIBS])
    use_tls_library=gnutls
    AC_DEFINE(HTTP_USE_GNUTLS, 1, [Enable GNUTLS support in http.c])
  else
    tmp=$(echo "$LIBGNUTLS_PKG_ERRORS" | tr '\n' '\v' | sed 's/\v/\n*** /g')
    AC_MSG_WARN([[
Werner Koch's avatar
Werner Koch committed
1027
***
1028
*** Building without NTBTLS and GNUTLS - no TLS access to keyservers.
Werner Koch's avatar
Werner Koch committed
1029 1030
***
*** $tmp]])
1031
  fi
Werner Koch's avatar
Werner Koch committed
1032 1033
fi

1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049
#
# Allow to set a fixed trust store file for system provided certificates.
#
AC_ARG_WITH([default-trust-store-file],
            [AC_HELP_STRING([--with-default-trust-store-file=FILE],
                            [Use FILE as system trust store])],
            default_trust_store_file="$withval",
            default_trust_store_file="")
if test x"$default_trust_store_file" = xno;then
  default_trust_store_file=""
fi
if test x"$default_trust_store_file" != x ; then
  AC_DEFINE_UNQUOTED([DEFAULT_TRUST_STORE_FILE],
    ["$default_trust_store_file"], [Use as default system trust store file])
fi

Werner Koch's avatar
Werner Koch committed
1050

1051
AC_MSG_NOTICE([checking for networking options])
1052

1053 1054 1055 1056 1057 1058
#
# Must check for network library requirements before doing link tests
# for ldap, for example. If ldap libs are static (or dynamic and without
# ELF runtime link paths), then link will fail and LDAP support won't
# be detected.
#
1059 1060 1061 1062 1063
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname,
	[NETLIBS="-lnsl $NETLIBS"]))
AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt,
	[NETLIBS="-lsocket $NETLIBS"]))

1064

1065
#
1066
# Check standard resolver functions.
1067
#
1068
if test "$build_dirmngr" = "yes"; then
1069
  _dns_save_libs=$LIBS
1070
  LIBS=""
1071

1072 1073
  # Find the system resolver which can always be enabled with
  # the dirmngr option --standard-resolver.
1074

1075 1076 1077 1078 1079
  # the double underscore thing is a glibc-ism?
  AC_SEARCH_LIBS(res_query,resolv bind,,
                 AC_SEARCH_LIBS(__res_query,resolv bind,,have_resolver=no))
  AC_SEARCH_LIBS(dn_expand,resolv bind,,
                 AC_SEARCH_LIBS(__dn_expand,resolv bind,,have_resolver=no))
1080

1081 1082 1083 1084 1085 1086 1087 1088
  # macOS renames dn_skipname into res_9_dn_skipname in <resolv.h>,
  # and for some reason fools us into believing we don't need
  # -lresolv even if we do.  Since the test program checking for the
  # symbol does not include <resolv.h>, we need to check for the
  # renamed symbol explicitly.
  AC_SEARCH_LIBS(res_9_dn_skipname,resolv bind,,
      AC_SEARCH_LIBS(dn_skipname,resolv bind,,
          AC_SEARCH_LIBS(__dn_skipname,resolv bind,,have_resolver=no)))
1089

1090
  if test x"$have_resolver" != xno ; then
1091 1092 1093 1094

      # Make sure that the BIND 4 resolver interface is workable before
      # enabling any code that calls it.  At some point I'll rewrite the
      # code to use the BIND 8 resolver API.
1095
      # We might also want to use libdns instead.
1096

1097 1098
    AC_MSG_CHECKING([whether the resolver is usable])
    AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
1099 1100
#include <netinet/in.h>
#include <arpa/nameser.h>
1101
#include <resolv.h>]],
1102 1103
[[unsigned char answer[PACKETSZ];
  res_query("foo.bar",C_IN,T_A,answer,PACKETSZ);
1104
  dn_skipname(0,0);
1105 1106
  dn_expand(0,0,0,0,0);
]])],have_resolver=yes,have_resolver=no)
1107
    AC_MSG_RESULT($have_resolver)
1108

1109 1110
    # This is Apple-specific and somewhat bizarre as they changed the
    # define in bind 8 for some reason.
1111

1112 1113 1114 1115
    if test x"$have_resolver" != xyes ; then
      AC_MSG_CHECKING(
           [whether I can make the resolver usable with BIND_8_COMPAT])
      AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define BIND_8_COMPAT
1116 1117 1118
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
1119
#include <resolv.h>]],
1120 1121 1122 1123
[[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])
1124
      AC_MSG_RESULT($have_resolver)
1125
    fi
1126
  fi
1127

1128 1129 1130 1131 1132
  if test x"$have_resolver" = xyes ; then
    AC_DEFINE(HAVE_SYSTEM_RESOLVER,1,[The system's resolver is usable.])
    DNSLIBS="$DNSLIBS $LIBS"
    if test x"$need_compat" = xyes ; then
      AC_DEFINE(BIND_8_COMPAT,1,[an Apple OSXism])
1133
    fi
1134 1135 1136 1137 1138
    if test "$use_libdns" = yes; then
     show_tor_support=yes
    fi
  elif test "$use_libdns" = yes; then
    show_tor_support=yes
1139 1140 1141 1142 1143 1144
  else
    AC_MSG_WARN([[
***
*** The system's DNS resolver is not usable.
*** Dirmngr functionality is limited.
***]])
1145
    show_tor_support="${show_tor_support} (no system resolver)"
1146
  fi
1147

1148 1149 1150 1151 1152 1153
  if test "$have_w32_system" = yes; then
    if test "$use_libdns" = yes; then
      DNSLIBS="$DNSLIBS -liphlpapi"
    fi
  fi

1154
  LIBS=$_dns_save_libs
1155 1156
fi

1157
AC_SUBST(DNSLIBS)
1158

Werner Koch's avatar
Werner Koch committed
1159

1160 1161 1162
#
# Check for LDAP
#
1163 1164
# Note that running the check changes the variable
# gnupg_have_ldap from "n/a" to "no" or "yes".
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179

AC_ARG_ENABLE(ldap,
    AC_HELP_STRING([--disable-ldap],[disable LDAP support]),
    [if test "$enableval" = "no"; then gnupg_have_ldap=no; fi])

if test "$gnupg_have_ldap" != "no" ; then
  if test "$build_dirmngr" = "yes" ; then
     GNUPG_CHECK_LDAP($NETLIBS)
     AC_CHECK_LIB(lber, ber_free,
                  [ LBER_LIBS="$LBER_LIBS -llber"
                    AC_DEFINE(HAVE_LBER,1,
                             [defined if liblber is available])
                    have_lber=yes
                 ])
  fi
1180
fi
1181
AC_SUBST(LBER_LIBS)
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203
if test "$gnupg_have_ldap" = "no"; then
    AC_MSG_WARN([[
***
*** Building without LDAP support.
*** No CRL access or X.509 certificate search available.
***]])
fi

AM_CONDITIONAL(USE_LDAP, [test "$gnupg_have_ldap" = yes])
if test "$gnupg_have_ldap" = yes ; then
  AC_DEFINE(USE_LDAP,1,[Defined if LDAP is support])
else
 use_ldapwrapper=no
fi

if test "$use_ldapwrapper" = yes; then
   AC_DEFINE(USE_LDAPWRAPPER,1, [Build dirmngr with LDAP wrapper process])
fi
AM_CONDITIONAL(USE_LDAPWRAPPER, test "$use_ldapwrapper" = yes)



1204

1205 1206 1207 1208 1209 1210
#
# Check for sendmail
#
# This isn't necessarily sendmail itself, but anything that gives a
# sendmail-ish interface to the outside world.  That includes Exim,
# Postfix, etc.  Basically, anything that can handle "sendmail -t".
1211
AC_ARG_WITH(mailprog,
1212 1213 1214
      AC_HELP_STRING([--with-mailprog=NAME],
                     [use "NAME -t" for mail transport]),
             ,with_mailprog=yes)
1215
if test x"$with_mailprog" = xyes ; then
1216
    AC_PATH_PROG(SENDMAIL,sendmail,,$PATH:/usr/sbin:/usr/libexec:/usr/lib)
1217
elif test x"$with_mailprog" != xno ; then
1218 1219 1220 1221 1222 1223
    AC_MSG_CHECKING([for a mail transport program])
    AC_SUBST(SENDMAIL,$with_mailprog)
    AC_MSG_RESULT($with_mailprog)
fi


1224 1225 1226
#
# Construct a printable name of the OS
#
Werner Koch's avatar
Werner Koch committed
1227
case "${host}" in
1228 1229 1230
    *-mingw32ce*)
        PRINTABLE_OS_NAME="W32CE"
        ;;
1231
    *-mingw32*)
1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254
        PRINTABLE_OS_NAME="MingW32"
        ;;
    *-*-cygwin*)
        PRINTABLE_OS_NAME="Cygwin"
        ;;
    i?86-emx-os2 | i?86-*-os2*emx )
        PRINTABLE_OS_NAME="OS/2"
        ;;
    i?86-*-msdosdjgpp*)
        PRINTABLE_OS_NAME="MSDOS/DJGPP"
        try_dynload=no
        ;;
    *-linux*)
        PRINTABLE_OS_NAME="GNU/Linux"
        ;;
    *)
        PRINTABLE_OS_NAME=`uname -s || echo "Unknown"`
        ;;
esac
AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME",
                   [A human readable text with the name of the OS])


Werner Koch's avatar
Werner Koch committed
1255 1256 1257
#
# Checking for iconv
#
1258 1259 1260 1261 1262 1263 1264 1265
if test "$require_iconv" = yes; then
  AM_ICONV
else
  LIBICONV=
  LTLIBICONV=
  AC_SUBST(LIBICONV)
  AC_SUBST(LTLIBICONV)
fi
Werner Koch's avatar
Werner Koch committed
1266

1267

1268 1269 1270
#
# Check for gettext
#
1271 1272 1273
# This is "GNU gnupg" - The project-id script from gettext
#                       needs this string
#
1274
AC_MSG_NOTICE([checking for gettext])
Werner Koch's avatar
Werner Koch committed
1275
AM_PO_SUBDIRS
Werner Koch's avatar
Werner Koch committed
1276
AM_GNU_GETTEXT_VERSION([0.17])
1277
if test "$try_gettext" = yes; then
Werner Koch's avatar
Werner Koch committed
1278
  AM_GNU_GETTEXT([external],[need-ngettext])
1279 1280 1281 1282 1283 1284 1285 1286 1287 1288

  # gettext requires some extra checks.  These really should be part of
  # the basic AM_GNU_GETTEXT macro.  TODO: move other gettext-specific
  # function checks to here.

  AC_CHECK_FUNCS(strchr)
else
  USE_NLS=no
  USE_INCLUDED_LIBINTL=no
  BUILD_INCLUDED_LIBINTL=no
Werner Koch's avatar
Werner Koch committed
1289
  POSUB=po
1290 1291 1292
  AC_SUBST(USE_NLS)
  AC_SUBST(USE_INCLUDED_LIBINTL)
  AC_SUBST(BUILD_INCLUDED_LIBINTL)
Werner Koch's avatar
Werner Koch committed
1293
  AC_SUBST(POSUB)
1294 1295
fi

1296 1297
# We use HAVE_LANGINFO_CODESET in a couple of places.
AM_LANGINFO_CODESET
1298

1299
# Checks required for our use of locales
1300 1301 1302
gt_LC_MESSAGES


1303 1304 1305 1306 1307
#
# SELinux support
#
if test "$selinux_support" = yes ; then
  AC_DEFINE(ENABLE_SELINUX_HACKS,1,[Define to enable SELinux support])
1308
fi
1309

1310 1311

#
1312
# Checks for header files.
1313
#
1314
AC_MSG_NOTICE([checking for header files])
1315
AC_HEADER_STDC
1316
AC_CHECK_HEADERS([string.h unistd.h langinfo.h termio.h locale.h getopt.h \
1317
                  pty.h utmp.h pwd.h inttypes.h signal.h sys/select.h     \
1318
                  stdint.h signal.h util.h libutil.h termios.h \
NIIBE Yutaka's avatar
NIIBE Yutaka committed
1319
                  ucred.h sys/ucred.h sys/sysmacros.h sys/mkdev.h])
1320

1321
AC_HEADER_TIME
1322

1323

1324
#
1325
# Checks for typedefs, structures, and compiler characteristics.
1326
#
1327
AC_MSG_NOTICE([checking for system characteristics])
1328 1329
AC_C_CONST
AC_C_INLINE
1330
AC_C_VOLATILE
1331
AC_TYPE_SIZE_T
1332
AC_TYPE_MODE_T
1333 1334 1335
AC_TYPE_SIGNAL
AC_DECL_SYS_SIGLIST

1336 1337 1338
gl_HEADER_SYS_SOCKET
gl_TYPE_SOCKLEN_T

1339 1340
AC_SEARCH_LIBS([inet_addr], [nsl])

1341 1342 1343 1344 1345 1346 1347 1348
AC_ARG_ENABLE(endian-check,
              AC_HELP_STRING([--disable-endian-check],
	      [disable the endian check and trust the OS provided macros]),
	      endiancheck=$enableval,endiancheck=yes)

if test x"$endiancheck" = xyes ; then
  GNUPG_CHECK_ENDIAN
fi
1349

1350
# fixme: we should get rid of the byte type
1351 1352 1353
GNUPG_CHECK_TYPEDEF(byte, HAVE_BYTE_TYPEDEF)
GNUPG_CHECK_TYPEDEF(ushort, HAVE_USHORT_TYPEDEF)
GNUPG_CHECK_TYPEDEF(ulong, HAVE_ULONG_TYPEDEF)
1354 1355 1356 1357 1358 1359 1360
GNUPG_CHECK_TYPEDEF(u16, HAVE_U16_TYPEDEF)
GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF)

AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long)
1361
AC_HEADER_TIME
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374
AC_CHECK_SIZEOF(time_t,,[[
#include <stdio.h>
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# if HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif
]])
1375
GNUPG_TIME_T_UNSIGNED
1376 1377


1378 1379 1380 1381 1382 1383
if test "$ac_cv_sizeof_unsigned_short" = "0" \
   || test "$ac_cv_sizeof_unsigned_int" = "0" \
   || test "$ac_cv_sizeof_unsigned_long" = "0"; then
    AC_MSG_WARN([Hmmm, something is wrong with the sizes - using defaults]);
fi

1384 1385

#
1386
# Checks for library functions.
1387
#
1388
AC_MSG_NOTICE([checking for library functions])
1389
AC_CHECK_DECLS(getpagesize)
1390 1391 1392
AC_FUNC_FSEEKO
AC_FUNC_VPRINTF
AC_FUNC_FORK
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403
AC_CHECK_FUNCS([atexit canonicalize_file_name clock_gettime ctermid  \
                explicit_bzero fcntl flockfile fsync ftello          \
                ftruncate funlockfile getaddrinfo getenv getpagesize \
                getpwnam getpwuid getrlimit getrusage gettimeofday   \
                gmtime_r inet_ntop inet_pton isascii lstat memicmp   \
                memmove memrchr mmap nl_langinfo pipe raise rand     \
                setenv setlocale setrlimit sigaction sigprocmask     \
                stat stpcpy strcasecmp strerror strftime stricmp     \
                strlwr strncasecmp strpbrk strsep strtol strtoul     \
                strtoull tcgetattr timegm times ttyname unsetenv     \
                wait4 waitpid ])
1404

1405 1406 1407 1408 1409 1410 1411 1412 1413 1414
# On some systems (e.g. Solaris) nanosleep requires linking to librl.
# Given that we use nanosleep only as an optimization over a select
# based wait function we want it only if it is available in libc.
_save_libs="$LIBS"
AC_SEARCH_LIBS([nanosleep], [],
               [AC_DEFINE(HAVE_NANOSLEEP,1,
                [Define to 1 if you have the `nanosleep' function in libc.])])
LIBS="$_save_libs"


1415 1416 1417 1418 1419 1420 1421 1422
# See whether libc supports the Linux inotify interface
case "${host}" in
    *-*-linux*)
        AC_CHECK_FUNCS([inotify_init])
        ;;
esac


1423 1424 1425 1426 1427 1428
if test "$have_android_system" = yes; then
   # On Android ttyname is a stub but prints an error message.
   AC_DEFINE(HAVE_BROKEN_TTYNAME,1,
             [Defined if ttyname does not work properly])
fi

1429
AC_CHECK_TYPES([struct sigaction, sigset_t],,,[#include <signal.h>])
1430

Werner Koch's avatar
Werner Koch committed
1431 1432
# Dirmngr requires mmap on Unix systems.
if test $ac_cv_func_mmap != yes -a $mmap_needed = yes; then
1433
  AC_MSG_ERROR([[Sorry, the current implementation requires mmap.]])
Werner Koch's avatar
Werner Koch committed
1434 1435
fi

1436 1437

#
1438
# Check for the getsockopt SO_PEERCRED, etc.
1439
#
1440 1441
AC_CHECK_MEMBERS([struct ucred.pid, struct ucred.cr_pid, struct sockpeercred.pid], [], [], [#include <sys/types.h>
#include <sys/socket.h> ])
1442

1443 1444
# (Open)Solaris
AC_CHECK_FUNCS([getpeerucred])
1445 1446


1447
#
Werner Koch's avatar
Werner Koch committed
1448
# W32 specific test
1449
#
Werner Koch's avatar
Werner Koch committed
1450 1451
GNUPG_FUNC_MKDIR_TAKES_ONE_ARG

1452
#
1453
# Sanity check regex.  Tests adapted from mutt.
1454
#
1455 1456
AC_MSG_CHECKING([whether regular expression support is requested])
AC_ARG_ENABLE(regex,
1457 1458 1459
  AC_HELP_STRING([--disable-regex],
    [do not handle regular expressions in trust signatures]),
  use_regex=$enableval, use_regex=yes)
1460 1461 1462
AC_MSG_RESULT($use_regex)

if test "$use_regex" = yes ; then
1463 1464 1465 1466 1467 1468 1469 1470 1471
  _cppflags="${CPPFLAGS}"
  _ldflags="${LDFLAGS}"
  AC_ARG_WITH(regex,
     AC_HELP_STRING([--with-regex=DIR],[look for regex in DIR]),
      [
      if test -d "$withval" ; then
        CPPFLAGS="${CPPFLAGS} -I$withval/include"
        LDFLAGS="${LDFLAGS} -L$withval/lib"
      fi
1472
      ],withval="")
1473

1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484
  # Does the system have regex functions at all?
  AC_SEARCH_LIBS([regcomp], [regex])
  AC_CHECK_FUNC(regcomp, gnupg_cv_have_regex=yes, gnupg_cv_have_regex=no)

  if test $gnupg_cv_have_regex = no; then
    use_regex=no
  else
    if test x"$cross_compiling" = xyes; then
      AC_MSG_WARN([cross compiling; assuming regexp libray is not broken])
    else
      AC_CACHE_CHECK([whether your system's regexp library is broken],
1485 1486 1487 1488 1489 1490 1491
       [gnupg_cv_regex_broken],
       AC_TRY_RUN([
#include <unistd.h>
#include <regex.h>
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); }],
       gnupg_cv_regex_broken=no, gnupg_cv_regex_broken=yes, gnupg_cv_regex_broken=yes))

1492 1493 1494 1495 1496
      if test $gnupg_cv_regex_broken = yes; then
        AC_MSG_WARN([your regex is broken - disabling regex use])
        use_regex=no
      fi
    fi
1497
  fi
1498 1499
  CPPFLAGS="${_cppflags}"
  LDFLAGS="${_ldflags}"
1500 1501
fi