s3: smbd: rename_internals_fsp() has to reopen the parent directory of the target...
[Samba.git] / lib / util / wscript_configure
blob27206e0e85a6bb539ea426cc6d5c3502431c409f
1 #!/usr/bin/env python
2 from waflib import Logs, Options, Errors
4 import os, sys
6 if Options.options.disable_fault_handling:
7 conf.DEFINE('HAVE_DISABLE_FAULT_HANDLING',1)
9 # backtrace could be in libexecinfo or in libc.
10 # This is our preferred backtrace handler (more useful output than libunwind as at Ubuntu 20.04 x86_64)
11 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
12 conf.CHECK_HEADERS('execinfo.h')
14 conf.SET_TARGET_TYPE('LIBUNWIND', 'EMPTY')
15 if Options.options.with_libunwind:
16 if conf.check_cfg(package='libunwind-generic',
17 args='--cflags --libs',
18 msg='Checking for libunwind',
19 uselib_store='LIBUNWIND',
20 mandatory=False):
21 if conf.CHECK_HEADERS('libunwind.h'):
22 conf.SET_TARGET_TYPE('LIBUNWIND', 'SYSLIB')
23 else:
24 raise Errors.WafError('--with-libunwind specified but libunwind not found')
25 elif Options.options.with_libunwind == None:
26 if not conf.CONFIG_SET('HAVE_BACKTRACE_SYMBOLS') \
27 and not Options.options.disable_fault_handling:
28 raise Errors.WafError(
29 '''backtrace_symbols() not found but
30 --with-libunwind not specified.
31 Use --without-libunwind to build without internal backtrace support or
32 --disable-fault-handling to totally defer fault handling to the OS.''')
34 conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE', headers='sys/statvfs.h')
36 # all the different ways of doing statfs
37 statfs_types = [
38 ( 'STAT_STATVFS',
39 'statvfs (SVR4)',
40 'struct statvfs fsd; exit(statvfs(0, &fsd))',
41 'sys/statvfs.h' ),
43 ( 'STAT_STATFS3_OSF1',
44 '3-argument statfs function (DEC OSF/1)',
45 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd, sizeof(struct statfs)))',
46 'sys/param.h sys/mount.h' ),
48 ( 'STAT_STATFS2_BSIZE',
49 'two-argument statfs with statfs.bsize',
50 'struct statfs fsd; fsd.f_bsize = 0; exit(statfs(".", &fsd))',
51 'sys/param.h sys/mount.h sys/vfs.h' ),
53 ( 'STAT_STATFS4',
54 'four-argument statfs (AIX-3.2.5, SVR3)',
55 'struct statfs fsd; exit(statfs(".", &fsd, sizeof fsd, 0))',
56 'sys/statfs.h' ),
58 ( 'STAT_STATFS2_FSIZE',
59 'two-argument statfs with statfs.fsize',
60 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd))',
61 'sys/param.h sys/mount.h' ),
63 ( 'STAT_STATFS2_FS_DATA',
64 'two-argument statfs with struct fs_data (Ultrix)',
65 'struct fs_data fsd; exit(statfs(".", &fsd) != 1)',
66 'sys/param.h sys/mount.h sys/fs_types.h' )
69 found_statfs=False
70 for (define, msg, code, headers) in statfs_types:
71 if conf.CHECK_CODE(code,
72 define=define,
73 headers=headers,
74 msg='Checking for %s' % msg,
75 local_include=False):
76 found_statfs=True
77 break
79 if not found_statfs:
80 print("FATAL: Failed to find a statfs method")
81 raise
83 conf.CHECK_CODE("""struct statfs fsd;
84 fsd.f_bsize = 0;
85 fsd.f_iosize = 0;
86 return (statfs (".", &fsd));
87 """,
88 headers='sys/param.h sys/mount.h sys/vfs.h',
89 define='BSD_STYLE_STATVFS',
90 msg='Checking for *bsd style statfs with statfs.f_iosize',
91 execute=True,
92 local_include=False)
94 conf.CHECK_CODE('struct statvfs buf; buf.f_fsid = 0',
95 define='HAVE_FSID_INT',
96 msg='Checking if f_fsid is an integer',
97 execute=False,
98 local_include=False,
99 headers='sys/statvfs.h')
101 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
102 # systems use f_bsize.
103 conf.CHECK_CODE('struct statvfs buf; buf.f_frsize = 0',
104 define='HAVE_FRSIZE',
105 msg='Checking that statvfs.f_frsize works',
106 headers='sys/statvfs.h',
107 execute=False,
108 local_include=False)
110 # Some systems use f_flag in struct statvfs while others use f_flags
111 conf.CHECK_CODE('struct statvfs buf; buf.f_flag = 0',
112 define='HAVE_STATVFS_F_FLAG',
113 msg='Checking whether statvfs.f_flag exists',
114 headers='sys/statvfs.h',
115 local_include=False,
116 execute=False)
118 conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0',
119 define='HAVE_STATVFS_F_FLAGS',
120 msg='Checking whether statvfs.f_flags exists',
121 headers='sys/statvfs.h',
122 local_include=False,
123 execute=False)
125 # Check for mallinfo2() first and fallback to mallinfo() if not found
126 body = '''mi.arena + mi.ordblks + mi.smblks + mi.hblks + mi.hblkhd +
127 mi.usmblks + mi.fsmblks + mi.uordblks + mi.fordblks + mi.keepcost'''
128 if not conf.CHECK_CODE('''struct mallinfo2 mi = mallinfo2(); return %s;'''
129 % body, 'HAVE_MALLINFO2',
130 msg="Checking for mallinfo2()",
131 headers='malloc.h'):
132 conf.CHECK_CODE('''struct mallinfo mi = mallinfo(); return %s;'''
133 % body, 'HAVE_MALLINFO',
134 msg="Checking for mallinfo()",
135 headers='malloc.h')
138 # systemd removed the libsystemd-daemon and libsystemd-journal libraries. In newer
139 # versions it is only libsystemd. As waf pkg-config handling does not provide
140 # targets which could be used as a dependency based on the package name we need
141 # to look for them on our own. This enabled one of the library targets based on
142 # which version we detect.
144 conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
145 conf.SET_TARGET_TYPE('systemd-journal', 'EMPTY')
146 conf.SET_TARGET_TYPE('systemd', 'EMPTY')
148 if Options.options.enable_systemd != False:
149 r_daemon = conf.CHECK_CFG(package='libsystemd-daemon', args='--cflags --libs',
150 msg='Checking for libsystemd-daemon')
151 r_journal = conf.CHECK_CFG(package='libsystemd-journal', args='--cflags --libs',
152 msg='Checking for libsystemd-journal')
153 if r_daemon is None and r_journal is None:
154 conf.CHECK_CFG(package='libsystemd', args='--cflags --libs',
155 msg='Checking for libsystemd')
156 conf.CHECK_LIB('systemd', shlib=True)
157 else:
158 conf.CHECK_LIB('systemd-daemon', shlib=True)
159 conf.CHECK_LIB('systemd-journal', shlib=True)
161 conf.SET_TARGET_TYPE('lttng-ust', 'EMPTY')
163 if Options.options.enable_lttng != False:
164 conf.CHECK_CFG(package='lttng-ust', args='--cflags --libs',
165 msg='Checking for lttng-ust', uselib_store="LTTNG-UST")
166 conf.CHECK_HEADERS('lttng/tracef.h', lib='lttng-st')
167 conf.CHECK_LIB('lttng-ust', shlib=True)
169 if (conf.CONFIG_SET('HAVE_LTTNG_TRACEF_H') and
170 conf.CONFIG_SET('HAVE_LTTNG_UST')):
171 conf.DEFINE('HAVE_LTTNG_TRACEF', '1')
172 conf.env['HAVE_LTTNG_TRACEF'] = True
174 if Options.options.gpfs_headers_dir:
175 conf.env['CPPPATH_GPFS'] = Options.options.gpfs_headers_dir
176 if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"):
177 Logs.info('Using gpfs.h from %s' % Options.options.gpfs_headers_dir)
178 conf.DEFINE('HAVE_GPFS', '1')
179 else:
180 conf.env['CPPPATH_GPFS'] = "/usr/lpp/mmfs/include/"
181 if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"):
182 Logs.info('Using gpfs.h from installed gpfs package.')
183 conf.DEFINE('HAVE_GPFS', '1')
184 else:
185 if sys.platform.startswith('linux'):
186 conf.env['CPPPATH_GPFS'] = os.path.abspath("third_party/gpfs")
187 if conf.CHECK_HEADERS('gpfs.h', False, False, "gpfs"):
188 Logs.info('Using gpfs.h from third_party directory.')
189 conf.DEFINE('HAVE_GPFS', '1')