7 opt.tool_options('compiler_cc')
8 opt.add_option('--disable-rpath',
9 help=("Disable use of rpath"),
10 action="store_true", dest='disable_rpath', default=False)
15 # load our local waf extensions
16 conf.check_tool('autoconf', tooldir='. ../replace')
19 conf.check_tool('compiler_cc')
20 conf.DEFUN('_GNU_SOURCE', 1)
21 conf.DEFUN('_XOPEN_SOURCE_EXTENDED', 1)
22 conf.DEFUN('LIBREPLACE_NETWORK_CHECKS', 1)
24 conf.CHECK_HEADERS('unistd.h sys/types.h stdlib.h stdio.h')
25 conf.CHECK_HEADERS('sys/wait.h sys/stat.h malloc.h grp.h')
26 conf.CHECK_HEADERS('crypt.h dlfcn.h dl.h standards.h stdbool.h stdint.h')
27 conf.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
28 conf.CHECK_HEADERS('sys/time.h time.h stdarg.h vararg.h sys/mount.h mntent.h')
29 conf.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
30 conf.CHECK_HEADERS('sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h')
31 conf.CHECK_HEADERS('netinet/ip.h netinet/tcp.h netinet/in_ip.h sys/sockio.h sys/un.h')
32 conf.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h')
33 conf.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
35 conf.check(type_name='long long')
36 conf.CHECK_TYPES('intptr_t uintptr_t ptrdiff_t')
37 conf.CHECK_TYPES('comparison_fn_t socklen_t bool')
39 conf.CHECK_TYPE('int8_t', 'char')
40 conf.CHECK_TYPE('int16_t', 'short')
41 conf.CHECK_TYPE('uint16_t', 'unsigned short')
42 conf.CHECK_TYPE('int32_t', 'int')
43 conf.CHECK_TYPE('uint32_t', 'unsigned')
44 conf.CHECK_TYPE('int64_t', 'long long')
45 conf.CHECK_TYPE('uint64_t', 'unsigned long long')
46 conf.CHECK_TYPE('size_t', 'unsigned int')
47 conf.CHECK_TYPE('ssize_t', 'int')
48 conf.CHECK_TYPE('ino_t', 'unsigned')
49 conf.CHECK_TYPE('loff_t', 'off_t')
50 conf.CHECK_TYPE('bool', 'off_t')
52 conf.CHECK_TYPE_IN('struct ifaddrs', 'ifaddrs.h')
53 conf.CHECK_TYPE_IN('struct addrinfo', 'netdb.h')
54 conf.CHECK_TYPE_IN('struct sockaddr', 'sys/socket.h')
56 conf.CHECK_FUNCS('shl_load shl_unload shl_findsym')
57 conf.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer')
58 conf.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setresuid setegid')
59 conf.CHECK_FUNCS('setresgid chroot bzero strerror vsyslog setlinebuf mktime')
60 conf.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat')
61 conf.CHECK_FUNCS('initgroups memmove strdup pread pwrite strndup strcasestr')
62 conf.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
63 conf.CHECK_FUNCS('link readlink symlink realpath fdatasync snprintf vsnprintf')
64 conf.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
65 conf.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memmem printf memset memcpy')
66 conf.CHECK_FUNCS('connect gethostbyname if_nametoindex socketpair')
67 conf.CHECK_FUNCS('inet_ntoa inet_ntop dirfd getdirentries getdents syslog')
68 conf.CHECK_FUNCS('timegm getifaddrs freeifaddrs')
70 conf.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl')
72 # we could also put code fragments like this in separate files,
73 # for example in test/snprintf.c
74 conf.check_cc(fragment='''
75 #include <sys/types.h>
79 void foo(const char *format, ...) {
83 long long l = 1234567890;
87 len = vsnprintf(buf, 0, format, ap);
89 if (len != 5) exit(1);
92 len = vsnprintf(0, 0, format, ap);
94 if (len != 5) exit(2);
96 if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(3);
98 if (snprintf(buf, 20, "%lld", l) != 12 || strcmp(buf, "123456789000") != 0) exit(4);
99 if (snprintf(buf, 20, "%zu", 123456789) != 9 || strcmp(buf, "123456789") != 0) exit(5);
100 if (snprintf(buf, 20, "%2\$d %1\$d", 3, 4) != 3 || strcmp(buf, "4 3") != 0) exit(6);
101 if (snprintf(buf, 20, "%s", 0) < 3) exit(7);
106 main() { foo("hello"); }
108 define_name="HAVE_C99_VSNPRINTF",
112 msg="Checking for C99 vsnprintf")
114 conf.write_config_header('config.h')
117 # the libreplace shared library
119 features = 'cc cshlib',
120 source = 'replace.c',
122 includes = '. default /usr/include')
126 features = 'cc cprogram',
127 source = '''test/testsuite.c test/main.c test/strptime.c
128 test/os2_delete.c test/getifaddrs.c''',
129 target = 'replace_testsuite',
130 uselib_local = 'replace',
131 includes = '. default /usr/include')