s3:script: Replace --merge by --merge-by-timestamp in samba-log-parser
[samba4-gss.git] / wscript_configure_system_gnutls
blob9e9abcce17d91ac70391d06898e4cc2defd02324
1 from waflib import Logs
2 import os
4 def parse_version(v):
5     return tuple(map(int, (v.split("."))))
7 gnutls_min_required_version = "3.6.13"
9 conf.CHECK_FUNCS('getrandom', headers='sys/random.h')
10 if not conf.CONFIG_SET('HAVE_GETRANDOM'):
11    gnutls_min_required_version = "3.7.2"
13 gnutls_required_version = gnutls_min_required_version
15 conf.CHECK_CFG(package='gnutls',
16                args=('"gnutls >= %s" --cflags --libs' % gnutls_required_version),
17                      msg='Checking for GnuTLS >= %s' % gnutls_required_version,
18                      mandatory=True)
20 gnutls_version_str = conf.cmd_and_log(conf.env.PKGCONFIG + ['--modversion', 'gnutls']).strip()
21 gnutls_version = parse_version(gnutls_version_str)
23 # Define gnutls as a system library
24 conf.SET_TARGET_TYPE('gnutls', 'SYSLIB')
26 # Check for gnutls_aead_cipher_encryptv2
28 # This is available since version 3.6.10, but 3.6.10 has a bug which got fixed
29 # in 3.6.11, see:
31 #     https://gitlab.com/gnutls/gnutls/-/merge_requests/1085
33 # 3.6.10 - 3.6.14 have a severe memory leak with AES-CCM
34 #     https://gitlab.com/gnutls/gnutls/-/merge_requests/1278
35 if (gnutls_version > parse_version('3.6.14')):
36       conf.DEFINE('ALLOW_GNUTLS_AEAD_CIPHER_ENCRYPTV2_AES_CCM', 1)
38 # Check if gnutls has fips mode support
39 # gnutls_fips140_mode_enabled() is available since 3.3.0
40 fragment = '''
41 #include <gnutls/gnutls.h>
42 #include <stdlib.h>
44 int main(void)
46     unsigned int ok;
48     ok = gnutls_fips140_mode_enabled();
50     return !ok;
52 '''
54 os.environ['GNUTLS_FORCE_FIPS_MODE'] = '1'
55 conf.CHECK_CODE(fragment,
56                 'HAVE_GNUTLS_FIPS_MODE_SUPPORTED',
57                 execute=True,
58                 addmain=False,
59                 add_headers=False,
60                 lib='gnutls',
61                 msg='Checking for gnutls fips mode support')
62 del os.environ['GNUTLS_FORCE_FIPS_MODE']