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_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,
31 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
33 static void __attribute__((cold))
36 samba_cv_attribute_cold=yes)
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,
47 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
49 static void __attribute__((const))
52 samba_cv_attribute_const=yes)
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,
63 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
65 static void __attribute__((noreturn))
66 cleanup(void) { exit(1); }
68 samba_cv_attribute_noreturn=yes)
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,
79 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
81 static void __attribute__((format(__printf__, 1, 2)))
82 cleanup(const char *fmt, ...) { }
84 samba_cv_attribute_printf=yes)
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,
95 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
97 static void __attribute__((unused))
100 samba_cv_attribute_unused=yes)
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,
111 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
113 static void __attribute__((used))
116 samba_cv_attribute_used=yes)
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
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;
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,
142 AC_LINK_IFELSE([AC_LANG_SOURCE(
144 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
146 samba_cv_builtin_clz=yes)
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,
157 AC_LINK_IFELSE([AC_LANG_SOURCE(
159 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
161 samba_cv_builtin_clzl=yes)
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,
171 AC_LINK_IFELSE([AC_LANG_SOURCE(
173 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
175 samba_cv_builtin_clzll=yes)
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,
186 AC_LINK_IFELSE([AC_LANG_SOURCE(
188 return __builtin_constant_p(1) ? 0 : 1;
190 samba_cv_builtin_constant_p=yes)
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,
201 AC_LINK_IFELSE([AC_LANG_SOURCE(
203 return __builtin_expect(main != 0, 1) ? 0 : 1;
205 samba_cv_builtin_expect=yes)
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,
216 AC_LINK_IFELSE([AC_LANG_SOURCE(
218 return __builtin_popcountl(255L) == 8 ? 0 : 1;
220 samba_cv_builtin_popcountl=yes)
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,
231 AC_LINK_IFELSE([AC_LANG_SOURCE(
233 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
235 samba_cv_builtin_types_compatible_p=yes)
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,
246 AC_LINK_IFELSE([AC_LANG_SOURCE(
248 return __builtin_choose_expr(1, 0, "garbage");
250 samba_cv_builtin_choose_expr=yes)
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,
262 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
264 int *foo = (int@<:@@:>@) { 1, 2, 3, 4 };
265 return foo@<:@0@:>@ == 1 ? 0 : 1;
267 samba_cv_compound_literals=yes)
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,
278 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
279 [struct foo { unsigned int x; int arr@<:@@:>@; }; ])],
280 samba_cv_have_flex_arr_member=yes)
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,
291 AC_LINK_IFELSE([AC_LANG_SOURCE(
293 int main(void) { return isblank(' ') ? 0 : 1; }
295 samba_cv_have_isblank=yes)
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
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;
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__],
321 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
326 return i == x ? 0 : 1;
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,
339 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
340 [int __attribute__((warn_unused_result)) func(int x)
342 samba_cv_warn_unused_result=yes)
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>])