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) ? 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_compound_literals],
240 samba_cv_builtin_compound_literals,
244 int *foo = (int[]) { 1, 2, 3, 4 };
245 return foo[0] == 1 ? 0 : 1;
247 samba_cv_builtin_compound_literals=yes)
250 if test x"$samba_cv_builtin_compound_literals" = xyes ; then
251 AC_DEFINE(HAVE_BUILTIN_COMPOUND_LITERALS, 1,
252 [whether we have __builtin_compound_literals])
255 AC_CACHE_CHECK([whether we have __builtin_have_isblank],
256 samba_cv_builtin_have_isblank,
260 int main(void) { return isblank(' ') ? 0 : 1; }
262 samba_cv_builtin_have_isblank=yes)
265 if test x"$samba_cv_builtin_have_isblank" = xyes ; then
266 AC_DEFINE(HAVE_BUILTIN_HAVE_ISBLANK, 1,
267 [whether we have __builtin_have_isblank])
270 # FIXME: We could use endian.h or sys/endian.h here, and __BYTE_ORDER for
272 AC_CACHE_CHECK([whether we are little endian],samba_cv_little_endian,[
273 AC_TRY_RUN([int main(void) {
274 union { int i; char c[sizeof(int)]; } u;
276 return u.c[0] == 0x04 && u.c[1] == 0x03 && u.c[2] == 0x02 && u.c[3] == 0x01 ? 0 : 1;
278 samba_cv_little_endian=yes,
279 samba_cv_little_endian=no)])
280 if test x"$samba_cv_little_endian" = xyes ; then
281 AC_DEFINE(HAVE_LITTLE_ENDIAN, 1,
282 [whether we are little endian])
285 AC_CACHE_CHECK([whether we have __typeof__],
293 return i == x ? 0 : 1;
298 if test x"$samba_cv_typeof" = xyes ; then
299 AC_DEFINE(HAVE_TYPEOF, 1,
300 [whether we have __typeof__])
303 AC_CACHE_CHECK([whether we have __attribute__((warn_unused_result))],
304 samba_cv_warn_unused_result,
307 [int __attribute__((warn_unused_result)) func(int x)
309 samba_cv_warn_unused_result=yes)
312 if test x"$samba_cv_warn_unused_result" = xyes ; then
313 AC_DEFINE(HAVE_WARN_UNUSED_RESULT, 1,
314 [whether we have __attribute__((warn_unused_result))])