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_HEADERS(sys/time.h time.h)
54 AC_CHECK_HEADERS(sys/socket.h netinet/in.h)
55 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
56 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
57 AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
58 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
59 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
60 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
61 AC_HAVE_DECL(errno, [#include <errno.h>])
63 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
64 AC_TRY_RUN([#include <stdlib.h>
65 #include <sys/types.h>
70 char tpl[20]="/tmp/test.XXXXXX";
71 int fd = mkstemp(tpl);
72 if (fd == -1) exit(1);
74 if (fstat(fd, &st) != 0) exit(1);
75 if ((st.st_mode & 0777) != 0600) exit(1);
78 samba_cv_HAVE_SECURE_MKSTEMP=yes,
79 samba_cv_HAVE_SECURE_MKSTEMP=no,
80 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
81 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
82 AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
85 dnl Provided by snprintf.c:
86 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
87 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
88 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
89 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
90 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
91 AC_CHECK_HEADERS(strings.h)
93 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
95 #include <sys/types.h>
99 void foo(const char *format, ...) {
103 long long l = 1234567890;
106 va_start(ap, format);
107 len = vsnprintf(buf, 0, format, ap);
109 if (len != 5) exit(1);
111 va_start(ap, format);
112 len = vsnprintf(0, 0, format, ap);
114 if (len != 5) exit(2);
116 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
118 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
119 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
120 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
121 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
125 main() { foo("hello"); }
127 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
128 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
129 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
132 dnl Provided by dlfcn.c:
133 AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
134 SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
136 LIBS="$LIBS $DL_LIBS"
137 AC_CHECK_HEADERS(dlfcn.h)
138 AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
141 AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
142 [AC_MSG_ERROR([Required function not found])])
144 sinclude(lib/replace/getpass.m4)
146 sinclude(lib/replace/cc_features.m4)
147 sinclude(cc_features.m4)
149 LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes,
150 c99_struct_initialization=no)
153 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
154 AC_TRY_LINK([#include <stdarg.h>
155 va_list ap1,ap2;], [va_copy(ap1,ap2);],
156 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
157 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
158 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
161 if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
162 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
163 AC_TRY_LINK([#include <stdarg.h>
164 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
165 samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
166 if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
167 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
171 dnl __FUNCTION__ macro
172 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
173 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
174 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
175 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
176 AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
179 AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
180 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
181 samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
182 if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
183 AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
187 AC_CHECK_HEADERS([sys/param.h limits.h])
189 AC_CHECK_TYPE(comparison_fn_t,
190 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
192 AC_CHECK_FUNCS(timegm strnlen setenv)
193 AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
195 # this test disabled as we don't actually need __VA_ARGS__ yet
197 # #define eprintf(...) fprintf(stderr, __VA_ARGS__)
198 # eprintf("bla", "bar");
199 # ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])])
201 # Check prerequisites
202 AC_CHECK_FUNCS([memset printf syslog], [],
203 [ AC_MSG_ERROR([Required function not found])])
205 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
207 #include <sys/types.h>
212 #include <signal.h>],[sig_atomic_t i = 0],
213 samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
214 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
215 AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])