1 dnl find the ccan sources.
3 for d in $ccanpaths; do
4 if test -f "$srcdir/$d/str/str.c"; then
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"
17 # Preferred method for including ccan modules is #include <ccan/module/...>.
18 CCAN_CFLAGS="-I$ccandir/.."
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
24 AC_CACHE_CHECK([whether we can compile with __attribute__((cold))],
25 samba_cv_attribute_cold,
29 static void __attribute__((cold))
32 samba_cv_attribute_cold=yes)
35 if test x"$samba_cv_attribute_cold" = xyes ; then
36 AC_DEFINE(HAVE_ATTRIBUTE_COLD, 1,
37 [whether we can compile with __attribute__((cold))])
40 AC_CACHE_CHECK([whether we can compile with __attribute__((const))],
41 samba_cv_attribute_const,
45 static void __attribute__((const))
48 samba_cv_attribute_const=yes)
51 if test x"$samba_cv_attribute_const" = xyes ; then
52 AC_DEFINE(HAVE_ATTRIBUTE_CONST, 1,
53 [whether we can compile with __attribute__((const))])
56 AC_CACHE_CHECK([whether we can compile with __attribute__((noreturn))],
57 samba_cv_attribute_noreturn,
61 static void __attribute__((noreturn))
62 cleanup(void) { exit(1); }
64 samba_cv_attribute_noreturn=yes)
67 if test x"$samba_cv_attribute_noreturn" = xyes ; then
68 AC_DEFINE(HAVE_ATTRIBUTE_NORETURN, 1,
69 [whether we can compile with __attribute__((noreturn))])
72 AC_CACHE_CHECK([whether we can compile with __attribute__((printf))],
73 samba_cv_attribute_printf,
77 static void __attribute__((format(__printf__, 1, 2)))
78 cleanup(const char *fmt, ...) { }
80 samba_cv_attribute_printf=yes)
83 if test x"$samba_cv_attribute_printf" = xyes ; then
84 AC_DEFINE(HAVE_ATTRIBUTE_PRINTF, 1,
85 [whether we can compile with __attribute__((format(printf)))])
88 AC_CACHE_CHECK([whether we can compile with __attribute__((unused))],
89 samba_cv_attribute_unused,
93 static void __attribute__((unused))
96 samba_cv_attribute_unused=yes)
99 if test x"$samba_cv_attribute_unused" = xyes ; then
100 AC_DEFINE(HAVE_ATTRIBUTE_UNUSED, 1,
101 [whether we can compile with __attribute__((unused))])
104 AC_CACHE_CHECK([whether we can compile with __attribute__((used))],
105 samba_cv_attribute_used,
109 static void __attribute__((used))
112 samba_cv_attribute_used=yes)
115 if test x"$samba_cv_attribute_used" = xyes ; then
116 AC_DEFINE(HAVE_ATTRIBUTE_USED, 1,
117 [whether we can compile with __attribute__((used))])
120 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
122 AC_CACHE_CHECK([whether we are big endian],samba_cv_big_endian,[
123 AC_TRY_RUN([int main(void) {
124 union { int i; char c[sizeof(int)]; } u;
126 return u.c[0] == 0x01 && u.c[1] == 0x02 && u.c[2] == 0x03 && u.c[3] == 0x04 ? 0 : 1;
128 samba_cv_big_endian=yes,
129 samba_cv_big_endian=no)])
130 if test x"$samba_cv_big_endian" = xyes ; then
131 AC_DEFINE(HAVE_BIG_ENDIAN, 1,
132 [whether we are big endian])
135 AC_CACHE_CHECK([whether we have __builtin_clz],
136 samba_cv_builtin_clz,
140 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
142 samba_cv_builtin_clz=yes)
145 if test x"$samba_cv_builtin_clz" = xyes ; then
146 AC_DEFINE(HAVE_BUILTIN_CLZ, 1,
147 [whether we have __builtin_clz])
150 AC_CACHE_CHECK([whether we have __builtin_clzl],
151 samba_cv_builtin_clzl,
155 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
157 samba_cv_builtin_clzl=yes)
160 if test x"$samba_cv_builtin_clzl" = xyes ; then
161 AC_DEFINE(HAVE_BUILTIN_CLZL, 1,
162 [whether we have __builtin_clzl])
164 AC_CACHE_CHECK([whether we have __builtin_clzll],
165 samba_cv_builtin_clzll,
169 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
171 samba_cv_builtin_clzll=yes)
174 if test x"$samba_cv_builtin_clzll" = xyes ; then
175 AC_DEFINE(HAVE_BUILTIN_CLZLL, 1,
176 [whether we have __builtin_clzll])
179 AC_CACHE_CHECK([whether we have __builtin_constant_p],
180 samba_cv_builtin_constant_p,
184 return __builtin_constant_p(1) ? 0 : 1;
186 samba_cv_builtin_constant_p=yes)
189 if test x"$samba_cv_builtin_constant_p" = xyes ; then
190 AC_DEFINE(HAVE_BUILTIN_CONSTANT_P, 1,
191 [whether we have __builtin_constant_p])
194 AC_CACHE_CHECK([whether we have __builtin_expect],
195 samba_cv_builtin_expect,
199 return __builtin_expect(main != 0, 1) ? 0 : 1;
201 samba_cv_builtin_expect=yes)
204 if test x"$samba_cv_builtin_expect" = xyes ; then
205 AC_DEFINE(HAVE_BUILTIN_EXPECT, 1,
206 [whether we have __builtin_expect])
209 AC_CACHE_CHECK([whether we have __builtin_popcountl],
210 samba_cv_builtin_popcountl,
214 return __builtin_popcountl(255L) == 8 ? 0 : 1;
216 samba_cv_builtin_popcountl=yes)
219 if test x"$samba_cv_builtin_popcountl" = xyes ; then
220 AC_DEFINE(HAVE_BUILTIN_POPCOUNTL, 1,
221 [whether we have __builtin_popcountl])
224 AC_CACHE_CHECK([whether we have __builtin_types_compatible_p],
225 samba_cv_builtin_types_compatible_p,
229 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
231 samba_cv_builtin_types_compatible_p=yes)
234 if test x"$samba_cv_builtin_types_compatible_p" = xyes ; then
235 AC_DEFINE(HAVE_BUILTIN_TYPES_COMPATIBLE_P, 1,
236 [whether we have __builtin_types_compatible_p])
239 AC_CACHE_CHECK([whether we have __builtin_choose_expr],
240 samba_cv_builtin_choose_expr,
244 return __builtin_choose_expr(1, 0, "garbage");
246 samba_cv_builtin_choose_expr=yes)
249 if test x"$samba_cv_builtin_choose_expr" = xyes ; then
250 AC_DEFINE(HAVE_BUILTIN_CHOOSE_EXPR, 1,
251 [whether we have __builtin_choose_expr])
254 # We use @<:@ and @:>@ here for embedded [ and ].
255 AC_CACHE_CHECK([whether we have compound literals],
256 samba_cv_compound_literals,
260 int *foo = (int@<:@@:>@) { 1, 2, 3, 4 };
261 return foo@<:@0@:>@ == 1 ? 0 : 1;
263 samba_cv_compound_literals=yes)
266 if test x"$samba_cv_compound_literals" = xyes ; then
267 AC_DEFINE(HAVE_COMPOUND_LITERALS, 1,
268 [whether we have compound literals])
271 AC_CACHE_CHECK([whether we have __builtin_have_isblank],
272 samba_cv_builtin_have_isblank,
276 int main(void) { return isblank(' ') ? 0 : 1; }
278 samba_cv_builtin_have_isblank=yes)
281 if test x"$samba_cv_builtin_have_isblank" = xyes ; then
282 AC_DEFINE(HAVE_BUILTIN_HAVE_ISBLANK, 1,
283 [whether we have __builtin_have_isblank])
286 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
288 AC_CACHE_CHECK([whether we are little endian],samba_cv_little_endian,[
289 AC_TRY_RUN([int main(void) {
290 union { int i; char c[sizeof(int)]; } u;
292 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;
294 samba_cv_little_endian=yes,
295 samba_cv_little_endian=no)])
296 if test x"$samba_cv_little_endian" = xyes ; then
297 AC_DEFINE(HAVE_LITTLE_ENDIAN, 1,
298 [whether we are little endian])
301 AC_CACHE_CHECK([whether we have __typeof__],
309 return i == x ? 0 : 1;
314 if test x"$samba_cv_typeof" = xyes ; then
315 AC_DEFINE(HAVE_TYPEOF, 1,
316 [whether we have __typeof__])
319 AC_CACHE_CHECK([whether we have __attribute__((warn_unused_result))],
320 samba_cv_warn_unused_result,
323 [int __attribute__((warn_unused_result)) func(int x)
325 samba_cv_warn_unused_result=yes)
328 if test x"$samba_cv_warn_unused_result" = xyes ; then
329 AC_DEFINE(HAVE_WARN_UNUSED_RESULT, 1,
330 [whether we have __attribute__((warn_unused_result))])