7 sys
.path
.insert(0, srcdir
+"/buildtools/wafsamba")
9 import Options
, os
, preproc
12 opt
.tool_options('compiler_cc')
13 # TODO: we are not yet obeying these default paths at install time
14 opt
.add_option('--libdir',
15 help=("object code libraries [PREFIX/lib"),
16 action
="store", dest
='LIBDIR', default
='${PREFIX}/lib')
17 opt
.add_option('--bindir',
18 help=("user executables [PREFIX/bin]"),
19 action
="store", dest
='BINDIR', default
='${PREFIX}/bin')
20 opt
.add_option('--sbindir',
21 help=("system admin executables [PREFIX/sbin]"),
22 action
="store", dest
='SBINDIR', default
='${PREFIX}/sbin')
23 opt
.add_option('--enable-rpath',
24 help=("Enable use of rpath for installed binaries"),
25 action
="store_true", dest
='enable_rpath', default
=False)
26 opt
.add_option('--enable-developer',
27 help=("Turn on developer warnings and debugging"),
28 action
="store_true", dest
='developer', default
=False)
29 opt
.add_option('--enable-gccdeps',
30 help=("Enable use gcc -MD dependency module"),
31 action
="store_true", dest
='enable_gccdeps', default
=False)
32 opt
.add_option('--timestamp-dependencies',
33 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
34 action
="store_true", dest
='timestamp_dependencies', default
=False)
35 opt
.add_option('-C', action
='store_true', help='dummy option for autoconf compatibility')
36 opt
.add_option('--pedantic',
37 help=("Enable even more compiler warnings"),
38 action
='store_true', dest
='pedantic', default
=False)
43 conf
.env
.srcdir
= conf
.srcdir
45 # during the configure checks we want the waf dependency checker
46 # to go into system includes. This ensures that if you add/remove
47 # a system library, that 'waf configure' will detect that, and
48 # it won't be fooled by the waf cache
49 preproc
.go_absolute
= True
51 if Options
.options
.timestamp_dependencies
:
52 conf
.ENABLE_TIMESTAMP_DEPENDENCIES()
54 # load our local waf extensions
55 conf
.check_tool('wafsamba', tooldir
=conf
.srcdir
+ "/buildtools/wafsamba")
57 # trim whitespaces from 'CC'.
58 # The build farm sometimes puts a space at the start
59 if os
.environ
.get('CC'):
60 conf
.env
['CC'] = os
.environ
.get('CC').strip()
61 os
.environ
['CC'] = conf
.env
['CC']
63 conf
.check_tool('compiler_cc')
65 if Options
.options
.enable_gccdeps
:
66 # don't enable gccdeps by default as it needs a very recent version gcc
67 conf
.check_tool('gccdeps', tooldir
=conf
.srcdir
+ "/buildtools/wafsamba")
69 # make the install paths available in environment
70 conf
.env
.LIBDIR
= Options
.options
.LIBDIR
71 conf
.env
.BINDIR
= Options
.options
.BINDIR
72 conf
.env
.SBINDIR
= Options
.options
.SBINDIR
74 conf
.env
.RPATH_ON_INSTALL
= Options
.options
.enable_rpath
76 # we should use the PIC options in waf instead
77 conf
.ADD_CFLAGS('-fPIC')
80 conf
.check_cfg(atleast_pkgconfig_version
='0.0.0')
82 conf
.DEFINE('_GNU_SOURCE', 1, add_to_cflags
=True)
83 conf
.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags
=True)
84 conf
.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
86 conf
.CHECK_HEADERS('unistd.h sys/types.h stdlib.h stdio.h stddef.h')
87 conf
.CHECK_HEADERS('ctype.h locale.h acl/libacl.h compat.h')
88 conf
.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
89 conf
.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
90 conf
.CHECK_HEADERS('libaio.h locale.h ndir.h net/if.h pwd.h readline.h')
91 conf
.CHECK_HEADERS('readline/history.h readline/readline.h shadow.h sys/acl.h')
92 conf
.CHECK_HEADERS('sys/attributes.h sys/capability.h sys/dir.h sys/epoll.h')
93 conf
.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h sys/fs/vx/quota.h')
94 conf
.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
95 conf
.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
96 conf
.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h')
97 conf
.CHECK_HEADERS('sys/wait.h sys/stat.h malloc.h grp.h')
98 conf
.CHECK_HEADERS('crypt.h dlfcn.h dl.h standards.h stdbool.h stdint.h')
99 conf
.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
100 conf
.CHECK_HEADERS('sys/time.h time.h stdarg.h vararg.h sys/mount.h mntent.h')
101 conf
.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
102 conf
.CHECK_HEADERS('sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h')
103 conf
.CHECK_HEADERS('netinet/ip.h netinet/tcp.h netinet/in_ip.h sys/sockio.h sys/un.h')
104 conf
.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h')
105 conf
.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
106 conf
.CHECK_HEADERS('resolv.h libintl.h errno.h')
107 conf
.CHECK_HEADERS('gcrypt.h getopt.h iconv.h')
108 conf
.CHECK_HEADERS('sys/inotify.h memory.h nss.h popt.h sasl/sasl.h')
109 conf
.CHECK_HEADERS('security/pam_appl.h sys/inotify.h zlib.h asm/unistd.h')
110 conf
.CHECK_HEADERS('aio.h sys/unistd.h rpc/rpc.h rpc/nettype.h alloca.h float.h')
112 conf
.CHECK_HEADERS('rpcsvc/nis.h rpcsvc/ypclnt.h sys/prctl.h sys/sysctl.h', add_headers
=False)
113 conf
.CHECK_HEADERS('sys/fileio.h sys/filesys.h sys/dustat.h sys/sysmacros.h', add_headers
=False)
114 conf
.CHECK_HEADERS('xfs/libxfs.h netgroup.h rpcsvc/yp_prot.h', add_headers
=False)
115 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h', add_headers
=False)
116 conf
.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h', add_headers
=False)
117 conf
.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h', add_headers
=False)
118 conf
.CHECK_HEADERS('utmp.h utmpx.h lastlog.h', add_headers
=False)
120 if 'HAVE_STDDEF_H' in conf
.env
and 'HAVE_STDLIB_H' in conf
.env
:
121 conf
.DEFINE('STDC_HEADERS', 1)
123 if 'HAVE_SYS_TIME_H' in conf
.env
and 'HAVE_TIME_H' in conf
.env
:
124 conf
.DEFINE('TIME_WITH_SYS_TIME', 1)
126 conf
.define('SHLIBEXT', "so", quote
=True)
128 conf
.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t')
129 conf
.CHECK_TYPES('comparison_fn_t socklen_t bool')
130 conf
.CHECK_TYPE('_Bool', define
='HAVE__Bool')
132 conf
.CHECK_TYPE('int8_t', 'char')
133 conf
.CHECK_TYPE('int16_t', 'short')
134 conf
.CHECK_TYPE('uint16_t', 'unsigned short')
135 conf
.CHECK_TYPE('int32_t', 'int')
136 conf
.CHECK_TYPE('uint32_t', 'unsigned')
137 conf
.CHECK_TYPE('int64_t', 'long long')
138 conf
.CHECK_TYPE('uint64_t', 'unsigned long long')
139 conf
.CHECK_TYPE('size_t', 'unsigned int')
140 conf
.CHECK_TYPE('ssize_t', 'int')
141 conf
.CHECK_TYPE('ino_t', 'unsigned')
142 conf
.CHECK_TYPE('loff_t', 'off_t')
143 conf
.CHECK_TYPE('bool', 'off_t')
144 conf
.CHECK_TYPE('offset_t', 'loff_t')
145 conf
.CHECK_TYPE('volatile int', define
='HAVE_VOLATILE')
147 conf
.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
149 define
='WORDS_BIGENDIAN')
152 conf
.CHECK_TYPE_IN('struct ifaddrs', 'ifaddrs.h')
153 conf
.CHECK_TYPE_IN('struct addrinfo', 'netdb.h')
154 conf
.CHECK_TYPE_IN('struct sockaddr', 'sys/socket.h')
155 conf
.CHECK_CODE('struct sockaddr_in6 x', define
='HAVE_STRUCT_SOCKADDR_IN6')
156 conf
.CHECK_TYPE_IN('struct sockaddr_storage', 'sys/socket.h')
157 conf
.CHECK_TYPE_IN('sa_family_t', 'sys/socket.h')
159 conf
.CHECK_TYPE_IN('sig_atomic_t', 'signal.h', define
='HAVE_SIG_ATOMIC_T_TYPE')
162 struct sockaddr_storage sa_store;
163 struct addrinfo *ai = NULL;
164 struct in6_addr in6addr;
165 int idx = if_nametoindex("iface1");
166 int s = socket(AF_INET6, SOCK_STREAM, 0);
167 int ret = getaddrinfo(NULL, NULL, NULL, &ai);
169 const char *es = gai_strerror(ret);
175 # check if signal() takes a void function
176 if conf
.CHECK_CODE('return *(signal (0, 0)) (0) == 1', define
='RETSIGTYPE_INT', msg
='Checking return type of signal handlers'):
177 conf
.DEFINE('RETSIGTYPE', 'int')
179 conf
.DEFINE('RETSIGTYPE', 'void')
181 conf
.CHECK_FUNCS('shl_load shl_unload shl_findsym')
182 conf
.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer')
183 conf
.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setresuid setegid')
184 conf
.CHECK_FUNCS('setresgid chroot bzero strerror vsyslog setlinebuf mktime')
185 conf
.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat')
186 conf
.CHECK_FUNCS('initgroups memmove strdup pread pwrite strndup strcasestr')
187 conf
.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
188 conf
.CHECK_FUNCS('link readlink symlink realpath fdatasync snprintf vsnprintf')
189 conf
.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
190 conf
.CHECK_FUNCS('strtouq strtoll __strtoll strtoq memmem printf memset memcpy')
191 conf
.CHECK_FUNCS('connect gethostbyname if_nametoindex socketpair')
192 conf
.CHECK_FUNCS('inet_ntoa inet_aton inet_ntop inet_pton')
193 conf
.CHECK_FUNCS('dirfd getdirentries getdents syslog getaddrinfo freeaddrinfo')
194 conf
.CHECK_FUNCS('gai_strerror get_current_dir_name')
195 conf
.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups setsid')
196 conf
.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
197 conf
.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
200 conf
.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl', checklibc
=True)
201 conf
.CHECK_FUNCS_IN('poptGetContext', 'popt')
202 conf
.CHECK_FUNCS_IN('res_search', 'resolv', checklibc
=True)
203 conf
.CHECK_FUNCS_IN('gettext', 'intl', checklibc
=True)
204 conf
.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc
=True)
206 conf
.CHECK_FUNCS_IN('crypt', 'crypt', checklibc
=True)
208 conf
.CHECK_VARIABLE('rl_event_hook', define
='HAVE_DECL_RL_EVENT_HOOK', always
=True)
210 conf
.CHECK_VARIABLE('__FUNCTION__', define
='HAVE_FUNCTION_MACRO')
212 conf
.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')
214 conf
.CHECK_DECLS('dirfd environ errno getgrent_r getpwent_r', reverse
=True)
215 conf
.CHECK_DECLS('pread pwrite setenv setresgid setresuid', reverse
=True)
217 conf
.CHECK_SIZEOF('char int "long long" long off_t short size_t ssize_t')
218 conf
.CHECK_SIZEOF('void*', define
='SIZEOF_VOID_P')
220 if conf
.CONFIG_SET('HAVE_EPOLL_CREATE') and conf
.CONFIG_SET('HAVE_SYS_EPOLL_H'):
221 conf
.DEFINE('HAVE_EPOLL', 1)
223 conf
.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
224 define
="HAVE_VA_COPY",
225 msg
="Checking for va_copy")
228 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
229 eprintf("bla", "bar")
230 ''', define
='HAVE__VA_ARGS__MACRO')
232 conf
.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute
=False)
234 conf
.CHECK_CODE('#include "test/snprintf.c"',
235 define
="HAVE_C99_VSNPRINTF",
238 msg
="Checking for C99 vsnprintf")
240 if Options
.options
.pedantic
:
241 conf
.ADD_CFLAGS('-W')
243 if Options
.options
.developer
:
244 conf
.ADD_CFLAGS('-Wall -g -Wfatal-errors -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Werror-implicit-function-declaration -Wformat=2 -Wno-format-y2k')
246 conf
.SAMBA_CONFIG_H()
247 conf
.SAMBA_BUILD_ENV()
249 # look for a method of finding the list of network interfaces
250 for method
in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
251 if conf
.CHECK_CODE('''
253 #define NO_CONFIG_H 1
254 #define AUTOCONF_TEST 1
255 #define SOCKET_WRAPPER_NOT_REPLACE
257 #include "inet_ntop.c"
258 #include "snprintf.c"
259 #include "getifaddrs.c"
260 #define getifaddrs_test main
261 #include "test/getifaddrs.c"
269 typedef struct {unsigned x;} FOOBAR;
270 #define X_FOOBAR(x) ((FOOBAR) { x })
271 #define FOO_ONE X_FOOBAR(1)
273 static const struct {
278 static const FOOBAR f3[] = {FOO_ONE};
280 define
='HAVE_IMMEDIATE_STRUCTURES')
282 conf
.CHECK_CODE('mkdir("foo",0777)', define
='HAVE_MKDIR_MODE')
284 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec', define
='HAVE_STAT_TV_NSEC')
285 # we need the st_rdev test under two names
286 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define
='HAVE_STRUCT_STAT_ST_RDEV')
287 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define
='HAVE_ST_RDEV')
288 conf
.CHECK_STRUCTURE_MEMBER('struct sockaddr_storage', 'ss_family')
290 conf
.CHECK_CODE('struct sockaddr_un sunaddr; sunaddr.sun_family = AF_UNIX;',
291 define
='HAVE_UNIXSOCKET')
296 char tpl[20]="/tmp/test.XXXXXX";
297 int fd = mkstemp(tpl);
298 if (fd == -1) exit(1);
300 if (fstat(fd, &st) != 0) exit(1);
301 if ((st.st_mode & 0777) != 0600) exit(1);
304 define
='HAVE_SECURE_MKSTEMP',
306 mandatory
=True) # lets see if we get a mandatory failure for this one
308 if conf
.CHECK_CFLAGS('-fvisibility=hidden', 'VISIBILITY_CFLAGS'):
309 conf
.CHECK_CODE('''void vis_foo1(void) {}
310 __attribute__((visibility("default"))) void vis_foo2(void) {}''',
311 cflags
=conf
.env
.VISIBILITY_CFLAGS
,
312 define
='HAVE_VISIBILITY_ATTR')
314 if conf
.CHECK_FUNCS('getpass getpassphrase'):
315 # if we have both, then we prefer getpassphrase
316 conf
.DEFINE('REPLACE_GETPASS_BY_GETPASSPHRASE', 1)
317 conf
.DEFINE('REPLACE_GETPASS', 1)
319 conf
.CHECK_CODE('''#include "getpass.c"
320 int main(void) { return 0; }''',
322 define
='REPLACE_GETPASS',
323 cflags
='-DNO_CONFIG_H')
328 # libreplace needs to put the library in the right build groups
329 # as libreplace is a base library for everything, even for our
330 # compilers, we need libreplace to build very early
331 bld
.SETUP_BUILD_GROUPS()
333 REPLACE_SOURCE
= 'replace.c snprintf.c'
335 bld
.SAMBA_LIBRARY('replace',
336 source
=REPLACE_SOURCE
,
337 group
='base_libraries',
338 deps
='LIBREPLACE_GETPASS')
340 TEST_SOURCES
= '''test/testsuite.c test/main.c test/strptime.c
341 test/os2_delete.c test/getifaddrs.c'''
343 bld
.SAMBA_BINARY('replace_testsuite',
349 if bld
.CONFIG_SET('HAVE_INET_NTOA'): NET_SOURCES
.append('inet_ntoa.c')
350 if bld
.CONFIG_SET('HAVE_INET_ATON'): NET_SOURCES
.append('inet_aton.c')
351 if bld
.CONFIG_SET('HAVE_INET_NTOP'): NET_SOURCES
.append('inet_ntop.c')
352 if bld
.CONFIG_SET('HAVE_INET_PTON'): NET_SOURCES
.append('inet_pton.c')
353 if bld
.CONFIG_SET('HAVE_SOCKETPAIR'): NET_SOURCES
.append('socketpair.c')
355 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_NETWORK', NET_SOURCES
, deps
='replace')
359 if not 'HAVE_CRYPT' in bld
.env
: CRYPT_SOURCES
.append('crypt.c')
361 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_EXT', CRYPT_SOURCES
)
363 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_GETPASS', 'getpass.c',
364 enabled
=bld
.CONFIG_SET('REPLACE_GETPASS'))
366 bld
.CHECK_PROJECT_RULES()