4 import Options, os, wafsamba
7 opt.tool_options('compiler_cc')
8 opt.add_option('--libdir',
9 help=("object code libraries [PREFIX/lib]"),
10 action="store", dest='LIBDIR', default=None)
11 opt.add_option('--bindir',
12 help=("user executables [PREFIX/bin]"),
13 action="store", dest='BINDIR', default=None)
14 opt.add_option('--sbindir',
15 help=("system admin executables [PREFIX/sbin]"),
16 action="store", dest='SBINDIR', default=None)
17 opt.add_option('--disable-rpath',
18 help=("Disable use of rpath"),
19 action="store_true", dest='disable_rpath', default=False)
25 # load our local waf extensions
26 conf.check_tool('wafsamba', tooldir=conf.curdir)
28 conf.CONFIG_PATH('LIBDIR', '/lib')
29 conf.CONFIG_PATH('BINDIR', '/bin')
30 conf.CONFIG_PATH('SBINDIR', '/sbin')
32 conf.check_tool('compiler_cc')
33 conf.DEFUN('_GNU_SOURCE', 1)
34 conf.DEFUN('_XOPEN_SOURCE_EXTENDED', 1)
35 conf.DEFUN('LIBREPLACE_NETWORK_CHECKS', 1)
37 conf.CHECK_HEADERS('unistd.h sys/types.h stdlib.h stdio.h stddef.h')
38 conf.CHECK_HEADERS('sys/wait.h sys/stat.h malloc.h grp.h')
39 conf.CHECK_HEADERS('crypt.h dlfcn.h dl.h standards.h stdbool.h stdint.h')
40 conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
41 conf.CHECK_HEADERS('sys/time.h time.h stdarg.h vararg.h sys/mount.h mntent.h')
42 conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
43 conf.CHECK_HEADERS('sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h')
44 conf.CHECK_HEADERS('netinet/ip.h netinet/tcp.h netinet/in_ip.h sys/sockio.h sys/un.h')
45 conf.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h')
46 conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
48 if 'HAVE_STDDEF_H' in conf.env and 'HAVE_STDLIB_H' in conf.env:
49 conf.DEFUN('STDC_HEADERS', 1)
51 conf.check(type_name='long long')
52 conf.CHECK_TYPES('intptr_t uintptr_t ptrdiff_t')
53 conf.CHECK_TYPES('comparison_fn_t socklen_t bool')
55 conf.CHECK_TYPE('int8_t', 'char')
56 conf.CHECK_TYPE('int16_t', 'short')
57 conf.CHECK_TYPE('uint16_t', 'unsigned short')
58 conf.CHECK_TYPE('int32_t', 'int')
59 conf.CHECK_TYPE('uint32_t', 'unsigned')
60 conf.CHECK_TYPE('int64_t', 'long long')
61 conf.CHECK_TYPE('uint64_t', 'unsigned long long')
62 conf.CHECK_TYPE('size_t', 'unsigned int')
63 conf.CHECK_TYPE('ssize_t', 'int')
64 conf.CHECK_TYPE('ino_t', 'unsigned')
65 conf.CHECK_TYPE('loff_t', 'off_t')
66 conf.CHECK_TYPE('bool', 'off_t')
68 conf.CHECK_TYPE_IN('struct ifaddrs', 'ifaddrs.h')
69 conf.CHECK_TYPE_IN('struct addrinfo', 'netdb.h')
70 conf.CHECK_TYPE_IN('struct sockaddr', 'sys/socket.h')
72 conf.CHECK_FUNCS('shl_load shl_unload shl_findsym')
73 conf.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer')
74 conf.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setresuid setegid')
75 conf.CHECK_FUNCS('setresgid chroot bzero strerror vsyslog setlinebuf mktime')
76 conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat')
77 conf.CHECK_FUNCS('initgroups memmove strdup pread pwrite strndup strcasestr')
78 conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
79 conf.CHECK_FUNCS('link readlink symlink realpath fdatasync snprintf vsnprintf')
80 conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
81 conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memmem printf memset memcpy')
82 conf.CHECK_FUNCS('connect gethostbyname if_nametoindex socketpair')
83 conf.CHECK_FUNCS('inet_ntoa inet_ntop dirfd getdirentries getdents syslog')
84 conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs')
86 conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl')
88 conf.check_cc(fragment='''
94 define_name="HAVE_VA_COPY",
99 msg="Checking for va_copy")
102 # we could also put code fragments like this in separate files,
103 # for example in test/snprintf.c
104 conf.check_cc(fragment='''
105 #include <sys/types.h>
109 void foo(const char *format, ...) {
113 long long l = 1234567890;
116 va_start(ap, format);
117 len = vsnprintf(buf, 0, format, ap);
119 if (len != 5) exit(1);
121 va_start(ap, format);
122 len = vsnprintf(0, 0, format, ap);
124 if (len != 5) exit(2);
126 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
128 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
129 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
130 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
131 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
136 main() { foo("hello"); }
138 define_name="HAVE_C99_VSNPRINTF",
142 msg="Checking for C99 vsnprintf")
144 conf.SAMBA_CONFIG_H()
149 REPLACE_SOURCE = 'replace.c snprintf.c'
151 bld.SAMBA_LIBRARY('replace',
154 TEST_SOURCES = '''test/testsuite.c test/main.c test/strptime.c
155 test/os2_delete.c test/getifaddrs.c'''
157 bld.SAMBA_BINARY('replace_testsuite',