Remove useless bool "upper_case_domain" parameter.
[Samba/bb.git] / lib / ccan / libccan.m4
blob0d391ad961f86f0c9d0cf8fe493199c19a08c5b2
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_CACHE_CHECK([whether we can compile with __attribute__((cold))],
27                samba_cv_attribute_cold,
28                [
29                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
30                         [
31                                 static void __attribute__((cold))
32                                 cleanup(void) { }
33                         ])],
34                         samba_cv_attribute_cold=yes)
35                 ])
37 if test x"$samba_cv_attribute_cold" = xyes ; then
38    AC_DEFINE(HAVE_ATTRIBUTE_COLD, 1,
39              [whether we can compile with __attribute__((cold))])
42 AC_CACHE_CHECK([whether we can compile with __attribute__((const))],
43                samba_cv_attribute_const,
44                [
45                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
46                         [
47                                 static void __attribute__((const))
48                                 cleanup(void) { }
49                         ])],
50                         samba_cv_attribute_const=yes)
51                 ])
53 if test x"$samba_cv_attribute_const" = xyes ; then
54    AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1,
55              [whether we can compile with __attribute__((const))])
58 AC_CACHE_CHECK([whether we can compile with __attribute__((noreturn))],
59                samba_cv_attribute_noreturn,
60                [
61                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
62                         [
63                                 static void __attribute__((noreturn))
64                                 cleanup(void) { exit(1); }
65                         ])],
66                         samba_cv_attribute_noreturn=yes)
67                 ])
69 if test x"$samba_cv_attribute_noreturn" = xyes ; then
70    AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1,
71              [whether we can compile with __attribute__((noreturn))])
74 AC_CACHE_CHECK([whether we can compile with __attribute__((printf))],
75                samba_cv_attribute_printf,
76                [
77                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
78                         [
79                                 static void __attribute__((format(__printf__, 1, 2)))
80                                 cleanup(const char *fmt, ...) { }
81                         ])],
82                         samba_cv_attribute_printf=yes)
83                 ])
85 if test x"$samba_cv_attribute_printf" = xyes ; then
86    AC_DEFINE(HAVE_ATTRIBUTE_PRINTF, 1,
87              [whether we can compile with __attribute__((format(printf)))])
90 AC_CACHE_CHECK([whether we can compile with __attribute__((unused))],
91                samba_cv_attribute_unused,
92                [
93                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
94                         [
95                                 static void __attribute__((unused))
96                                 cleanup(void) { }
97                         ])],
98                         samba_cv_attribute_unused=yes)
99                 ])
101 if test x"$samba_cv_attribute_unused" = xyes ; then
102    AC_DEFINE(HAVE_ATTRIBUTE_UNUSED, 1,
103              [whether we can compile with __attribute__((unused))])
106 AC_CACHE_CHECK([whether we can compile with __attribute__((used))],
107                samba_cv_attribute_used,
108                [
109                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
110                         [
111                                 static void __attribute__((used))
112                                 cleanup(void) { }
113                         ])],
114                         samba_cv_attribute_used=yes)
115                 ])
117 if test x"$samba_cv_attribute_used" = xyes ; then
118    AC_DEFINE(HAVE_ATTRIBUTE_USED, 1,
119              [whether we can compile with __attribute__((used))])
122 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
123 # cross-compiling.
124 AC_CACHE_CHECK([whether we are big endian],samba_cv_big_endian,[
125 AC_TRY_RUN([int main(void) {
126 union { int i; char c[sizeof(int)]; } u;
127           u.i = 0x01020304;
128           return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;
130 samba_cv_big_endian=yes,
131 samba_cv_big_endian=no)])
132 if test x"$samba_cv_big_endian" = xyes ; then
133    AC_DEFINE(HAVE_BIG_ENDIAN, 1,
134              [whether we are big endian])
137 AC_CACHE_CHECK([whether we have __builtin_clz],
138                samba_cv_builtin_clz,
139                [
140                  AC_LINK_IFELSE([AC_LANG_SOURCE(
141                         [int main(void) {
142                                 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
143                         }])],
144                         samba_cv_builtin_clz=yes)
145                 ])
147 if test x"$samba_cv_builtin_clz" = xyes ; then
148    AC_DEFINE(HAVE_BUILTIN_CLZ, 1,
149              [whether we have __builtin_clz])
152 AC_CACHE_CHECK([whether we have __builtin_clzl],
153                samba_cv_builtin_clzl,
154                [
155                  AC_LINK_IFELSE([AC_LANG_SOURCE(
156                         [int main(void) {
157                                 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
158                         }])],
159                         samba_cv_builtin_clzl=yes)
160                 ])
162 if test x"$samba_cv_builtin_clzl" = xyes ; then
163    AC_DEFINE(HAVE_BUILTIN_CLZL, 1,
164              [whether we have __builtin_clzl])
166 AC_CACHE_CHECK([whether we have __builtin_clzll],
167                samba_cv_builtin_clzll,
168                [
169                  AC_LINK_IFELSE([AC_LANG_SOURCE(
170                         [int main(void) {
171                                 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
172                         }])],
173                         samba_cv_builtin_clzll=yes)
174                 ])
176 if test x"$samba_cv_builtin_clzll" = xyes ; then
177    AC_DEFINE(HAVE_BUILTIN_CLZLL, 1,
178              [whether we have __builtin_clzll])
181 AC_CACHE_CHECK([whether we have __builtin_constant_p],
182                samba_cv_builtin_constant_p,
183                [
184                  AC_LINK_IFELSE([AC_LANG_SOURCE(
185                         [int main(void) {
186                                 return __builtin_constant_p(1) ? 0 : 1;
187                         }])],
188                         samba_cv_builtin_constant_p=yes)
189                 ])
191 if test x"$samba_cv_builtin_constant_p" = xyes ; then
192    AC_DEFINE(HAVE_BUILTIN_CONSTANT_P, 1,
193              [whether we have __builtin_constant_p])
196 AC_CACHE_CHECK([whether we have __builtin_expect],
197                samba_cv_builtin_expect,
198                [
199                  AC_LINK_IFELSE([AC_LANG_SOURCE(
200                         [int main(void) {
201                                 return __builtin_expect(main != 0, 1) ? 0 : 1;
202                         }])],
203                         samba_cv_builtin_expect=yes)
204                 ])
206 if test x"$samba_cv_builtin_expect" = xyes ; then
207    AC_DEFINE(HAVE_BUILTIN_EXPECT, 1,
208              [whether we have __builtin_expect])
211 AC_CACHE_CHECK([whether we have __builtin_popcountl],
212                samba_cv_builtin_popcountl,
213                [
214                  AC_LINK_IFELSE([AC_LANG_SOURCE(
215                         [int main(void) {
216                                 return __builtin_popcountl(255L) == 8 ? 0 : 1;
217                         }])],
218                         samba_cv_builtin_popcountl=yes)
219                 ])
221 if test x"$samba_cv_builtin_popcountl" = xyes ; then
222    AC_DEFINE(HAVE_BUILTIN_POPCOUNTL, 1,
223              [whether we have __builtin_popcountl])
226 AC_CACHE_CHECK([whether we have __builtin_types_compatible_p],
227                samba_cv_builtin_types_compatible_p,
228                [
229                  AC_LINK_IFELSE([AC_LANG_SOURCE(
230                         [int main(void) {
231                                 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
232                         }])],
233                         samba_cv_builtin_types_compatible_p=yes)
234                 ])
236 if test x"$samba_cv_builtin_types_compatible_p" = xyes ; then
237    AC_DEFINE(HAVE_BUILTIN_TYPES_COMPATIBLE_P, 1,
238              [whether we have __builtin_types_compatible_p])
241 AC_CACHE_CHECK([whether we have __builtin_choose_expr],
242                samba_cv_builtin_choose_expr,
243                [
244                  AC_LINK_IFELSE([AC_LANG_SOURCE(
245                         [int main(void) {
246                                 return __builtin_choose_expr(1, 0, "garbage");
247                         }])],
248                         samba_cv_builtin_choose_expr=yes)
249                 ])
251 if test x"$samba_cv_builtin_choose_expr" = xyes ; then
252    AC_DEFINE(HAVE_BUILTIN_CHOOSE_EXPR, 1,
253              [whether we have __builtin_choose_expr])
256 # We use @<:@ and @:>@ here for embedded [ and ].
257 AC_CACHE_CHECK([whether we have compound literals],
258                samba_cv_compound_literals,
259                [
260                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
261                         [int main(void) {
262                                 int *foo = (int@<:@@:>@) { 1, 2, 3, 4 };
263                                 return foo@<:@0@:>@ == 1 ? 0 : 1;
264                         }])],
265                         samba_cv_compound_literals=yes)
266                 ])
268 if test x"$samba_cv_compound_literals" = xyes ; then
269    AC_DEFINE(HAVE_COMPOUND_LITERALS, 1,
270              [whether we have compound literals])
273 AC_CACHE_CHECK([whether we have isblank],
274                samba_cv_have_isblank,
275                [
276                  AC_LINK_IFELSE([AC_LANG_SOURCE(
277                         [#include <ctype.h>
278                          int main(void) { return isblank(' ') ? 0 : 1; }
279                         ])],
280                         samba_cv_have_isblank=yes)
281                 ])
283 if test x"$samba_cv_have_isblank" = xyes ; then
284    AC_DEFINE(HAVE_ISBLANK, 1,
285              [whether we have isblank])
288 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
289 # cross-compiling.
290 AC_CACHE_CHECK([whether we are little endian],samba_cv_little_endian,[
291 AC_TRY_RUN([int main(void) {
292 union { int i; char c[sizeof(int)]; } u;
293           u.i = 0x01020304;
294           return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;
296 samba_cv_little_endian=yes,
297 samba_cv_little_endian=no)])
298 if test x"$samba_cv_little_endian" = xyes ; then
299    AC_DEFINE(HAVE_LITTLE_ENDIAN, 1,
300              [whether we are little endian])
303 AC_CACHE_CHECK([whether we have __typeof__],
304                samba_cv_typeof,
305                [
306                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
307                         [int main(void) {
308                                 int x = 1;
309                                 __typeof__(x) i;
310                                 i = x;
311                                 return i == x ? 0 : 1;
312                         }])],
313                         samba_cv_typeof=yes)
314                 ])
316 if test x"$samba_cv_typeof" = xyes ; then
317    AC_DEFINE(HAVE_TYPEOF, 1,
318              [whether we have __typeof__])
321 AC_CACHE_CHECK([whether we have __attribute__((warn_unused_result))],
322                samba_cv_warn_unused_result,
323                [
324                  AC_COMPILE_IFELSE([AC_LANG_SOURCE(
325                         [int __attribute__((warn_unused_result)) func(int x)
326                             { return x; }])],
327                         samba_cv_warn_unused_result=yes)
328                 ])
330 if test x"$samba_cv_warn_unused_result" = xyes ; then
331    AC_DEFINE(HAVE_WARN_UNUSED_RESULT, 1,
332              [whether we have __attribute__((warn_unused_result))])