s3:libsmb: check the wct of the incoming SMBnegprot responses
[Samba.git] / lib / ccan / libccan.m4
blobdf38d3b962dc21074ebe78065e1a62f42db46eac
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_CACHE_CHECK([whether we can compile with __attribute__((cold))],
25                samba_cv_attribute_cold,
26                [
27                  AC_COMPILE_IFELSE(
28                         [
29                                 static void __attribute__((cold))
30                                 cleanup(void) { }
31                         ],
32                         samba_cv_attribute_cold=yes)
33                 ])
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,
42                [
43                  AC_COMPILE_IFELSE(
44                         [
45                                 static void __attribute__((const))
46                                 cleanup(void) { }
47                         ],
48                         samba_cv_attribute_const=yes)
49                 ])
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,
58                [
59                  AC_COMPILE_IFELSE(
60                         [
61                                 static void __attribute__((noreturn))
62                                 cleanup(void) { exit(1); }
63                         ],
64                         samba_cv_attribute_noreturn=yes)
65                 ])
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,
74                [
75                  AC_COMPILE_IFELSE(
76                         [
77                                 static void __attribute__((format(__printf__, 1, 2)))
78                                 cleanup(const char *fmt, ...) { }
79                         ],
80                         samba_cv_attribute_printf=yes)
81                 ])
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,
90                [
91                  AC_COMPILE_IFELSE(
92                         [
93                                 static void __attribute__((unused))
94                                 cleanup(void) { }
95                         ],
96                         samba_cv_attribute_unused=yes)
97                 ])
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,
106                [
107                  AC_COMPILE_IFELSE(
108                         [
109                                 static void __attribute__((used))
110                                 cleanup(void) { }
111                         ],
112                         samba_cv_attribute_used=yes)
113                 ])
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
121 # cross-compiling.
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;
125           u.i = 0x01020304;
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,
137                [
138                  AC_LINK_IFELSE(
139                         [int main(void) {
140                                 return __builtin_clz(1) == (sizeof(int)*8 - 1) ? 0 : 1;
141                         }],
142                         samba_cv_builtin_clz=yes)
143                 ])
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,
152                [
153                  AC_LINK_IFELSE(
154                         [int main(void) {
155                                 return __builtin_clzl(1) == (sizeof(int)*8 - 1) ? 0 : 1;
156                         }],
157                         samba_cv_builtin_clzl=yes)
158                 ])
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,
166                [
167                  AC_LINK_IFELSE(
168                         [int main(void) {
169                                 return __builtin_clzll(1) == (sizeof(int)*8 - 1) ? 0 : 1;
170                         }],
171                         samba_cv_builtin_clzll=yes)
172                 ])
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,
181                [
182                  AC_LINK_IFELSE(
183                         [int main(void) {
184                                 return __builtin_constant_p(1) ? 0 : 1;
185                         }],
186                         samba_cv_builtin_constant_p=yes)
187                 ])
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,
196                [
197                  AC_LINK_IFELSE(
198                         [int main(void) {
199                                 return __builtin_expect(main != 0) ? 0 : 1;
200                         }],
201                         samba_cv_builtin_expect=yes)
202                 ])
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,
211                [
212                  AC_LINK_IFELSE(
213                         [int main(void) {
214                                 return __builtin_popcountl(255L) == 8 ? 0 : 1;
215                         }],
216                         samba_cv_builtin_popcountl=yes)
217                 ])
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,
226                [
227                  AC_LINK_IFELSE(
228                         [int main(void) {
229                                 return __builtin_types_compatible_p(char *, int) ? 1 : 0;
230                         }],
231                         samba_cv_builtin_types_compatible_p=yes)
232                 ])
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,
241                [
242                  AC_COMPILE_IFELSE(
243                         [int main(void) {
244                                 int *foo = (int[]) { 1, 2, 3, 4 };
245                                 return foo[0] == 1 ? 0 : 1;
246                         }],
247                         samba_cv_builtin_compound_literals=yes)
248                 ])
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,
257                [
258                  AC_LINK_IFELSE(
259                         [#include <ctype.h>
260                          int main(void) { return isblank(' ') ? 0 : 1; }
261                         ],
262                         samba_cv_builtin_have_isblank=yes)
263                 ])
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
271 # cross-compiling.
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;
275           u.i = 0x01020304;
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__],
286                samba_cv_typeof,
287                [
288                  AC_COMPILE_IFELSE(
289                         [int main(void) {
290                                 int x = 1;
291                                 __typeof__(x) i;
292                                 i = x;
293                                 return i == x ? 0 : 1;
294                         }],
295                         samba_cv_typeof=yes)
296                 ])
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,
305                [
306                  AC_COMPILE_IFELSE(
307                         [int __attribute__((warn_unused_result)) func(int x)
308                             { return x; }],
309                         samba_cv_warn_unused_result=yes)
310                 ])
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))])