dsdb-operational: rework the loop for attribute removal
[Samba/bjacke.git] / lib / ccan / libccan.m4
blob7b27c69b81750c6e8b70f3e8b6eb58cbc62d3139
1 dnl find the ccan sources.
2 ccandir="../lib/ccan"
3 for d in $ccanpaths; do
4         if test -f "$srcdir/$d/str/str.c"; then
5                 ccandir="$d"
6                 AC_SUBST(ccandir)
7                 break
8         fi
9 done
10 if test -f "$ccandir/str/str.c"; then :; else
11    AC_MSG_ERROR([cannot find ccan source in $ccandir])
13 CCAN_OBJ="$ccandir/hash/hash.o $ccandir/htable/htable.o $ccandir/ilog/ilog.o $ccandir/likely/likely.o $ccandir/str/debug.o $ccandir/str/str.o $ccandir/tally/tally.o"
15 AC_SUBST(CCAN_OBJ)
17 # Preferred method for including ccan modules is #include <ccan/module/...>.
18 CCAN_CFLAGS="-I$ccandir/.."
19 AC_SUBST(CCAN_CFLAGS)
21 # All the configuration checks.  Regrettably, the __attribute__ checks will
22 # give false positives on old GCCs, since they just cause warnings.  But that's
23 # fairly harmless.
24 AC_CHECK_HEADERS(err.h)
26 AC_CHECK_HEADERS(byteswap.h)
28 AC_CACHE_CHECK([whether we can compile with __attribute__((cold))],
29                samba_cv_attribute_cold,
30                [
31                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
32                         [
33                                 static void __attribute__((cold))
34                                 cleanup(void) { }
35                         ])],
36                         samba_cv_attribute_cold=yes)
37                 ])
39 if test x"$samba_cv_attribute_cold" = xyes ; then
40    AC_DEFINE(HAVE_ATTRIBUTE_COLD, 1,
41              [whether we can compile with __attribute__((cold))])
44 AC_CACHE_CHECK([whether we can compile with __attribute__((const))],
45                samba_cv_attribute_const,
46                [
47                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
48                         [
49                                 static void __attribute__((const))
50                                 cleanup(void) { }
51                         ])],
52                         samba_cv_attribute_const=yes)
53                 ])
55 if test x"$samba_cv_attribute_const" = xyes ; then
56    AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1,
57              [whether we can compile with __attribute__((const))])
60 AC_CACHE_CHECK([whether we can compile with __attribute__((noreturn))],
61                samba_cv_attribute_noreturn,
62                [
63                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
64                         [
65                                 static void __attribute__((noreturn))
66                                 cleanup(void) { exit(1); }
67                         ])],
68                         samba_cv_attribute_noreturn=yes)
69                 ])
71 if test x"$samba_cv_attribute_noreturn" = xyes ; then
72    AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1,
73              [whether we can compile with __attribute__((noreturn))])
76 AC_CACHE_CHECK([whether we can compile with __attribute__((printf))],
77                samba_cv_attribute_printf,
78                [
79                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
80                         [
81                                 static void __attribute__((format(__printf__, 1, 2)))
82                                 cleanup(const char *fmt, ...) { }
83                         ])],
84                         samba_cv_attribute_printf=yes)
85                 ])
87 if test x"$samba_cv_attribute_printf" = xyes ; then
88    AC_DEFINE(HAVE_ATTRIBUTE_PRINTF, 1,
89              [whether we can compile with __attribute__((format(printf)))])
92 AC_CACHE_CHECK([whether we can compile with __attribute__((unused))],
93                samba_cv_attribute_unused,
94                [
95                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
96                         [
97                                 static void __attribute__((unused))
98                                 cleanup(void) { }
99                         ])],
100                         samba_cv_attribute_unused=yes)
101                 ])
103 if test x"$samba_cv_attribute_unused" = xyes ; then
104    AC_DEFINE(HAVE_ATTRIBUTE_UNUSED, 1,
105              [whether we can compile with __attribute__((unused))])
108 AC_CACHE_CHECK([whether we can compile with __attribute__((used))],
109                samba_cv_attribute_used,
110                [
111                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
112                         [
113                                 static void __attribute__((used))
114                                 cleanup(void) { }
115                         ])],
116                         samba_cv_attribute_used=yes)
117                 ])
119 if test x"$samba_cv_attribute_used" = xyes ; then
120    AC_DEFINE(HAVE_ATTRIBUTE_USED, 1,
121              [whether we can compile with __attribute__((used))])
124 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
125 # cross-compiling.
126 AC_CACHE_CHECK([whether we are big endian],samba_cv_big_endian,[
127 AC_TRY_RUN([int main(void) {
128 union { int i; char c[sizeof(int)]; } u;
129           u.i = 0x01020304;
130           return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;
132 samba_cv_big_endian=yes,
133 samba_cv_big_endian=no)])
134 if test x"$samba_cv_big_endian" = xyes ; then
135    AC_DEFINE(HAVE_BIG_ENDIAN, 1,
136              [whether we are big endian])
139 AC_CACHE_CHECK([whether we have __builtin_clz],
140                samba_cv_builtin_clz,
141                [
142                  AC_LINK_IFELSE([AC_LANG_SOURCE(
143                         [int main(void) {
144                                 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
145                         }])],
146                         samba_cv_builtin_clz=yes)
147                 ])
149 if test x"$samba_cv_builtin_clz" = xyes ; then
150    AC_DEFINE(HAVE_BUILTIN_CLZ, 1,
151              [whether we have __builtin_clz])
154 AC_CACHE_CHECK([whether we have __builtin_clzl],
155                samba_cv_builtin_clzl,
156                [
157                  AC_LINK_IFELSE([AC_LANG_SOURCE(
158                         [int main(void) {
159                                 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
160                         }])],
161                         samba_cv_builtin_clzl=yes)
162                 ])
164 if test x"$samba_cv_builtin_clzl" = xyes ; then
165    AC_DEFINE(HAVE_BUILTIN_CLZL, 1,
166              [whether we have __builtin_clzl])
168 AC_CACHE_CHECK([whether we have __builtin_clzll],
169                samba_cv_builtin_clzll,
170                [
171                  AC_LINK_IFELSE([AC_LANG_SOURCE(
172                         [int main(void) {
173                                 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
174                         }])],
175                         samba_cv_builtin_clzll=yes)
176                 ])
178 if test x"$samba_cv_builtin_clzll" = xyes ; then
179    AC_DEFINE(HAVE_BUILTIN_CLZLL, 1,
180              [whether we have __builtin_clzll])
183 AC_CACHE_CHECK([whether we have __builtin_constant_p],
184                samba_cv_builtin_constant_p,
185                [
186                  AC_LINK_IFELSE([AC_LANG_SOURCE(
187                         [int main(void) {
188                                 return __builtin_constant_p(1) ? 0 : 1;
189                         }])],
190                         samba_cv_builtin_constant_p=yes)
191                 ])
193 if test x"$samba_cv_builtin_constant_p" = xyes ; then
194    AC_DEFINE(HAVE_BUILTIN_CONSTANT_P, 1,
195              [whether we have __builtin_constant_p])
198 AC_CACHE_CHECK([whether we have __builtin_expect],
199                samba_cv_builtin_expect,
200                [
201                  AC_LINK_IFELSE([AC_LANG_SOURCE(
202                         [int main(void) {
203                                 return __builtin_expect(main != 0, 1) ? 0 : 1;
204                         }])],
205                         samba_cv_builtin_expect=yes)
206                 ])
208 if test x"$samba_cv_builtin_expect" = xyes ; then
209    AC_DEFINE(HAVE_BUILTIN_EXPECT, 1,
210              [whether we have __builtin_expect])
213 AC_CACHE_CHECK([whether we have __builtin_popcountl],
214                samba_cv_builtin_popcountl,
215                [
216                  AC_LINK_IFELSE([AC_LANG_SOURCE(
217                         [int main(void) {
218                                 return __builtin_popcountl(255L) == 8 ? 0 : 1;
219                         }])],
220                         samba_cv_builtin_popcountl=yes)
221                 ])
223 if test x"$samba_cv_builtin_popcountl" = xyes ; then
224    AC_DEFINE(HAVE_BUILTIN_POPCOUNTL, 1,
225              [whether we have __builtin_popcountl])
228 AC_CACHE_CHECK([whether we have __builtin_types_compatible_p],
229                samba_cv_builtin_types_compatible_p,
230                [
231                  AC_LINK_IFELSE([AC_LANG_SOURCE(
232                         [int main(void) {
233                                 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
234                         }])],
235                         samba_cv_builtin_types_compatible_p=yes)
236                 ])
238 if test x"$samba_cv_builtin_types_compatible_p" = xyes ; then
239    AC_DEFINE(HAVE_BUILTIN_TYPES_COMPATIBLE_P, 1,
240              [whether we have __builtin_types_compatible_p])
243 AC_CACHE_CHECK([whether we have __builtin_choose_expr],
244                samba_cv_builtin_choose_expr,
245                [
246                  AC_LINK_IFELSE([AC_LANG_SOURCE(
247                         [int main(void) {
248                                 return __builtin_choose_expr(1, 0, "garbage");
249                         }])],
250                         samba_cv_builtin_choose_expr=yes)
251                 ])
253 if test x"$samba_cv_builtin_choose_expr" = xyes ; then
254    AC_DEFINE(HAVE_BUILTIN_CHOOSE_EXPR, 1,
255              [whether we have __builtin_choose_expr])
258 # We use @<:@ and @:>@ here for embedded [ and ].
259 AC_CACHE_CHECK([whether we have compound literals],
260                samba_cv_compound_literals,
261                [
262                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
263                         [int main(void) {
264                                 int *foo = (int@<:@@:>@) { 1, 2, 3, 4 };
265                                 return foo@<:@0@:>@ == 1 ? 0 : 1;
266                         }])],
267                         samba_cv_compound_literals=yes)
268                 ])
270 if test x"$samba_cv_compound_literals" = xyes ; then
271    AC_DEFINE(HAVE_COMPOUND_LITERALS, 1,
272              [whether we have compound literals])
275 AC_CACHE_CHECK([whether we have flexible array members],
276                samba_cv_have_flex_arr_member,
277                [
278                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
279                         [struct foo { unsigned int x; int arr@<:@@:>@; }; ])],
280                         samba_cv_have_flex_arr_member=yes)
281                 ])
283 if test x"$samba_cv_have_flex_arr_member" = xyes ; then
284    AC_DEFINE(HAVE_FLEXIBLE_ARRAY_MEMBER, 1,
285              [whether we have flexible array member support])
288 AC_CACHE_CHECK([whether we have isblank],
289                samba_cv_have_isblank,
290                [
291                  AC_LINK_IFELSE([AC_LANG_SOURCE(
292                         [#include <ctype.h>
293                          int main(void) { return isblank(' ') ? 0 : 1; }
294                         ])],
295                         samba_cv_have_isblank=yes)
296                 ])
298 if test x"$samba_cv_have_isblank" = xyes ; then
299    AC_DEFINE(HAVE_ISBLANK, 1,
300              [whether we have isblank])
303 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
304 # cross-compiling.
305 AC_CACHE_CHECK([whether we are little endian],samba_cv_little_endian,[
306 AC_TRY_RUN([int main(void) {
307 union { int i; char c[sizeof(int)]; } u;
308           u.i = 0x01020304;
309           return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;
311 samba_cv_little_endian=yes,
312 samba_cv_little_endian=no)])
313 if test x"$samba_cv_little_endian" = xyes ; then
314    AC_DEFINE(HAVE_LITTLE_ENDIAN, 1,
315              [whether we are little endian])
318 AC_CACHE_CHECK([whether we have __typeof__],
319                samba_cv_typeof,
320                [
321                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
322                         [int main(void) {
323                                 int x = 1;
324                                 __typeof__(x) i;
325                                 i = x;
326                                 return i == x ? 0 : 1;
327                         }])],
328                         samba_cv_typeof=yes)
329                 ])
331 if test x"$samba_cv_typeof" = xyes ; then
332    AC_DEFINE(HAVE_TYPEOF, 1,
333              [whether we have __typeof__])
336 AC_CACHE_CHECK([whether we have __attribute__((warn_unused_result))],
337                samba_cv_warn_unused_result,
338                [
339                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
340                         [int __attribute__((warn_unused_result)) func(int x)
341                             { return x; }])],
342                         samba_cv_warn_unused_result=yes)
343                 ])
345 if test x"$samba_cv_warn_unused_result" = xyes ; then
346    AC_DEFINE(HAVE_WARN_UNUSED_RESULT, 1,
347              [whether we have __attribute__((warn_unused_result))])
349 AC_HAVE_DECL(bswap_64, [#include <byteswap.h>])