2 AddOption('--float', choices
=('4', '8', '16'), default
=8, metavar
='4,8,16', help='floating-point number bytes')
3 AddOption('--tools', default
='', help='append the default tool list')
5 vars.Add('CC', help='The C compiler')
6 vars.Add('CFLAGS', help='The C compiler flags')
7 vars.Add('LINKFLAGS', help='The linker flags')
10 tools
=['default'] + GetOption('tools').split(','),
13 env
.Append(CPPPATH
=('include'))
14 env
.Append(CPPDEFINES
=('A_EXPORTS'))
15 env
.Append(CPPDEFINES
=('A_HAVA_H', '"a.scons.h"'))
17 if '\n' not in conf
.config_h_text
:
19 conf
.config_h_text
= conf
.config_h_text
.replace(
20 conf
.config_h_text
.splitlines()[-1] + '\n', ''
22 conf
= env
.Configure(config_h
='include/a/a.scons.h')
23 A_SIZE_POINTER
= conf
.CheckTypeSize('void *')
25 conf
.Define('A_SIZE_POINTER', A_SIZE_POINTER
)
26 res
= conf
.TryRun('''#include <stdio.h>
30 printf("%s", *(char *)&x ? "1234" : "4321");
35 conf
.Define('A_BYTE_ORDER', res
[1], 'The byte order of compiler target architecture.')
36 A_SIZE_FLOAT
= int(env
.GetOption('float'))
37 conf
.Define('A_SIZE_FLOAT', A_SIZE_FLOAT
, "The size of `a_float', as computed by sizeof.")
41 'expm1', 'log1p', 'hypot', 'atan2',
42 'csqrt', 'cpow', 'cexp', 'clog',
43 'csin', 'ccos', 'ctan',
44 'csinh', 'ccosh', 'ctanh',
45 'casin', 'cacos', 'catan',
46 'casinh', 'cacosh', 'catanh'
48 name
= 'A_HAVE_' + func
.upper()
49 if A_SIZE_FLOAT
== 0x10:
51 if A_SIZE_FLOAT
== 0x04:
53 ok
= conf
.CheckFunc(func
)
56 conf
.Define(name
, '1')
58 a
= env
.SharedObject(env
.Glob('src/*.c') + env
.Glob('src/*/*.c'))
59 if env
['PLATFORM'] == 'win32':
60 liba
= env
.SharedLibrary('liba', a
)
62 liba
= env
.SharedLibrary('a', a
)
63 alib
= env
.StaticLibrary('a', a
)
65 if env
.GetOption('install_sandbox'):
66 include
= env
.Install('include', source
='include/a')
67 def install_fixup(source
, target
, env
):
68 source
= source
[0].get_relpath() + '/a.h'
69 target
= target
[0].get_relpath() + '/a.h'
70 with
open(source
, "r") as f
:
72 cur
= "#if defined(A_HAVE_H)"
73 new
= '#include "a.scons.h"\n' + cur
74 text
= text
.replace(cur
, new
)
75 with
open(target
, "wb") as f
:
76 f
.write(text
.encode())
77 env
.AddPostAction(include
, install_fixup
)
78 env
.Install('lib', source
=[alib
, liba
])