summaryrefslogtreecommitdiff
path: root/source4/lib/tls/wscript
blob: cbba87d5804cbddeeda5023c87aad55c9ae0a864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python

import Options
from optparse import SUPPRESS_HELP

def set_options(opt):
    # allow users to disable gnutls
    opt.add_option('--enable-gnutls',
                   help=("Enable use of gnutls"),
                   action="store_true", dest='enable_gnutls', default=True)
    opt.add_option('--disable-gnutls', help=SUPPRESS_HELP, action="store_false", dest='enable_gnutls')


def configure(conf):
    conf.env.enable_gnutls = Options.options.enable_gnutls
    if not conf.env.enable_gnutls:
        conf.SET_TARGET_TYPE('gnutls', 'DISABLED')
        conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
        conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')
        if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
            conf.fatal("--disable-gnutls given: Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")
        return

    if conf.check_cfg(package='gnutls',
                      args='"gnutls >= 3.0.0" --cflags --libs',
                      msg='Checking for gnutls >= 3.0.0s', mandatory=False):
        conf.DEFINE('HAVE_GNUTLS3', 1)
    else:
        conf.check_cfg(package='gnutls',
                       args='"gnutls >= 1.4.0 gnutls != 2.2.4 gnutls != 2.8.0 gnutls != 2.8.1" --cflags --libs',
                       msg='Checking for gnutls >= 1.4.0 and broken versions', mandatory=False)

    if 'HAVE_GNUTLS' in conf.env:
        conf.DEFINE('ENABLE_GNUTLS', 1)
    else:
        if 'AD_DC_BUILD_IS_ENABLED' in conf.env:
            conf.fatal("Building the AD DC requires GnuTLS (eg libgnutls-dev, gnutls-devel) for ldaps:// support and for the BackupKey protocol")

    conf.CHECK_FUNCS_IN('gnutls_global_init', 'gnutls',
                        headers='gnutls/gnutls.h')

    conf.CHECK_VARIABLE('gnutls_x509_crt_set_version',
                        headers='gnutls/gnutls.h gnutls/x509.h',
                        define='HAVE_GNUTLS_X509_CRT_SET_VERSION',
                        lib='gnutls')
    conf.CHECK_VARIABLE('gnutls_x509_crt_set_subject_key_id',
                        headers='gnutls/gnutls.h gnutls/x509.h',
                        define='HAVE_GNUTLS_X509_CRT_SET_SUBJECT_KEY_ID',
                        lib='gnutls')

    # check for gnutls_datum types
    conf.CHECK_TYPES('gnutls_datum gnutls_datum_t',
                     headers='gnutls/gnutls.h', lib='gnutls')

    # GnuTLS3 moved to libnettle, so only do this in the < 3.0 case
    if not 'HAVE_GNUTLS3' in conf.env:
        conf.CHECK_FUNCS_IN('gcry_control', 'gcrypt', headers='gcrypt.h')
        conf.CHECK_FUNCS_IN('gpg_err_code_from_errno', 'gpg-error')
    else:
        conf.SET_TARGET_TYPE('gcrypt', 'DISABLED')
        conf.SET_TARGET_TYPE('gpg-error', 'DISABLED')


def build(bld):
    bld.SAMBA_SUBSYSTEM('LIBTLS',
                        source='tls.c tlscert.c tls_tstream.c',
                        allow_warnings=True,
                        public_deps='talloc gnutls gcrypt samba-hostconfig samba_socket LIBTSOCKET tevent tevent-util'
                        )