build: allow the waf build to work with python 3.0 and 3.1
[nivanova/samba-autobuild/.git] / lib / util / wscript_configure
1 #!/usr/bin/env python
2
3
4 # backtrace could be in libexecinfo or in libc
5 conf.CHECK_FUNCS_IN('backtrace', 'execinfo', checklibc=True, headers='execinfo.h')
6
7 conf.CHECK_FUNCS('sigprocmask sigblock sigaction')
8
9 conf.CHECK_FUNCS_IN('flistxattr', 'attr', checklibc=True, headers='sys/attributes.h attr/xattr.h sys/xattr.h')
10
11 conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE', headers='sys/statvfs.h')
12
13 conf.CHECK_CODE('getxattr(NULL, NULL, NULL, 0, 0, 0)',
14                 define='XATTR_ADDITIONAL_OPTIONS')
15
16 if conf.CONFIG_SET('HAVE_FLISTXATTR'):
17     conf.DEFINE('HAVE_XATTR_SUPPORT', 1)
18
19
20
21
22 # all the different ways of doing statfs
23 statfs_types = [
24     ( 'STAT_STATVFS64',
25       'Linux statvfs64',
26       'struct statvfs64 fsd; exit(statvfs64 (".", &fsd))',
27       'sys/statvfs.h' ),
28
29     ( 'STAT_STATVFS',
30       'statvfs (SVR4)',
31       'struct statvfs fsd; exit(statvfs(0, &fsd))',
32       'sys/statvfs.h' ),
33
34     ( 'STAT_STATFS3_OSF1',
35       '3-argument statfs function (DEC OSF/1)',
36       'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd, sizeof(struct statfs)))'
37       'sys/param.h sys/mount.h' ),
38
39     ( 'STAT_STATFS2_BSIZE',
40       'two-argument statfs with statfs.bsize',
41       'struct statfs fsd; fsd.f_bsize = 0; exit(statfs(".", &fsd))',
42       'sys/param.h sys/mount.h  sys/vfs.h' ),
43
44     ( 'STAT_STATFS4',
45       'four-argument statfs  (AIX-3.2.5, SVR3)',
46       'struct statfs fsd; exit(statfs(".", &fsd, sizeof fsd, 0))',
47       'sys/statfs.h' ),
48
49     ( 'STAT_STATFS2_FSIZE',
50       'two-argument statfs with statfs.fsize',
51       'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd))'
52       'sys/param.h sys/mount.h' ),
53
54     ( 'STAT_STATFS2_FS_DATA',
55       'two-argument statfs with struct fs_data (Ultrix)',
56       'struct fs_data fsd; exit(statfs(".", &fsd) != 1)',
57       'sys/param.h sys/mount.h sys/fs_types.h' )
58 ]
59
60 found_statfs=False
61 for (define, msg, code, headers) in statfs_types:
62     if conf.CHECK_CODE(code,
63                        define=define,
64                        headers=headers,
65                        msg='Checking for %s' % msg,
66                        local_include=False):
67         found_statfs=True
68         break
69
70 if not found_statfs:
71     print("FATAL: Failed to find a statfs method")
72     raise
73
74
75 conf.CHECK_CODE('struct statvfs buf; buf.f_fsid = 0',
76                 define='HAVE_FSID_INT',
77                 msg='Checking if f_fsid is an integer',
78                 execute=False,
79                 local_include=False,
80                 headers='sys/statvfs.h')
81
82 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
83 # systems use f_bsize.
84 conf.CHECK_CODE('struct statvfs buf; buf.f_frsize = 0',
85                 define='HAVE_FRSIZE',
86                 msg='Checking that statvfs.f_frsize works',
87                 headers='sys/statvfs.h',
88                 execute=False,
89                 local_include=False)
90
91 # Some systems use f_flag in struct statvfs while others use f_flags
92 conf.CHECK_CODE('struct statvfs buf; buf.f_flag = 0',
93                 define='HAVE_STATVFS_F_FLAG',
94                 msg='Checking whether statvfs.f_flag exists',
95                 headers='sys/statvfs.h',
96                 local_include=False,
97                 execute=False)
98
99 conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0',
100                 define='HAVE_STATVFS_F_FLAGS',
101                 msg='Checking whether statvfs.f_flags exists',
102                 headers='sys/statvfs.h',
103                 local_include=False,
104                 execute=False)