1 AC_CHECK_HEADERS([stdint.h inttypes.h])
2 AC_CHECK_TYPE(uint_t, unsigned int)
3 AC_CHECK_TYPE(uint8_t, unsigned char)
4 AC_CHECK_TYPE(int8_t, char)
5 AC_CHECK_TYPE(int16_t, short)
6 AC_CHECK_TYPE(uint16_t, unsigned short)
7 AC_CHECK_TYPE(int32_t, long)
8 AC_CHECK_TYPE(intptr_t, unsigned long long)
9 AC_CHECK_TYPE(uint32_t, unsigned long)
10 AC_CHECK_TYPE(ssize_t, int)
12 AC_CHECK_HEADERS(stdbool.h)
15 [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
24 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
27 #include <sys/types.h>
28 #include <netinet/in.h>
29 #ifdef HAVE_ARPA_INET_H
30 #include <arpa/inet.h>
32 main() { struct in_addr ip; ip.s_addr = 0x12345678;
33 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
34 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
36 samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
37 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
38 AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
41 dnl Provided by replace.c:
43 #include <sys/types.h>
48 #include <sys/socket.h>],
50 [AC_DEFINE(socklen_t, int,[Socket length type])])
52 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
53 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
54 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
55 AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
56 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
57 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
58 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
59 AC_HAVE_DECL(errno, [#include <errno.h>])
61 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
62 AC_TRY_RUN([#include <stdlib.h>
63 #include <sys/types.h>
68 char tpl[20]="/tmp/test.XXXXXX";
69 int fd = mkstemp(tpl);
70 if (fd == -1) exit(1);
72 if (fstat(fd, &st) != 0) exit(1);
73 if ((st.st_mode & 0777) != 0600) exit(1);
76 samba_cv_HAVE_SECURE_MKSTEMP=yes,
77 samba_cv_HAVE_SECURE_MKSTEMP=no,
78 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
79 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
80 AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
83 dnl Provided by snprintf.c:
84 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
85 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
86 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
87 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
88 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
89 AC_CHECK_HEADERS(strings.h)
91 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
93 #include <sys/types.h>
97 void foo(const char *format, ...) {
101 long long l = 1234567890;
104 va_start(ap, format);
105 len = vsnprintf(buf, 0, format, ap);
107 if (len != 5) exit(1);
109 va_start(ap, format);
110 len = vsnprintf(0, 0, format, ap);
112 if (len != 5) exit(2);
114 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
116 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
117 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
118 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
119 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
123 main() { foo("hello"); }
125 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
126 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
127 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
130 dnl Provided by dlfcn.c:
131 AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
132 SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
134 LIBS="$LIBS $DL_LIBS"
135 AC_CHECK_HEADERS(dlfcn.h)
136 AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
139 AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
140 [AC_MSG_ERROR([Required function not found])])
142 sinclude(lib/replace/getpass.m4)
145 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
146 AC_TRY_LINK([#include <stdarg.h>
147 va_list ap1,ap2;], [va_copy(ap1,ap2);],
148 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
149 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
150 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
153 if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
154 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
155 AC_TRY_LINK([#include <stdarg.h>
156 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
157 samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
158 if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
159 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
163 dnl __FUNCTION__ macro
164 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
165 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
166 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
167 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
168 AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
171 AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
172 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
173 samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
174 if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
175 AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
179 AC_CHECK_HEADERS([sys/param.h limits.h])
181 AC_CHECK_TYPE(comparison_fn_t,
182 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
184 AC_CHECK_FUNCS(timegm strnlen setenv)
185 AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
188 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
189 eprintf("bla", "bar");
190 ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])])
192 # Check prerequisites
193 AC_CHECK_FUNCS([memset printf syslog], [],
194 [ AC_MSG_ERROR([Required function not found])])
196 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
198 #include <sys/types.h>
203 #include <signal.h>],[sig_atomic_t i = 0],
204 samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
205 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
206 AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])