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_CACHE_CHECK([whether we can compile with __attribute__((cold))],
27 samba_cv_attribute_cold,
29 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
31 static void __attribute__((cold))
34 samba_cv_attribute_cold=yes)
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,
45 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
47 static void __attribute__((const))
50 samba_cv_attribute_const=yes)
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,
61 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
63 static void __attribute__((noreturn))
64 cleanup(void) { exit(1); }
66 samba_cv_attribute_noreturn=yes)
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,
77 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
79 static void __attribute__((format(__printf__, 1, 2)))
80 cleanup(const char *fmt, ...) { }
82 samba_cv_attribute_printf=yes)
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,
93 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
95 static void __attribute__((unused))
98 samba_cv_attribute_unused=yes)
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,
109 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
111 static void __attribute__((used))
114 samba_cv_attribute_used=yes)
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
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;
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,
140 AC_LINK_IFELSE([AC_LANG_SOURCE(
142 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
144 samba_cv_builtin_clz=yes)
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,
155 AC_LINK_IFELSE([AC_LANG_SOURCE(
157 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
159 samba_cv_builtin_clzl=yes)
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,
169 AC_LINK_IFELSE([AC_LANG_SOURCE(
171 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
173 samba_cv_builtin_clzll=yes)
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,
184 AC_LINK_IFELSE([AC_LANG_SOURCE(
186 return __builtin_constant_p(1) ? 0 : 1;
188 samba_cv_builtin_constant_p=yes)
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,
199 AC_LINK_IFELSE([AC_LANG_SOURCE(
201 return __builtin_expect(main != 0, 1) ? 0 : 1;
203 samba_cv_builtin_expect=yes)
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,
214 AC_LINK_IFELSE([AC_LANG_SOURCE(
216 return __builtin_popcountl(255L) == 8 ? 0 : 1;
218 samba_cv_builtin_popcountl=yes)
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,
229 AC_LINK_IFELSE([AC_LANG_SOURCE(
231 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
233 samba_cv_builtin_types_compatible_p=yes)
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,
244 AC_LINK_IFELSE([AC_LANG_SOURCE(
246 return __builtin_choose_expr(1, 0, "garbage");
248 samba_cv_builtin_choose_expr=yes)
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,
260 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
262 int *foo = (int@<:@@:>@) { 1, 2, 3, 4 };
263 return foo@<:@0@:>@ == 1 ? 0 : 1;
265 samba_cv_compound_literals=yes)
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,
276 AC_LINK_IFELSE([AC_LANG_SOURCE(
278 int main(void) { return isblank(' ') ? 0 : 1; }
280 samba_cv_have_isblank=yes)
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
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;
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__],
306 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
311 return i == x ? 0 : 1;
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,
324 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
325 [int __attribute__((warn_unused_result)) func(int x)
327 samba_cv_warn_unused_result=yes)
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))])