1 AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS,
3 echo "LIBREPLACE_LOCATION_CHECKS: START"
5 dnl find the libreplace sources. This is meant to work both for
6 dnl libreplace standalone builds, and builds of packages using libreplace
8 for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
9 if test -f "$d/replace.c"; then
11 AC_SUBST(libreplacedir)
15 LIBREPLACEOBJ="replace.o"
16 AC_SUBST(LIBREPLACEOBJ)
22 echo "LIBREPLACE_LOCATION_CHECKS: END"
23 ]) dnl end AC_LIBREPLACE_LOCATION_CHECKS
26 AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS,
28 echo "LIBREPLACE_BROKEN_CHECKS: START"
30 dnl find the libreplace sources. This is meant to work both for
31 dnl libreplace standalone builds, and builds of packages using libreplace
33 for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
34 if test -f "$d/replace.c"; then
36 AC_SUBST(libreplacedir)
40 LIBREPLACEOBJ="replace.o"
41 AC_SUBST(LIBREPLACEOBJ)
43 LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o"
52 AC_CHECK_TYPE(ino_t,unsigned)
53 AC_CHECK_TYPE(loff_t,off_t)
54 AC_CHECK_TYPE(offset_t,loff_t)
58 AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
60 AC_CHECK_HEADERS(stdbool.h sys/select.h)
62 AC_CHECK_HEADERS(sys/epoll.h)
63 AC_CHECK_FUNCS(epoll_create)
66 [AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
75 [AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],,
83 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
84 AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"],
85 samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
86 if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
87 AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
91 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
92 AC_CHECK_HEADERS(sys/time.h time.h)
93 AC_CHECK_HEADERS(stdarg.h vararg.h)
94 AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
95 AC_CHECK_HEADERS(netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
96 AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
99 dnl we need to check that net/if.h really can be used, to cope with hpux
100 dnl where including it always fails
111 #if HAVE_SYS_SOCKET_H
112 # include <sys/socket.h>
114 [#include <net/if.h>],
115 AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h))
118 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
122 #include <sys/types.h>
123 #include <netinet/in.h>
124 #ifdef HAVE_ARPA_INET_H
125 #include <arpa/inet.h>
127 main() { struct in_addr ip; ip.s_addr = 0x12345678;
128 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
129 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
131 samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
132 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
133 AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
136 dnl Provided by replace.c:
138 #include <sys/types.h>
143 #include <sys/socket.h>],
145 [AC_DEFINE(socklen_t, int,[Socket length type])])
147 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
148 AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
149 AC_CHECK_FUNCS(waitpid strlcpy strlcat innetgr initgroups memmove strdup)
150 AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp)
151 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
152 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
153 AC_HAVE_DECL(errno, [#include <errno.h>])
155 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
156 AC_TRY_RUN([#include <stdlib.h>
157 #include <sys/types.h>
158 #include <sys/stat.h>
162 char tpl[20]="/tmp/test.XXXXXX";
163 int fd = mkstemp(tpl);
164 if (fd == -1) exit(1);
166 if (fstat(fd, &st) != 0) exit(1);
167 if ((st.st_mode & 0777) != 0600) exit(1);
170 samba_cv_HAVE_SECURE_MKSTEMP=yes,
171 samba_cv_HAVE_SECURE_MKSTEMP=no,
172 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
173 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
174 AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
177 dnl Provided by snprintf.c:
178 AC_CHECK_HEADERS(stdio.h strings.h)
179 AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf])
180 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
182 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
184 #include <sys/types.h>
188 void foo(const char *format, ...) {
192 long long l = 1234567890;
195 va_start(ap, format);
196 len = vsnprintf(buf, 0, format, ap);
198 if (len != 5) exit(1);
200 va_start(ap, format);
201 len = vsnprintf(0, 0, format, ap);
203 if (len != 5) exit(2);
205 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
207 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
208 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
209 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
210 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
214 main() { foo("hello"); }
216 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
217 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
218 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
222 LIBREPLACE_C99_STRUCT_INIT(c99_struct_initialization=yes,
223 c99_struct_initialization=no)
226 AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
227 AC_TRY_LINK([#include <stdarg.h>
228 va_list ap1,ap2;], [va_copy(ap1,ap2);],
229 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
230 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
231 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
234 if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
235 AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
236 AC_TRY_LINK([#include <stdarg.h>
237 va_list ap1,ap2;], [__va_copy(ap1,ap2);],
238 samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
239 if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
240 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
244 dnl __FUNCTION__ macro
245 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
246 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
247 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
248 if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
249 AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
252 AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
253 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
254 samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
255 if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
256 AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
260 AC_CHECK_HEADERS([sys/param.h limits.h])
262 AC_CHECK_TYPE(comparison_fn_t,
263 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
265 AC_CHECK_FUNCS(strnlen setenv)
266 AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
268 # this test disabled as we don't actually need __VA_ARGS__ yet
270 # #define eprintf(...) fprintf(stderr, __VA_ARGS__)
271 # eprintf("bla", "bar");
272 # ], [], [AC_MSG_ERROR([__VA_ARGS__ is required])])
274 # Check prerequisites
275 AC_CHECK_FUNCS([memset printf syslog], [],
276 [ AC_MSG_ERROR([Required function not found])])
278 AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
280 #include <sys/types.h>
285 #include <signal.h>],[sig_atomic_t i = 0],
286 samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
287 if test x"$samba_cv_sig_atomic_t" = x"yes"; then
288 AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
292 AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[
298 [int fd = open("/dev/null", O_DIRECT);],
299 samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
300 if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
301 AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
305 AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
306 dnl Check whether the compiler can generate precompiled headers
308 if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
309 precompiled_headers=yes
311 precompiled_headers=no
313 AC_SUBST(precompiled_headers)
316 dnl Check if the C compiler understands volatile (it should, being ANSI).
317 AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
318 AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
319 samba_cv_volatile=yes,samba_cv_volatile=no)])
320 if test x"$samba_cv_volatile" = x"yes"; then
321 AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
324 m4_include(system/config.m4)
327 m4_include(getpass.m4)
329 m4_include(timegm.m4)
330 m4_include(repdir.m4)
332 AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
333 [AC_MSG_ERROR([Required function not found])])
335 echo "LIBREPLACE_BROKEN_CHECKS: END"
336 ]) dnl end AC_LIBREPLACE_BROKEN_CHECKS
338 AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START,
340 #LIBREPLACE_ALL_CHECKS: START"
342 AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END,
344 #LIBREPLACE_ALL_CHECKS: END"
346 m4_define(AC_LIBREPLACE_ALL_CHECKS,
348 AC__LIBREPLACE_ALL_CHECKS_START
349 AC_LIBREPLACE_LOCATION_CHECKS
350 AC_LIBREPLACE_CC_CHECKS
351 AC_LIBREPLACE_BROKEN_CHECKS
352 AC__LIBREPLACE_ALL_CHECKS_END
355 m4_include(libreplace_cc.m4)
356 m4_include(libreplace_macros.m4)
357 m4_include(autoconf-2.60.m4)