smbd: Always free the talloc_stackframe() before leaving smbd_do_query_security_desc
[Samba/bb.git] / lib / ccan / wscript
blob334f8fe4d08665be9f56b7699033a9af11785f99
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 # FIXME: if they don't have -Werror, these will all fail. But they
9 # probably will anyway...
10 conf.CHECK_CODE('int __attribute__((cold)) func(int x) { return x; }',
11 addmain=False, link=False, cflags="-Werror",
12 define='HAVE_ATTRIBUTE_COLD')
13 conf.CHECK_CODE('int __attribute__((const)) func(int x) { return x; }',
14 addmain=False, link=False, cflags="-Werror",
15 define='HAVE_ATTRIBUTE_CONST')
16 conf.CHECK_CODE('void __attribute__((noreturn)) func(int x) { exit(x); }',
17 addmain=False, link=False, cflags="-Werror",
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="-Werror",
21 define='HAVE_ATTRIBUTE_PRINTF')
22 conf.CHECK_CODE('int __attribute__((unused)) func(int x) { return x; }',
23 addmain=False, link=False, cflags="-Werror",
24 define='HAVE_ATTRIBUTE_UNUSED')
25 conf.CHECK_CODE('int __attribute__((used)) func(int x) { return x; }',
26 addmain=False, link=False, cflags="-Werror",
27 define='HAVE_ATTRIBUTE_USED')
28 # We try to use headers for a compile-time test.
29 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
30 #define B __BYTE_ORDER
31 #elif defined(BYTE_ORDER)
32 #define B BYTE_ORDER
33 #endif
35 #ifdef __LITTLE_ENDIAN
36 #define LITTLE __LITTLE_ENDIAN
37 #elif defined(LITTLE_ENDIAN)
38 #define LITTLE LITTLE_ENDIAN
39 #endif
41 #if !defined(LITTLE) || !defined(B) || LITTLE != B
42 #error Not little endian.
43 #endif""",
44 headers="endian.h sys/endian.h",
45 define="HAVE_LITTLE_ENDIAN")
46 conf.CHECK_CODE(code = """#ifdef __BYTE_ORDER
47 #define B __BYTE_ORDER
48 #elif defined(BYTE_ORDER)
49 #define B BYTE_ORDER
50 #endif
52 #ifdef __BIG_ENDIAN
53 #define BIG __BIG_ENDIAN
54 #elif defined(BIG_ENDIAN)
55 #define BIG BIG_ENDIAN
56 #endif
58 #if !defined(BIG) || !defined(B) || BIG != B
59 #error Not big endian.
60 #endif""",
61 headers="endian.h sys/endian.h",
62 define="HAVE_BIG_ENDIAN")
64 if not conf.CONFIG_SET("HAVE_BIG_ENDIAN") and not conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
65 # That didn't work! Do runtime test.
66 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
67 u.i = 0x01020304;
68 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;""",
69 addmain=True, execute=True,
70 define='HAVE_LITTLE_ENDIAN',
71 msg="Checking for HAVE_LITTLE_ENDIAN - runtime")
72 conf.CHECK_CODE("""union { int i; char c[sizeof(int)]; } u;
73 u.i = 0x01020304;
74 return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;""",
75 addmain=True, execute=True,
76 define='HAVE_BIG_ENDIAN',
77 msg="Checking for HAVE_BIG_ENDIAN - runtime")
79 # Extra sanity check.
80 if conf.CONFIG_SET("HAVE_BIG_ENDIAN") == conf.CONFIG_SET("HAVE_LITTLE_ENDIAN"):
81 Logs.error("Failed endian determination. The PDP-11 is back?")
82 sys.exit(1)
84 conf.CHECK_CODE('return __builtin_choose_expr(1, 0, "garbage");',
85 link=True,
86 define='HAVE_BUILTIN_CHOOSE_EXPR')
87 conf.CHECK_CODE('return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;',
88 link=True,
89 define='HAVE_BUILTIN_CLZ')
90 conf.CHECK_CODE('return __builtin_clzl(1) == (sizeof(long)*8 - 1) ? 0 : 1;',
91 link=True,
92 define='HAVE_BUILTIN_CLZL')
93 conf.CHECK_CODE('return __builtin_clzll(1) == (sizeof(long long)*8 - 1) ? 0 : 1;',
94 link=True,
95 define='HAVE_BUILTIN_CLZLL')
96 conf.CHECK_CODE('return __builtin_constant_p(1) ? 0 : 1;',
97 link=True,
98 define='HAVE_BUILTIN_CONSTANT_P')
99 conf.CHECK_CODE('return __builtin_expect(main != 0, 1) ? 0 : 1;',
100 link=True,
101 define='HAVE_BUILTIN_EXPECT')
102 conf.CHECK_CODE('return __builtin_popcountl(255L) == 8 ? 0 : 1;',
103 link=True,
104 define='HAVE_BUILTIN_POPCOUNTL')
105 conf.CHECK_CODE('return __builtin_types_compatible_p(char *, int) ? 1 : 0;',
106 link=True,
107 define='HAVE_BUILTIN_TYPES_COMPATIBLE_P')
108 conf.CHECK_CODE('int *foo = (int[]) { 1, 2, 3, 4 }; return foo[0] ? 0 : 1;',
109 define='HAVE_COMPOUND_LITERALS')
110 conf.CHECK_CODE("""#include <ctype.h>
111 int main(void) { return isblank(' ') ? 0 : 1; }""",
112 link=True, addmain=False, add_headers=False,
113 define='HAVE_ISBLANK')
114 conf.CHECK_CODE('int x = 1; __typeof__(x) i; i = x; return i == x ? 0 : 1;',
115 link=True,
116 define='HAVE_TYPEOF')
117 conf.CHECK_CODE('int __attribute__((warn_unused_result)) func(int x) { return x; }',
118 addmain=False, link=False, cflags="-Werror",
119 define='HAVE_WARN_UNUSED_RESULT')
121 # backtrace could be in libexecinfo or in libc
122 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
124 def ccan_module(bld, name, deps=''):
125 bld.SAMBA_SUBSYSTEM('ccan-%s' % name,
126 source=bld.path.ant_glob('%s/*.c' % name),
127 deps=deps)
128 bld.env.CCAN_MODS += 'ccan-%s ' % name
130 def build(bld):
131 bld.env.CCAN_MODS = ""
133 # These have actual C files.
134 ccan_module(bld, 'hash', 'ccan-build_assert')
135 ccan_module(bld, 'ilog', 'ccan-compiler');
136 ccan_module(bld, 'read_write_all')
137 ccan_module(bld, 'str', 'ccan-build_assert')
138 ccan_module(bld, 'tally', 'ccan-build_assert ccan-likely')
140 # These are headers only.
141 ccan_module(bld, 'array_size', 'ccan-build_assert')
142 ccan_module(bld, 'asearch','ccan-typesafe_cb ccan-array_size')
143 ccan_module(bld, 'build_assert')
144 ccan_module(bld, 'cast', 'ccan-build_assert')
145 ccan_module(bld, 'check_type', 'ccan-build_assert')
146 ccan_module(bld, 'compiler')
147 ccan_module(bld, 'endian')
148 ccan_module(bld, 'likely', 'ccan-str')
149 ccan_module(bld, 'typesafe_cb')
150 ccan_module(bld, 'err', 'ccan-compiler')
152 # Failtest pulls in a lot of stuff, and it's only for unit tests.
153 if bld.env.DEVELOPER_MODE:
154 ccan_module(bld, 'container_of', 'ccan-check_type')
155 ccan_module(bld, 'htable', 'ccan-compiler')
156 ccan_module(bld, 'list', 'ccan-container_of')
157 ccan_module(bld, 'time')
158 ccan_module(bld, 'tcon')
159 ccan_module(bld, 'tlist', 'ccan-list ccan-tcon')
160 ccan_module(bld, 'failtest',
162 ccan-err ccan-hash ccan-htable ccan-list
163 ccan-read_write_all ccan-str ccan-time execinfo
164 ''')
166 # This is the complete CCAN collection as one group.
167 bld.SAMBA_LIBRARY('ccan',
168 source='',
169 deps=bld.env.CCAN_MODS,
170 private_library=True,
171 grouping_library=True)