waf: Fix systemd detection
[Samba.git] / lib / util / wscript_configure
blobe52ba4a76238a9724584d44d6d3479ad1261b131
1 #!/usr/bin/env python
2 import Options
4 if Options.options.disable_fault_handling:
5 conf.DEFINE('HAVE_DISABLE_FAULT_HANDLING',1)
7 # backtrace could be in libexecinfo or in libc
8 conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo', checklibc=True, headers='execinfo.h')
10 conf.CHECK_FUNCS('sigprocmask sigblock sigaction')
12 conf.CHECK_STRUCTURE_MEMBER('struct statvfs', 'f_frsize', define='HAVE_FRSIZE', headers='sys/statvfs.h')
14 # all the different ways of doing statfs
15 statfs_types = [
16 ( 'STAT_STATVFS',
17 'statvfs (SVR4)',
18 'struct statvfs fsd; exit(statvfs(0, &fsd))',
19 'sys/statvfs.h' ),
21 ( 'STAT_STATFS3_OSF1',
22 '3-argument statfs function (DEC OSF/1)',
23 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd, sizeof(struct statfs)))',
24 'sys/param.h sys/mount.h' ),
26 ( 'STAT_STATFS2_BSIZE',
27 'two-argument statfs with statfs.bsize',
28 'struct statfs fsd; fsd.f_bsize = 0; exit(statfs(".", &fsd))',
29 'sys/param.h sys/mount.h sys/vfs.h' ),
31 ( 'STAT_STATFS4',
32 'four-argument statfs (AIX-3.2.5, SVR3)',
33 'struct statfs fsd; exit(statfs(".", &fsd, sizeof fsd, 0))',
34 'sys/statfs.h' ),
36 ( 'STAT_STATFS2_FSIZE',
37 'two-argument statfs with statfs.fsize',
38 'struct statfs fsd; fsd.f_fsize = 0; exit(statfs(".", &fsd))',
39 'sys/param.h sys/mount.h' ),
41 ( 'STAT_STATFS2_FS_DATA',
42 'two-argument statfs with struct fs_data (Ultrix)',
43 'struct fs_data fsd; exit(statfs(".", &fsd) != 1)',
44 'sys/param.h sys/mount.h sys/fs_types.h' )
47 found_statfs=False
48 for (define, msg, code, headers) in statfs_types:
49 if conf.CHECK_CODE(code,
50 define=define,
51 headers=headers,
52 msg='Checking for %s' % msg,
53 local_include=False):
54 found_statfs=True
55 break
57 if not found_statfs:
58 print("FATAL: Failed to find a statfs method")
59 raise
61 conf.CHECK_CODE("""struct statfs fsd;
62 fsd.f_bsize = 0;
63 fsd.f_iosize = 0;
64 return (statfs (".", &fsd));
65 """,
66 headers='sys/param.h sys/mount.h sys/vfs.h',
67 define='BSD_STYLE_STATVFS',
68 msg='Checking for *bsd style statfs with statfs.f_iosize',
69 execute=True,
70 local_include=False)
72 conf.CHECK_CODE('struct statvfs buf; buf.f_fsid = 0',
73 define='HAVE_FSID_INT',
74 msg='Checking if f_fsid is an integer',
75 execute=False,
76 local_include=False,
77 headers='sys/statvfs.h')
79 # fsusage.c assumes that statvfs has an f_frsize entry. Some weird
80 # systems use f_bsize.
81 conf.CHECK_CODE('struct statvfs buf; buf.f_frsize = 0',
82 define='HAVE_FRSIZE',
83 msg='Checking that statvfs.f_frsize works',
84 headers='sys/statvfs.h',
85 execute=False,
86 local_include=False)
88 # Some systems use f_flag in struct statvfs while others use f_flags
89 conf.CHECK_CODE('struct statvfs buf; buf.f_flag = 0',
90 define='HAVE_STATVFS_F_FLAG',
91 msg='Checking whether statvfs.f_flag exists',
92 headers='sys/statvfs.h',
93 local_include=False,
94 execute=False)
96 conf.CHECK_CODE('struct statvfs buf; buf.f_flags = 0',
97 define='HAVE_STATVFS_F_FLAGS',
98 msg='Checking whether statvfs.f_flags exists',
99 headers='sys/statvfs.h',
100 local_include=False,
101 execute=False)
104 # systemd removed the libsystemd-daemon and libsystemd-journal libraries. In newer
105 # versions it is only libsystemd. As waf pkg-config handling does not provide
106 # targets which could be used as a dependency based on the package name we need
107 # to look for them on our own. This enabled one of the library targets based on
108 # which version we detect.
110 conf.SET_TARGET_TYPE('systemd-daemon', 'EMPTY')
111 conf.SET_TARGET_TYPE('systemd-journal', 'EMPTY')
112 conf.SET_TARGET_TYPE('systemd', 'EMPTY')
114 if Options.options.enable_systemd != False:
115 conf.check_cfg(package='libsystemd-daemon', args='--cflags --libs',
116 msg='Checking for libsystemd-daemon')
117 if not conf.CHECK_LIB('systemd-daemon', shlib=True):
118 conf.CHECK_LIB('systemd', shlib=True)
120 if Options.options.enable_systemd != False:
121 conf.check_cfg(package='libsystemd-journal', args='--cflags --libs',
122 msg='Checking for libsystemd-journal')
123 if not conf.CHECK_LIB('systemd-journal', shlib=True):
124 conf.CHECK_LIB('systemd', shlib=True)
126 if Options.options.enable_lttng != False:
127 conf.check_cfg(package='lttng-ust', args='--cflags --libs',
128 msg='Checking for lttng-ust', uselib_store="LTTNG-UST")
129 conf.CHECK_HEADERS('lttng/tracef.h', lib='lttng-st')
130 conf.CHECK_LIB('lttng-ust', shlib=True)
132 if (conf.CONFIG_SET('HAVE_LTTNG_TRACEF_H') and
133 conf.CONFIG_SET('HAVE_LTTNG_UST')):
134 conf.DEFINE('HAVE_LTTNG_TRACEF', '1')
135 conf.env['HAVE_LTTNG_TRACEF'] = True
136 else:
137 conf.SET_TARGET_TYPE('lttng-ust', 'EMPTY')
138 conf.undefine('HAVE_LTTNG_TRACEF')
140 conf.env['CPPPATH_GPFS'] = '/usr/lpp/mmfs/include/'
141 if conf.CHECK_HEADERS('gpfs_fcntl.h', False, False, "gpfs"):
142 conf.DEFINE('HAVE_GPFS', '1')