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('--disable-shared',
24 help=("Disable all use of shared libraries"),
25 action
="store_true", dest
='disable_shared', default
=False)
26 opt
.add_option('--disable-rpath',
27 help=("Disable use of rpath for build binaries"),
28 action
="store_true", dest
='disable_rpath_build', default
=False)
29 opt
.add_option('--disable-rpath-install',
30 help=("Disable use of rpath for installed binaries"),
31 action
="store_true", dest
='disable_rpath_install', default
=False)
32 opt
.add_option('--enable-developer',
33 help=("Turn on developer warnings and debugging"),
34 action
="store_true", dest
='developer', default
=False)
35 opt
.add_option('--enable-gccdeps',
36 help=("Enable use gcc -MD dependency module"),
37 action
="store_true", dest
='enable_gccdeps', default
=False)
38 opt
.add_option('--timestamp-dependencies',
39 help=("use file timestamps instead of content for build dependencies (BROKEN)"),
40 action
="store_true", dest
='timestamp_dependencies', default
=False)
42 help='enable configure cacheing',
43 action
='store_true', dest
='enable_configure_cache')
44 opt
.add_option('--pedantic',
45 help=("Enable even more compiler warnings"),
46 action
='store_true', dest
='pedantic', default
=False)
51 conf
.env
.srcdir
= conf
.srcdir
53 if Options
.options
.timestamp_dependencies
:
54 conf
.ENABLE_TIMESTAMP_DEPENDENCIES()
56 conf
.SETUP_CONFIGURE_CACHE(Options
.options
.enable_configure_cache
)
58 # load our local waf extensions
59 conf
.check_tool('wafsamba', tooldir
=conf
.srcdir
+ "/buildtools/wafsamba")
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
.DISABLE_SHARED
= Options
.options
.disable_shared
76 # see if we can compile and run a simple C program
77 conf
.CHECK_CODE('#include "test/simple.c"\n',
79 define
='HAVE_SIMPLE_C_PROG',
82 msg
='Checking simple C program')
85 if not conf
.env
.DISABLE_SHARED
and conf
.CHECK_RPATH_SUPPORT():
86 conf
.env
.RPATH_ON_BUILD
= not Options
.options
.disable_rpath_build
87 conf
.env
.RPATH_ON_INSTALL
= (conf
.env
.RPATH_ON_BUILD
and
88 not Options
.options
.disable_rpath_install
)
90 conf
.env
.RPATH_ON_INSTALL
= False
91 conf
.env
.RPATH_ON_BUILD
= False
93 # we should use the PIC options in waf instead
94 conf
.ADD_CFLAGS('-fPIC')
97 conf
.check_cfg(atleast_pkgconfig_version
='0.0.0')
99 conf
.DEFINE('_GNU_SOURCE', 1, add_to_cflags
=True)
100 conf
.DEFINE('_XOPEN_SOURCE_EXTENDED', 1, add_to_cflags
=True)
101 conf
.DEFINE('LIBREPLACE_NETWORK_CHECKS', 1)
103 # get the base headers we'll use for the rest of the tests
104 conf
.CHECK_HEADERS('stdio.h sys/types.h sys/stat.h stdlib.h stddef.h memory.h string.h',
106 conf
.CHECK_HEADERS('strings.h inttypes.h stdint.h unistd.h minix/config.h', add_headers
=True)
107 conf
.CHECK_HEADERS('ctype.h standards.h stdbool.h stdint.h stdarg.h vararg.h', add_headers
=True)
109 # see if we need special largefile flags
110 conf
.CHECK_LARGEFILE()
112 conf
.CHECK_HEADERS('crypt.h locale.h acl/libacl.h compat.h')
113 conf
.CHECK_HEADERS('acl/libacl.h attr/xattr.h compat.h ctype.h dustat.h')
114 conf
.CHECK_HEADERS('fcntl.h fnmatch.h glob.h history.h krb5.h langinfo.h')
115 conf
.CHECK_HEADERS('libaio.h locale.h ndir.h pwd.h')
116 conf
.CHECK_HEADERS('shadow.h sys/acl.h')
117 conf
.CHECK_HEADERS('sys/attributes.h sys/capability.h sys/dir.h sys/epoll.h')
118 conf
.CHECK_HEADERS('sys/fcntl.h sys/filio.h sys/filsys.h sys/fs/s5param.h sys/fs/vx/quota.h')
119 conf
.CHECK_HEADERS('sys/id.h sys/ioctl.h sys/ipc.h sys/mman.h sys/mode.h sys/ndir.h sys/priv.h')
120 conf
.CHECK_HEADERS('sys/resource.h sys/security.h sys/shm.h sys/statfs.h sys/statvfs.h sys/termio.h')
121 conf
.CHECK_HEADERS('sys/vfs.h sys/xattr.h termio.h termios.h')
122 conf
.CHECK_HEADERS('sys/wait.h sys/stat.h malloc.h grp.h')
123 conf
.CHECK_HEADERS('sys/select.h setjmp.h utime.h sys/syslog.h syslog.h')
124 conf
.CHECK_HEADERS('sys/time.h time.h stdarg.h vararg.h sys/mount.h mntent.h')
125 conf
.CHECK_HEADERS('stropts.h unix.h string.h strings.h sys/param.h limits.h')
126 conf
.CHECK_HEADERS('''sys/socket.h netinet/in.h netdb.h arpa/inet.h netinet/in_systm.h
127 netinet/ip.h netinet/tcp.h netinet/in_ip.h
128 sys/sockio.h sys/un.h''', together
=True)
129 conf
.CHECK_HEADERS('sys/uio.h ifaddrs.h direct.h dirent.h')
130 conf
.CHECK_HEADERS('windows.h winsock2.h ws2tcpip.h')
131 conf
.CHECK_HEADERS('libintl.h errno.h')
132 conf
.CHECK_HEADERS('gcrypt.h getopt.h iconv.h')
133 conf
.CHECK_HEADERS('sys/inotify.h memory.h nss.h popt.h sasl/sasl.h')
134 conf
.CHECK_HEADERS('security/pam_appl.h sys/inotify.h zlib.h asm/unistd.h')
135 conf
.CHECK_HEADERS('aio.h sys/unistd.h rpc/rpc.h rpc/nettype.h alloca.h float.h')
137 conf
.CHECK_HEADERS('rpcsvc/nis.h rpcsvc/ypclnt.h sys/prctl.h sys/sysctl.h', add_headers
=False)
138 conf
.CHECK_HEADERS('sys/fileio.h sys/filesys.h sys/dustat.h sys/sysmacros.h', add_headers
=False)
139 conf
.CHECK_HEADERS('xfs/libxfs.h netgroup.h rpcsvc/yp_prot.h', add_headers
=False)
140 conf
.CHECK_HEADERS('valgrind.h valgrind/valgrind.h valgrind/memcheck.h', add_headers
=False)
141 conf
.CHECK_HEADERS('nss_common.h nsswitch.h ns_api.h', add_headers
=False)
142 conf
.CHECK_HEADERS('sys/extattr.h sys/ea.h sys/proplist.h sys/cdefs.h', add_headers
=False)
143 conf
.CHECK_HEADERS('utmp.h utmpx.h lastlog.h', add_headers
=False)
144 conf
.CHECK_HEADERS('syscall.h sys/syscall.h', add_headers
=False)
146 if 'HAVE_STDDEF_H' in conf
.env
and 'HAVE_STDLIB_H' in conf
.env
:
147 conf
.DEFINE('STDC_HEADERS', 1)
149 if 'HAVE_SYS_TIME_H' in conf
.env
and 'HAVE_TIME_H' in conf
.env
:
150 conf
.DEFINE('TIME_WITH_SYS_TIME', 1)
152 conf
.define('SHLIBEXT', "so", quote
=True)
154 conf
.CHECK_TYPES('"long long" intptr_t uintptr_t ptrdiff_t')
155 conf
.CHECK_TYPES('comparison_fn_t bool')
156 conf
.CHECK_TYPE('_Bool', define
='HAVE__Bool')
158 conf
.CHECK_TYPE('int8_t', 'char')
159 conf
.CHECK_TYPE('int16_t', 'short')
160 conf
.CHECK_TYPE('uint16_t', 'unsigned short')
161 conf
.CHECK_TYPE('int32_t', 'int')
162 conf
.CHECK_TYPE('uint32_t', 'unsigned')
163 conf
.CHECK_TYPE('int64_t', 'long long')
164 conf
.CHECK_TYPE('uint64_t', 'unsigned long long')
165 conf
.CHECK_TYPE('size_t', 'unsigned int')
166 conf
.CHECK_TYPE('ssize_t', 'int')
167 conf
.CHECK_TYPE('ino_t', 'unsigned')
168 conf
.CHECK_TYPE('loff_t', 'off_t')
169 conf
.CHECK_TYPE('bool', 'off_t')
170 conf
.CHECK_TYPE('offset_t', 'loff_t')
171 conf
.CHECK_TYPE('volatile int', define
='HAVE_VOLATILE')
173 conf
.CHECK_CODE('long one = 1; return ((char *)(&one))[0]',
175 define
='WORDS_BIGENDIAN')
178 conf
.CHECK_TYPES('socklen_t', headers
='sys/socket.h')
179 conf
.CHECK_TYPE_IN('struct ifaddrs', 'ifaddrs.h')
180 conf
.CHECK_TYPE_IN('struct addrinfo', 'netdb.h')
181 conf
.CHECK_TYPE_IN('struct sockaddr', 'sys/socket.h')
182 conf
.CHECK_CODE('struct sockaddr_in6 x', define
='HAVE_STRUCT_SOCKADDR_IN6',
183 headers
='sys/socket.h netdb.h netinet/in.h')
184 conf
.CHECK_TYPE_IN('struct sockaddr_storage', 'sys/socket.h')
185 conf
.CHECK_TYPE_IN('sa_family_t', 'sys/socket.h')
187 conf
.CHECK_TYPE_IN('sig_atomic_t', 'signal.h', define
='HAVE_SIG_ATOMIC_T_TYPE')
189 conf
.CHECK_FUNCS_IN('''inet_ntoa inet_aton inet_ntop inet_pton connect gethostbyname
190 getaddrinfo getnameinfo freeaddrinfo gai_strerror socketpair''',
191 'socket nsl', checklibc
=True,
192 headers
='sys/socket.h netinet/in.h arpa/inet.h netdb.h')
195 struct sockaddr_storage sa_store;
196 struct addrinfo *ai = NULL;
197 struct in6_addr in6addr;
198 int idx = if_nametoindex("iface1");
199 int s = socket(AF_INET6, SOCK_STREAM, 0);
200 int ret = getaddrinfo(NULL, NULL, NULL, &ai);
202 const char *es = gai_strerror(ret);
208 headers
='sys/socket.h netdb.h netinet/in.h')
210 # check if signal() takes a void function
211 if conf
.CHECK_CODE('return *(signal (0, 0)) (0) == 1', define
='RETSIGTYPE_INT', msg
='Checking return type of signal handlers'):
212 conf
.DEFINE('RETSIGTYPE', 'int')
214 conf
.DEFINE('RETSIGTYPE', 'void')
216 # these may be builtins, so we need the link=False strategy
217 conf
.CHECK_FUNCS('strdup memmem printf memset memcpy memmove strcpy strncpy bzero', link
=False)
219 conf
.CHECK_FUNCS('shl_load shl_unload shl_findsym')
220 conf
.CHECK_FUNCS('pipe strftime srandom random srand rand usleep setbuffer')
221 conf
.CHECK_FUNCS('lstat getpgrp utime utimes seteuid setresuid setegid')
222 conf
.CHECK_FUNCS('setresgid chroot strerror vsyslog setlinebuf mktime')
223 conf
.CHECK_FUNCS('ftruncate chsize rename waitpid wait4 strlcpy strlcat')
224 conf
.CHECK_FUNCS('initgroups pread pwrite strndup strcasestr')
225 conf
.CHECK_FUNCS('strtok_r mkdtemp dup2 dprintf vdprintf isatty chown lchown')
226 conf
.CHECK_FUNCS('link readlink symlink realpath fdatasync snprintf vsnprintf')
227 conf
.CHECK_FUNCS('asprintf vasprintf setenv unsetenv strnlen strtoull __strtoull')
228 conf
.CHECK_FUNCS('strtouq strtoll __strtoll strtoq')
229 conf
.CHECK_FUNCS('if_nametoindex')
230 conf
.CHECK_FUNCS('dirfd getdirentries getdents syslog')
231 conf
.CHECK_FUNCS('gai_strerror get_current_dir_name')
232 conf
.CHECK_FUNCS('timegm getifaddrs freeifaddrs mmap setgroups setsid')
233 conf
.CHECK_FUNCS('getgrent_r getgrgid_r getgrnam_r getgrouplist getpagesize')
234 conf
.CHECK_FUNCS('getpwent_r getpwnam_r getpwuid_r epoll_create')
236 conf
.CHECK_FUNCS_IN('dlopen dlsym dlerror dlclose', 'dl',
237 checklibc
=True, headers
='dlfcn.h dl.h')
238 conf
.CHECK_FUNCS_IN('poptGetContext', 'popt')
240 # these headers need to be tested as a group on freebsd
241 conf
.CHECK_HEADERS(headers
='sys/socket.h net/if.h', together
=True)
242 conf
.CHECK_HEADERS(headers
='netinet/in.h arpa/nameser.h resolv.h', together
=True)
243 conf
.CHECK_FUNCS_IN('res_search', 'resolv', checklibc
=True,
244 headers
='netinet/in.h arpa/nameser.h resolv.h')
246 conf
.CHECK_FUNCS_IN('gettext', 'intl', checklibc
=True, headers
='libintl.h')
247 conf
.CHECK_FUNCS_IN('pthread_create', 'pthread', checklibc
=True, headers
='pthread.h')
249 conf
.CHECK_FUNCS_IN('crypt', 'crypt', checklibc
=True)
251 conf
.CHECK_VARIABLE('rl_event_hook', define
='HAVE_DECL_RL_EVENT_HOOK', always
=True,
252 headers
='readline.h readline/readline.h readline/history.h')
254 conf
.CHECK_VARIABLE('__FUNCTION__', define
='HAVE_FUNCTION_MACRO')
256 conf
.CHECK_DECLS('snprintf vsnprintf asprintf vasprintf')
258 conf
.CHECK_DECLS('dirfd', reverse
=True, headers
='dirent.h')
259 conf
.CHECK_DECLS('errno', headers
='errno.h', reverse
=True)
260 conf
.CHECK_DECLS('environ getgrent_r getpwent_r', reverse
=True, headers
='pwd.h grp.h')
261 conf
.CHECK_DECLS('pread pwrite setenv setresgid setresuid', reverse
=True)
263 conf
.CHECK_SIZEOF('char int "long long" long off_t short size_t ssize_t')
264 conf
.CHECK_SIZEOF('void*', define
='SIZEOF_VOID_P')
266 if conf
.CONFIG_SET('HAVE_EPOLL_CREATE') and conf
.CONFIG_SET('HAVE_SYS_EPOLL_H'):
267 conf
.DEFINE('HAVE_EPOLL', 1)
269 if not conf
.CHECK_CODE('''#define LIBREPLACE_CONFIGURE_TEST_STRPTIME
270 #include "$libreplacedir/test/strptime.c"''',
271 define
='HAVE_STRPTIME',
272 msg
='Checking for working strptime'):
273 conf
.DEFINE('REPLACE_STRPTIME', 1)
278 conf
.CHECK_CODE('va_list ap1,ap2; va_copy(ap1,ap2)',
279 define
="HAVE_VA_COPY",
280 msg
="Checking for va_copy")
283 #define eprintf(...) fprintf(stderr, __VA_ARGS__)
284 eprintf("bla", "bar")
285 ''', define
='HAVE__VA_ARGS__MACRO')
287 conf
.CHECK_CODE('gettimeofday(NULL, NULL)', 'HAVE_GETTIMEOFDAY_TZ', execute
=False)
289 conf
.CHECK_CODE('#include "test/snprintf.c"',
290 define
="HAVE_C99_VSNPRINTF",
293 msg
="Checking for C99 vsnprintf")
295 if Options
.options
.pedantic
and conf
.CHECK_CFLAGS('-W'):
296 conf
.ADD_CFLAGS('-W')
298 conf
.SAMBA_CONFIG_H()
299 conf
.SAMBA_BUILD_ENV()
301 # look for a method of finding the list of network interfaces
302 for method
in ['HAVE_IFACE_GETIFADDRS', 'HAVE_IFACE_AIX', 'HAVE_IFACE_IFCONF', 'HAVE_IFACE_IFREQ']:
303 if conf
.CHECK_CODE('''
305 #define NO_CONFIG_H 1
306 #define AUTOCONF_TEST 1
307 #define SOCKET_WRAPPER_NOT_REPLACE
309 #include "inet_ntop.c"
310 #include "snprintf.c"
311 #include "getifaddrs.c"
312 #define getifaddrs_test main
313 #include "test/getifaddrs.c"
322 typedef struct {unsigned x;} FOOBAR;
323 #define X_FOOBAR(x) ((FOOBAR) { x })
324 #define FOO_ONE X_FOOBAR(1)
326 static const struct {
331 static const FOOBAR f3[] = {FOO_ONE};
333 define
='HAVE_IMMEDIATE_STRUCTURES')
335 conf
.CHECK_CODE('mkdir("foo",0777)', define
='HAVE_MKDIR_MODE', headers
='sys/stat.h')
337 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_mtim.tv_nsec', define
='HAVE_STAT_TV_NSEC',
338 headers
='sys/stat.h')
339 # we need the st_rdev test under two names
340 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev',
341 define
='HAVE_STRUCT_STAT_ST_RDEV',
342 headers
='sys/stat.h')
343 conf
.CHECK_STRUCTURE_MEMBER('struct stat', 'st_rdev', define
='HAVE_ST_RDEV',
344 headers
='sys/stat.h')
345 conf
.CHECK_STRUCTURE_MEMBER('struct sockaddr_storage', 'ss_family',
346 headers
='sys/socket.h netinet/in.h')
349 if conf
.CHECK_STRUCTURE_MEMBER('struct sockaddr', 'sa_len',
350 headers
='sys/socket.h netinet/in.h',
351 define
='HAVE_SOCKADDR_SA_LEN'):
352 # the old build system produced both defines
353 conf
.DEFINE('HAVE_STRUCT_SOCKADDR_SA_LEN', 1)
355 conf
.CHECK_STRUCTURE_MEMBER('struct sockaddr_in', 'sin_len',
356 headers
='sys/socket.h netinet/in.h',
357 define
='HAVE_SOCK_SIN_LEN')
359 conf
.CHECK_CODE('struct sockaddr_un sunaddr; sunaddr.sun_family = AF_UNIX;',
360 define
='HAVE_UNIXSOCKET', headers
='sys/socket.h sys/un.h')
365 char tpl[20]="/tmp/test.XXXXXX";
366 int fd = mkstemp(tpl);
367 if (fd == -1) exit(1);
369 if (fstat(fd, &st) != 0) exit(1);
370 if ((st.st_mode & 0777) != 0600) exit(1);
373 define
='HAVE_SECURE_MKSTEMP',
375 mandatory
=True) # lets see if we get a mandatory failure for this one
377 if conf
.CHECK_CFLAGS('-fvisibility=hidden'):
378 conf
.env
.VISIBILITY_CFLAGS
= '-fvisibility=hidden'
379 conf
.CHECK_CODE('''void vis_foo1(void) {}
380 __attribute__((visibility("default"))) void vis_foo2(void) {}''',
381 cflags
=conf
.env
.VISIBILITY_CFLAGS
,
382 define
='HAVE_VISIBILITY_ATTR')
384 if conf
.CHECK_FUNCS('getpass getpassphrase'):
385 # if we have both, then we prefer getpassphrase
386 conf
.DEFINE('REPLACE_GETPASS_BY_GETPASSPHRASE', 1)
387 conf
.DEFINE('REPLACE_GETPASS', 1)
389 conf
.CHECK_CODE('''#include "getpass.c"
390 int main(void) { return 0; }''',
392 define
='REPLACE_GETPASS',
393 cflags
='-DNO_CONFIG_H')
395 conf
.sub_config('system')
399 # libreplace needs to put the library in the right build groups
400 # as libreplace is a base library for everything, even for our
401 # compilers, we need libreplace to build very early
402 bld
.SETUP_BUILD_GROUPS()
404 REPLACE_SOURCE
= 'replace.c snprintf.c'
406 if bld
.CONFIG_SET('REPLACE_STRPTIME'): REPLACE_SOURCE
+= ' strptime.c'
407 if not bld
.CONFIG_SET('HAVE_TIMEGM'): REPLACE_SOURCE
+= ' timegm.c'
408 if not bld
.CONFIG_SET('HAVE_GETIFADDRS'): REPLACE_SOURCE
+= ' getifaddrs.c'
409 if not bld
.CONFIG_SET('HAVE_DLOPEN'): REPLACE_SOURCE
+= ' dlfcn.c'
410 if not bld
.CONFIG_SET('HAVE_SOCKETPAIR'): REPLACE_SOURCE
+= ' socketpair.c'
411 if not bld
.CONFIG_SET('HAVE_CONNECT'): REPLACE_SOURCE
+= ' socket.c'
413 bld
.SAMBA_LIBRARY('replace',
414 source
=REPLACE_SOURCE
,
415 group
='base_libraries',
416 deps
='LIBREPLACE_GETPASS nsl socket')
418 TEST_SOURCES
= '''test/testsuite.c test/main.c test/strptime.c
419 test/os2_delete.c test/getifaddrs.c'''
422 bld
.SAMBA_BINARY('replace_testsuite',
428 if bld
.CONFIG_SET('HAVE_INET_NTOA'): NET_SOURCES
.append('inet_ntoa.c')
429 if bld
.CONFIG_SET('HAVE_INET_ATON'): NET_SOURCES
.append('inet_aton.c')
430 if bld
.CONFIG_SET('HAVE_INET_NTOP'): NET_SOURCES
.append('inet_ntop.c')
431 if bld
.CONFIG_SET('HAVE_INET_PTON'): NET_SOURCES
.append('inet_pton.c')
432 if bld
.CONFIG_SET('HAVE_SOCKETPAIR'): NET_SOURCES
.append('socketpair.c')
434 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_NETWORK', NET_SOURCES
, deps
='replace')
438 if not 'HAVE_CRYPT' in bld
.env
: CRYPT_SOURCES
.append('crypt.c')
440 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_EXT', CRYPT_SOURCES
)
442 bld
.SAMBA_SUBSYSTEM('LIBREPLACE_GETPASS', 'getpass.c',
443 enabled
=bld
.CONFIG_SET('REPLACE_GETPASS'))
445 bld
.CHECK_PROJECT_RULES()