cbba87d5804cbddeeda5023c87aad55c9ae0a864
[samba.git] / source4 / lib / tls / wscript
1 #!/usr/bin/env python
2
3 import Options
4 from optparse import SUPPRESS_HELP
5
6 def set_options(opt):
7     # allow users to disable gnutls
8     opt.add_option('--enable-gnutls',
9                    help=("Enable use of gnutls"),
10                    action="store_true", dest='enable_gnutls', default=True)
11     opt.add_option('--disable-gnutls', help=SUPPRESS_HELP, action="store_false", dest='enable_gnutls')
12
13
14 def configure(conf):
15     conf.env.enable_gnutls = Options.options.enable_gnutls
16     if not conf.env.enable_gnutls:
17         conf.SET_TARGET_TYPE('gnutls', 'DISABLED')
18         conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
19         conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')
20         if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
21             conf.fatal("--disable-gnutls given: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")
22         return
23
24     if conf.check_cfg(package='gnutls',
25                       args='"gnutls >= 3.0.0" --cflags --libs',
26                       msg='Checking for gnutls >= 3.0.0s', mandatory=False):
27         conf.DEFINE('HAVE_GNUTLS3', 1)
28     else:
29         conf.check_cfg(package='gnutls',
30                        args='"gnutls >= 1.4.0 gnutls != 2.2.4 gnutls != 2.8.0 gnutls != 2.8.1" --cflags --libs',
31                        msg='Checking for gnutls >= 1.4.0 and broken versions', mandatory=False)
32
33     if 'HAVE_GNUTLS' in conf.env:
34         conf.DEFINE('ENABLE_GNUTLS', 1)
35     else:
36         if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
37             conf.fatal("Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")
38
39     conf.CHECK_FUNCS_IN('gnutls_global_init', 'gnutls',
40                         headers='gnutls/gnutls.h')
41
42     conf.CHECK_VARIABLE('gnutls_x509_crt_set_version',
43                         headers='gnutls/gnutls.h gnutls/x509.h',
44                         define='HAVE_GNUTLS_X509_CRT_SET_VERSION',
45                         lib='gnutls')
46     conf.CHECK_VARIABLE('gnutls_x509_crt_set_subject_key_id',
47                         headers='gnutls/gnutls.h gnutls/x509.h',
48                         define='HAVE_GNUTLS_X509_CRT_SET_SUBJECT_KEY_ID',
49                         lib='gnutls')
50
51     # check for gnutls_datum types
52     conf.CHECK_TYPES('gnutls_datum gnutls_datum_t',
53                      headers='gnutls/gnutls.h', lib='gnutls')
54
55     # GnuTLS3 moved to libnettle, so only do this in the < 3.0 case
56     if not 'HAVE_GNUTLS3' in conf.env:
57         conf.CHECK_FUNCS_IN('gcry_control', 'gcrypt', headers='gcrypt.h')
58         conf.CHECK_FUNCS_IN('gpg_err_code_from_errno', 'gpg-error')
59     else:
60         conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
61         conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')
62
63
64 def build(bld):
65     bld.SAMBA_SUBSYSTEM('LIBTLS',
66                         source='tls.c tlscert.c tls_tstream.c',
67                         allow_warnings=True,
68                         public_deps='talloc gnutls gcrypt samba-hostconfig samba_socket LIBTSOCKET tevent tevent-util'
69                         )