source: branches/samba-3.0/source/lib/replace/libreplace.m4

Last change on this file was 312, checked in by Herwig Bauernfeind, 16 years ago

Update 3.0 to final 3.0.36 (source)

File size: 11.3 KB
Line 
1AC_DEFUN_ONCE(AC_LIBREPLACE_LOCATION_CHECKS,
2[
3echo "LIBREPLACE_LOCATION_CHECKS: START"
4
5dnl find the libreplace sources. This is meant to work both for
6dnl libreplace standalone builds, and builds of packages using libreplace
7libreplacedir=""
8libreplacepaths="$srcdir $srcdir/lib/replace $srcdir/libreplace $srcdir/../libreplace $srcdir/../replace"
9for d in $libreplacepaths; do
10 if test -f "$d/replace.c"; then
11 libreplacedir="$d"
12 AC_SUBST(libreplacedir)
13 break;
14 fi
15done
16if test x"$libreplacedir" = "x"; then
17 AC_MSG_ERROR([cannot find libreplace in $libreplacepaths])
18fi
19LIBREPLACEOBJ="replace.o"
20AC_SUBST(LIBREPLACEOBJ)
21
22AC_CANONICAL_BUILD
23AC_CANONICAL_HOST
24AC_CANONICAL_TARGET
25
26echo "LIBREPLACE_LOCATION_CHECKS: END"
27]) dnl end AC_LIBREPLACE_LOCATION_CHECKS
28
29
30AC_DEFUN_ONCE(AC_LIBREPLACE_BROKEN_CHECKS,
31[
32echo "LIBREPLACE_BROKEN_CHECKS: START"
33
34dnl find the libreplace sources. This is meant to work both for
35dnl libreplace standalone builds, and builds of packages using libreplace
36libreplacedir=""
37for d in "$srcdir" "$srcdir/lib/replace" "$srcdir/libreplace" "$srcdir/../libreplace" "$srcdir/../replace"; do
38 if test -f "$d/replace.c"; then
39 libreplacedir="$d"
40 AC_SUBST(libreplacedir)
41 break;
42 fi
43done
44LIBREPLACEOBJ="replace.o"
45AC_SUBST(LIBREPLACEOBJ)
46
47LIBREPLACEOBJ="${LIBREPLACEOBJ} snprintf.o"
48
49AC_TYPE_SIGNAL
50AC_TYPE_UID_T
51AC_TYPE_MODE_T
52AC_TYPE_OFF_T
53AC_TYPE_SIZE_T
54AC_TYPE_PID_T
55AC_STRUCT_ST_RDEV
56AC_CHECK_TYPE(ino_t,unsigned)
57AC_CHECK_TYPE(loff_t,off_t)
58AC_CHECK_TYPE(offset_t,loff_t)
59
60AC_FUNC_MEMCMP
61
62AC_CHECK_FUNCS(pipe strftime srandom random srand rand usleep setbuffer lstat getpgrp)
63
64AC_CHECK_HEADERS(stdbool.h stdint.h sys/select.h)
65AC_CHECK_HEADERS(setjmp.h)
66
67LIBREPLACE_PROVIDE_HEADER([stdint.h])
68LIBREPLACE_PROVIDE_HEADER([stdbool.h])
69
70AC_CHECK_TYPE(bool,
71[AC_DEFINE(HAVE_BOOL, 1, [Whether the bool type is available])],,
72[
73AC_INCLUDES_DEFAULT
74#ifdef HAVE_STDBOOL_H
75#include <stdbool.h>
76#endif]
77)
78
79AC_CHECK_TYPE(_Bool,
80[AC_DEFINE(HAVE__Bool, 1, [Whether the _Bool type is available])],,
81[
82AC_INCLUDES_DEFAULT
83#ifdef HAVE_STDBOOL_H
84#include <stdbool.h>
85#endif]
86)
87
88AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
89AC_TRY_RUN([#include "$libreplacedir/test/shared_mmap.c"],
90 samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
91if test x"$samba_cv_HAVE_MMAP" = x"yes"; then
92 AC_DEFINE(HAVE_MMAP,1,[Whether mmap works])
93fi
94
95
96AC_CHECK_HEADERS(sys/syslog.h syslog.h)
97AC_CHECK_HEADERS(sys/time.h time.h)
98AC_CHECK_HEADERS(stdarg.h vararg.h)
99AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
100AC_CHECK_HEADERS(netinet/in_systm.h)
101AC_CHECK_HEADERS([netinet/ip.h], [], [], [#ifdef HAVE_NETINET_IN_H
102#include <netinet/in.h>
103#endif
104#ifdef HAVE_NETINET_IN_SYSTM_H
105#include <netinet/in_systm.h>
106#endif])
107AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h)
108AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
109AC_CHECK_HEADERS(stropts.h)
110
111dnl we need to check that net/if.h really can be used, to cope with hpux
112dnl where including it always fails
113AC_CACHE_CHECK([for usable net/if.h],libreplace_cv_USABLE_NET_IF_H,[
114 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
115 AC_INCLUDES_DEFAULT
116 #if HAVE_SYS_SOCKET_H
117 # include <sys/socket.h>
118 #endif
119 #include <net/if.h>
120 int main(void) {return 0;}])],
121 [libreplace_cv_USABLE_NET_IF_H=yes],
122 [libreplace_cv_USABLE_NET_IF_H=no]
123 )
124])
125if test x"$libreplace_cv_USABLE_NET_IF_H" = x"yes";then
126 AC_DEFINE(HAVE_NET_IF_H, 1, usability of net/if.h)
127fi
128
129AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
130AC_TRY_RUN([
131#include <stdio.h>
132#include <unistd.h>
133#include <sys/types.h>
134#include <netinet/in.h>
135#ifdef HAVE_ARPA_INET_H
136#include <arpa/inet.h>
137#endif
138main() { struct in_addr ip; ip.s_addr = 0x12345678;
139if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
140 strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); }
141exit(1);}],
142 samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
143if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
144 AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
145fi
146
147dnl Provided by replace.c:
148AC_TRY_COMPILE([
149#include <sys/types.h>
150#if STDC_HEADERS
151#include <stdlib.h>
152#include <stddef.h>
153#endif
154#include <sys/socket.h>],
155[socklen_t foo;],,
156[AC_DEFINE(socklen_t, int,[Socket length type])])
157
158AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
159AC_CHECK_FUNCS(vsyslog setlinebuf mktime ftruncate chsize rename)
160AC_CHECK_FUNCS(waitpid strlcpy strlcat initgroups memmove strdup)
161AC_CHECK_FUNCS(pread pwrite strndup strcasestr strtok_r mkdtemp socketpair)
162AC_HAVE_DECL(setresuid, [#include <unistd.h>])
163AC_HAVE_DECL(setresgid, [#include <unistd.h>])
164AC_HAVE_DECL(errno, [#include <errno.h>])
165
166AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
167AC_TRY_RUN([#include <stdlib.h>
168#include <sys/types.h>
169#include <sys/stat.h>
170#include <unistd.h>
171main() {
172 struct stat st;
173 char tpl[20]="/tmp/test.XXXXXX";
174 int fd = mkstemp(tpl);
175 if (fd == -1) exit(1);
176 unlink(tpl);
177 if (fstat(fd, &st) != 0) exit(1);
178 if ((st.st_mode & 0777) != 0600) exit(1);
179 exit(0);
180}],
181samba_cv_HAVE_SECURE_MKSTEMP=yes,
182samba_cv_HAVE_SECURE_MKSTEMP=no,
183samba_cv_HAVE_SECURE_MKSTEMP=cross)])
184if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
185 AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
186fi
187
188dnl Provided by snprintf.c:
189AC_CHECK_HEADERS(stdio.h strings.h)
190AC_CHECK_DECLS([snprintf, vsnprintf, asprintf, vasprintf])
191AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
192
193AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
194AC_TRY_RUN([
195#include <sys/types.h>
196#include <stdio.h>
197#include <stdarg.h>
198#include <stdlib.h>
199void foo(const char *format, ...) {
200 va_list ap;
201 int len;
202 char buf[20];
203 long long l = 1234567890;
204 l *= 100;
205
206 va_start(ap, format);
207 len = vsnprintf(buf, 0, format, ap);
208 va_end(ap);
209 if (len != 5) exit(1);
210
211 va_start(ap, format);
212 len = vsnprintf(0, 0, format, ap);
213 va_end(ap);
214 if (len != 5) exit(2);
215
216 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
217
218 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
219 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
220 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
221 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
222
223 exit(0);
224}
225main() { foo("hello"); }
226],
227samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
228if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
229 AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
230fi
231
232
233dnl VA_COPY
234AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
235AC_TRY_LINK([#include <stdarg.h>
236va_list ap1,ap2;], [va_copy(ap1,ap2);],
237samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
238if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
239 AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
240fi
241
242if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
243AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
244AC_TRY_LINK([#include <stdarg.h>
245va_list ap1,ap2;], [__va_copy(ap1,ap2);],
246samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
247if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
248 AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
249fi
250fi
251
252dnl __FUNCTION__ macro
253AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
254AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
255samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
256if test x"$samba_cv_HAVE_FUNCTION_MACRO" = x"yes"; then
257 AC_DEFINE(HAVE_FUNCTION_MACRO,1,[Whether there is a __FUNCTION__ macro])
258else
259 dnl __func__ macro
260 AC_CACHE_CHECK([for __func__ macro],samba_cv_HAVE_func_MACRO,[
261 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __func__);],
262 samba_cv_HAVE_func_MACRO=yes,samba_cv_HAVE_func_MACRO=no)])
263 if test x"$samba_cv_HAVE_func_MACRO" = x"yes"; then
264 AC_DEFINE(HAVE_func_MACRO,1,[Whether there is a __func__ macro])
265 fi
266fi
267
268AC_CHECK_HEADERS([sys/param.h limits.h])
269
270AC_CHECK_TYPE(comparison_fn_t,
271[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
272
273AC_HAVE_DECL(setenv, [#include <stdlib.h>])
274AC_CHECK_FUNCS(setenv unsetenv)
275
276AC_CHECK_FUNCS(strnlen)
277AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
278
279# this test disabled as we don't actually need __VA_ARGS__ yet
280AC_TRY_CPP([
281#define eprintf(...) fprintf(stderr, __VA_ARGS__)
282eprintf("bla", "bar");
283], AC_DEFINE(HAVE__VA_ARGS__MACRO, 1, [Whether the __VA_ARGS__ macro is available]))
284
285# Check prerequisites
286AC_CHECK_FUNCS([memset printf syslog], [],
287 [ AC_MSG_ERROR([Required function not found])])
288
289AC_CACHE_CHECK([for sig_atomic_t type],samba_cv_sig_atomic_t, [
290 AC_TRY_COMPILE([
291#include <sys/types.h>
292#if STDC_HEADERS
293#include <stdlib.h>
294#include <stddef.h>
295#endif
296#include <signal.h>],[sig_atomic_t i = 0],
297 samba_cv_sig_atomic_t=yes,samba_cv_sig_atomic_t=no)])
298if test x"$samba_cv_sig_atomic_t" = x"yes"; then
299 AC_DEFINE(HAVE_SIG_ATOMIC_T_TYPE,1,[Whether we have the atomic_t variable type])
300fi
301
302
303AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[
304AC_TRY_COMPILE([
305#include <unistd.h>
306#ifdef HAVE_FCNTL_H
307#include <fcntl.h>
308#endif],
309[int fd = open("/dev/null", O_DIRECT);],
310samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
311if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
312 AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
313fi
314
315
316AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
317 dnl Check whether the compiler can generate precompiled headers
318 touch conftest.h
319 if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
320 precompiled_headers=yes
321 else
322 precompiled_headers=no
323 fi])
324AC_SUBST(precompiled_headers)
325
326
327dnl Check if the C compiler understands volatile (it should, being ANSI).
328AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
329 AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
330 samba_cv_volatile=yes,samba_cv_volatile=no)])
331if test x"$samba_cv_volatile" = x"yes"; then
332 AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
333fi
334
335m4_include(system/config.m4)
336
337m4_include(dlfcn.m4)
338m4_include(getpass.m4)
339m4_include(strptime.m4)
340m4_include(win32.m4)
341m4_include(timegm.m4)
342m4_include(repdir.m4)
343
344AC_CHECK_FUNCS([syslog memset memcpy],,[AC_MSG_ERROR([Required function not found])])
345
346echo "LIBREPLACE_BROKEN_CHECKS: END"
347]) dnl end AC_LIBREPLACE_BROKEN_CHECKS
348
349AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_START,
350[
351#LIBREPLACE_ALL_CHECKS: START"
352])
353AC_DEFUN_ONCE(AC__LIBREPLACE_ALL_CHECKS_END,
354[
355#LIBREPLACE_ALL_CHECKS: END"
356])
357m4_define(AC_LIBREPLACE_ALL_CHECKS,
358[
359AC__LIBREPLACE_ALL_CHECKS_START
360AC_LIBREPLACE_LOCATION_CHECKS
361AC_LIBREPLACE_CC_CHECKS
362AC_LIBREPLACE_BROKEN_CHECKS
363AC__LIBREPLACE_ALL_CHECKS_END
364])
365
366m4_include(libreplace_cc.m4)
367m4_include(libreplace_macros.m4)
368m4_include(autoconf-2.60.m4)
Note: See TracBrowser for help on using the repository browser.