waf: Utils package not defined
[bbaumbach/samba-autobuild/.git] / third_party / aesni-intel / wscript
1 #!/usr/bin/env python
2 from waflib import Options
3 from waflib import Errors
4
5 def configure(conf):
6     if Options.options.accel_aes.lower() == "intelaesni":
7         asm_flags = ('-Wp,-E,-lang-asm', '-xassembler-with-cpp')
8         for f in asm_flags:
9             if conf.CHECK_CFLAGS(f, ''):
10                 conf.DEFINE('AESNI_INTEL_CFLAGS', f)
11                 break
12         if conf.CONFIG_SET('AESNI_INTEL_CFLAGS'):
13             if conf.env['SYSTEM_UNAME_MACHINE'] in ('x86_64', 'amd64'):
14                 print("Compiling with Intel AES instructions")
15                 conf.DEFINE('HAVE_AESNI_INTEL', 1)
16             else:
17                 raise Errors.WafError('--accel-aes=intelaesni selected and non x86_64 CPU')
18         else:
19             raise Errors.WafError('--aes-accel=intelaesni selected and compiler rejects ' + str(asm_flags))
20         if not conf.CHECK_LDFLAGS('-Wl,-z,noexecstack'):
21             raise Errors.WafError('--accel-aes=intelaesni selected and linker rejects -z noexecstack')
22
23 def build(bld):
24     if not bld.CONFIG_SET('HAVE_AESNI_INTEL'):
25         return
26
27     bld.SAMBA_LIBRARY('aesni-intel',
28         source='aesni-intel_asm.c',
29         cflags=bld.CONFIG_GET('AESNI_INTEL_CFLAGS'),
30         ldflags='-Wl,-z,noexecstack',
31         private_library=True)