]> git.samba.org - amitay/samba.git/blob - source4/lib/replace/config.m4
3c11ac14761b935ee9590737c126b04ab76da57b
[amitay/samba.git] / source4 / lib / replace / config.m4
1 AC_CHECK_HEADERS([stdint.h inttypes.h])
2 AC_CHECK_TYPE(uint_t, unsigned int)
3 AC_CHECK_TYPE(int8_t, signed char)
4 AC_CHECK_TYPE(uint8_t, unsigned 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(uint32_t, unsigned long)
9 AC_CHECK_TYPE(int64_t, long long)
10 AC_CHECK_TYPE(uint64_t, unsigned long long)
11 AC_CHECK_TYPE(u_int32_t, unsigned long)
12 AC_CHECK_TYPE(u_int16_t, unsigned short)
13 AC_CHECK_TYPE(u_int8_t, unsigned char)
14 AC_CHECK_TYPE(ssize_t, int)
15 AC_CHECK_TYPE(comparison_fn_t, 
16 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
17
18 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
19 AC_TRY_RUN([
20 #include <stdio.h>
21 #include <sys/types.h>
22 #include <netinet/in.h>
23 #ifdef HAVE_ARPA_INET_H
24 #include <arpa/inet.h>
25 #endif
26 main() { struct in_addr ip; ip.s_addr = 0x12345678;
27 if (strcmp(inet_ntoa(ip),"18.52.86.120") &&
28     strcmp(inet_ntoa(ip),"120.86.52.18")) { exit(0); } 
29 exit(1);}],
30            samba_cv_REPLACE_INET_NTOA=yes,samba_cv_REPLACE_INET_NTOA=no,samba_cv_REPLACE_INET_NTOA=cross)])
31 if test x"$samba_cv_REPLACE_INET_NTOA" = x"yes"; then
32     AC_DEFINE(REPLACE_INET_NTOA,1,[Whether inet_ntoa should be replaced])
33 fi
34
35 dnl Provided by replace.c:
36 AC_TRY_COMPILE([
37 #include <sys/types.h>
38 #if STDC_HEADERS
39 #include <stdlib.h>
40 #include <stddef.h>
41 #endif
42 #include <sys/socket.h>], 
43 [socklen_t foo;],,
44 [AC_DEFINE(socklen_t, int,[Socket length type])])
45
46 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
47 AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
48 AC_CHECK_FUNCS(seteuid setresuid setegid setresgid chroot bzero strerror)
49 AC_CHECK_FUNCS(timegm setenv vsyslog setlinebuf mktime ftruncate chsize rename)
50 AC_CHECK_FUNCS(waitpid strnlen strlcpy strlcat innetgr initgroups memmove strdup)
51 AC_CHECK_FUNCS(pread pwrite strndup strcasestr)
52 AC_HAVE_DECL(setresuid, [#include <unistd.h>])
53 AC_HAVE_DECL(setresgid, [#include <unistd.h>])
54 AC_HAVE_DECL(errno, [#include <errno.h>])
55
56 AC_CACHE_CHECK([for secure mkstemp],samba_cv_HAVE_SECURE_MKSTEMP,[
57 AC_TRY_RUN([#include <stdlib.h>
58 #include <sys/types.h>
59 #include <sys/stat.h>
60 #include <unistd.h>
61 main() { 
62   struct stat st;
63   char tpl[20]="/tmp/test.XXXXXX"; 
64   int fd = mkstemp(tpl); 
65   if (fd == -1) exit(1);
66   unlink(tpl);
67   if (fstat(fd, &st) != 0) exit(1);
68   if ((st.st_mode & 0777) != 0600) exit(1);
69   exit(0);
70 }],
71 samba_cv_HAVE_SECURE_MKSTEMP=yes,
72 samba_cv_HAVE_SECURE_MKSTEMP=no,
73 samba_cv_HAVE_SECURE_MKSTEMP=cross)])
74 if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
75     AC_DEFINE(HAVE_SECURE_MKSTEMP,1,[Whether mkstemp is secure])
76 fi
77
78 dnl Provided by snprintf.c:
79 AC_HAVE_DECL(asprintf, [#include <stdio.h>])
80 AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
81 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
82 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
83 AC_CHECK_FUNCS(snprintf vsnprintf asprintf vasprintf)
84
85 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
86 AC_TRY_RUN([
87 #include <sys/types.h>
88 #include <stdarg.h>
89 void foo(const char *format, ...) { 
90        va_list ap;
91        int len;
92        char buf[20];
93        long long l = 1234567890;
94        l *= 100;
95
96        va_start(ap, format);
97        len = vsnprintf(buf, 0, format, ap);
98        va_end(ap);
99        if (len != 5) exit(1);
100
101        va_start(ap, format);
102        len = vsnprintf(0, 0, format, ap);
103        va_end(ap);
104        if (len != 5) exit(1);
105
106        if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
107
108        if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(1);
109
110        exit(0);
111 }
112 main() { foo("hello"); }
113 ],
114 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
115 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
116     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
117 fi
118
119 dnl Provided by dlfcn.c:
120 AC_SEARCH_LIBS_EXT(dlopen, [dl], DL_LIBS)
121 SMB_EXT_LIB(DL,[${DL_LIBS}],[${DL_CFLAGS}],[${DL_CPPFLAGS}],[${DL_LDFLAGS}])
122 SAVE_LIBS="$LIBS"
123 LIBS="$LIBS $DL_LIBS"
124 AC_CHECK_HEADERS(dlfcn.h)
125 AC_CHECK_FUNCS(dlopen dlsym dlerror dlclose)
126 LIBS="$SAVE_LIBS"
127
128 AC_CHECK_FUNCS([syslog memset setnetgrent getnetgrent endnetgrent memcpy],,
129                            [AC_MSG_ERROR([Required function not found])])
130
131 AC_CHECK_HEADERS(stdbool.h)
132
133 sinclude(lib/replace/readline.m4)
134 sinclude(lib/replace/getpass.m4)