summaryrefslogtreecommitdiff
path: root/third_party/aesni-intel/wscript
blob: bb874454ca68c547e93a5a4f20acce27c3034698 (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
#!/usr/bin/env python
from waflib import Options
from waflib import Utils

def configure(conf):
    if Options.options.accel_aes.lower() == "intelaesni":
        asm_flags = ('-Wp,-E,-lang-asm', '-xassembler-with-cpp')
        for f in asm_flags:
            if conf.CHECK_CFLAGS(f, ''):
                conf.DEFINE('AESNI_INTEL_CFLAGS', f)
                break
        if conf.CONFIG_SET('AESNI_INTEL_CFLAGS'):
            if conf.env['SYSTEM_UNAME_MACHINE'] in ('x86_64', 'amd64'):
                print("Compiling with Intel AES instructions")
                conf.DEFINE('HAVE_AESNI_INTEL', 1)
            else:
                raise Utils.WafError('--accel-aes=intelaesni selected and non x86_64 CPU')
        else:
            raise Utils.WafError('--aes-accel=intelaesni selected and compiler rejects ' + str(asm_flags))
        if not conf.CHECK_LDFLAGS('-Wl,-z,noexecstack'):
            raise Utils.WafError('--accel-aes=intelaesni selected and linker rejects -z noexecstack')

def build(bld):
    if not bld.CONFIG_SET('HAVE_AESNI_INTEL'):
        return

    bld.SAMBA_LIBRARY('aesni-intel',
        source='aesni-intel_asm.c',
        cflags=bld.CONFIG_GET('AESNI_INTEL_CFLAGS'),
        ldflags='-Wl,-z,noexecstack',
        private_library=True)