Fix some typos.
[Samba.git] / lib / ccan / wscript
blob0e540dbf0887c039e33c435a34fe2e20e59a51d8
1 #!/usr/bin/env python
3 import Logs, sys, Options
5 def configure(conf):
6 conf.DEFINE('HAVE_CCAN', 1)
7 conf.CHECK_HEADERS('err.h')
8 conf.CHECK_HEADERS('byteswap.h')
9 conf.CHECK_FUNCS('bswap_64', link=False, headers="byteswap.h")
10 conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
11 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
12 define='HAVE_ATTRIBUTE_COLD')
13 conf.CHECK_CODE('int __attribute__((const)) func(int x) { return x; }',
14 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
15 define='HAVE_ATTRIBUTE_CONST')
16 conf.CHECK_CODE('void __attribute__((noreturn)) func(int x) { exit(x); }',
17 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
18 define='HAVE_ATTRIBUTE_NORETURN')
19 conf.CHECK_CODE('void __attribute__((format(__printf__, 1, 2))) func(const char *fmt, ...) { }',
20 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
21 define='HAVE_ATTRIBUTE_PRINTF')
22 conf.CHECK_CODE('int __attribute__((unused)) func(int x) { return x; }',
23 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
24 define='HAVE_ATTRIBUTE_UNUSED')
25 conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
26 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
27 define='HAVE_ATTRIBUTE_USED')
29 conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
30 link=True,
31 define='HAVE_BUILTIN_CHOOSE_EXPR')
32 conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;',
33 link=True,
34 define='HAVE_BUILTIN_CLZ')
35 conf.CHECK_CODE('return __builtin_clzl(1) == (sizeof(long)*8 - 1) ? 0 : 1;',
36 link=True,
37 define='HAVE_BUILTIN_CLZL')
38 conf.CHECK_CODE('return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;',
39 link=True,
40 define='HAVE_BUILTIN_CLZLL')
41 conf.CHECK_CODE('return __builtin_constant_p(1) ? 0 : 1;',
42 link=True,
43 define='HAVE_BUILTIN_CONSTANT_P')
44 conf.CHECK_CODE('return __builtin_expect(main != 0, 1) ? 0 : 1;',
45 link=True,
46 define='HAVE_BUILTIN_EXPECT')
47 conf.CHECK_CODE('return __builtin_popcountl(255L) == 8 ? 0 : 1;',
48 link=True,
49 define='HAVE_BUILTIN_POPCOUNTL')
50 conf.CHECK_CODE('return __builtin_types_compatible_p(char *, int) ? 1 : 0;',
51 link=True,
52 define='HAVE_BUILTIN_TYPES_COMPATIBLE_P')
53 conf.CHECK_CODE('int *foo = (int[]) { 1, 2, 3, 4 }; return foo[0] ? 0 : 1;',
54 define='HAVE_COMPOUND_LITERALS')
55 conf.CHECK_CODE('struct foo { unsigned int x; int arr[]; };',
56 addmain=False, link=False,
57 define='HAVE_FLEXIBLE_ARRAY_MEMBER')
58 conf.CHECK_CODE("""#include <ctype.h>
59 int main(void) { return isblank(' ') ? 0 : 1; }""",
60 link=True, addmain=False, add_headers=False,
61 define='HAVE_ISBLANK')
62 conf.CHECK_CODE('int x = 1; __typeof__(x) i; i = x; return i == x ? 0 : 1;',
63 link=True,
64 define='HAVE_TYPEOF')
65 conf.CHECK_CODE('int __attribute__((warn_unused_result)) func(int x) { return x; }',
66 addmain=False, link=False, cflags=conf.env['WERROR_CFLAGS'],
67 define='HAVE_WARN_UNUSED_RESULT')
69 # backtrace could be in libexecinfo or in libc
70 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
72 # Only check for FILE_OFFSET_BITS=64 if off_t is normally small:
73 # use raw routines because wrappers include previous _GNU_SOURCE
74 # or _FILE_OFFSET_BITS defines.
75 # The math for these tests is:
76 # array[-1 * !((int)(condition)) ] (condition is true) = array[0] = builds
77 # array[-1 * !((int)(condition)) ] (condition is false) = array[-1] = fails
78 conf.check(fragment="""#include <sys/types.h>
79 int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) < 8)]; }""",
80 msg='Checking for small off_t',
81 define_name='SMALL_OFF_T')
82 # Unreliable return value above, hence use define.
83 if conf.CONFIG_SET('SMALL_OFF_T'):
84 conf.check(fragment="""#include <sys/types.h>
85 int main(void) { static int test_array[1 - 2 * !(((long int)(sizeof(off_t))) >= 8)]; }""",
86 msg='Checking for -D_FILE_OFFSET_BITS=64',
87 ccflags='-D_FILE_OFFSET_BITS=64',
88 define_name='HAVE_FILE_OFFSET_BITS')
90 def ccan_module(bld, name, deps=''):
91 bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
92 source=bld.path.ant_glob('%s/*.c' % name),
93 allow_warnings=True,
94 deps=deps)
95 bld.env.CCAN_MODS += 'ccan-%s ' % name
97 def build(bld):
98 bld.env.CCAN_MODS = ""
100 # These have actual C files.
101 ccan_module(bld, 'hash', 'ccan-build_assert')
102 ccan_module(bld, 'ilog', 'ccan-compiler');
103 ccan_module(bld, 'read_write_all')
104 ccan_module(bld, 'str', 'ccan-build_assert')
105 ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
107 # These are headers only.
108 ccan_module(bld, 'array_size', 'ccan-build_assert')
109 ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
110 ccan_module(bld, 'build_assert')
111 ccan_module(bld, 'cast', 'ccan-build_assert')
112 ccan_module(bld, 'check_type', 'ccan-build_assert')
113 ccan_module(bld, 'compiler')
114 ccan_module(bld, 'endian')
115 ccan_module(bld, 'likely', 'ccan-str')
116 ccan_module(bld, 'typesafe_cb')
117 ccan_module(bld, 'err', 'ccan-compiler')
119 # Failtest pulls in a lot of stuff, and it's only for unit tests.
120 if bld.env.DEVELOPER_MODE:
121 ccan_module(bld, 'container_of', 'ccan-check_type')
122 ccan_module(bld, 'htable', 'ccan-compiler')
123 ccan_module(bld, 'list', 'ccan-container_of')
124 ccan_module(bld, 'time')
125 ccan_module(bld, 'tcon')
126 ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
127 ccan_module(bld, 'failtest',
129 ccan-err ccan-hash ccan-htable ccan-list
130 ccan-read_write_all ccan-str ccan-time execinfo
131 ''')
133 # This is the complete CCAN collection as one group.
134 bld.SAMBA_LIBRARY('ccan',
135 source='',
136 deps=bld.env.CCAN_MODS,
137 allow_warnings=True,
138 private_library=True,
139 grouping_library=True)