]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/basic/meson.build
ced027ba8318d3ec18235f48af6ef34e5eeb05e9
[thirdparty/systemd.git] / src / basic / meson.build
1 # SPDX-License-Identifier: LGPL-2.1-or-later
2
3 basic_sources = files(
4 'MurmurHash2.c',
5 'af-list.c',
6 'alloc-util.c',
7 'architecture.c',
8 'argv-util.c',
9 'arphrd-util.c',
10 'audit-util.c',
11 'btrfs.c',
12 'build.c',
13 'build-path.c',
14 'bus-label.c',
15 'cap-list.c',
16 'capability-util.c',
17 'cgroup-util.c',
18 'chase.c',
19 'chattr-util.c',
20 'compress.c',
21 'conf-files.c',
22 'confidential-virt.c',
23 'devnum-util.c',
24 'dirent-util.c',
25 'dlfcn-util.c',
26 'efivars.c',
27 'env-file.c',
28 'env-util.c',
29 'errno-list.c',
30 'escape.c',
31 'ether-addr-util.c',
32 'extract-word.c',
33 'fd-util.c',
34 'fileio.c',
35 'filesystems.c',
36 'format-util.c',
37 'fs-util.c',
38 'glob-util.c',
39 'glyph-util.c',
40 'gunicode.c',
41 'hash-funcs.c',
42 'hashmap.c',
43 'hexdecoct.c',
44 'hmac.c',
45 'hostname-util.c',
46 'in-addr-util.c',
47 'initrd-util.c',
48 'inotify-util.c',
49 'io-util.c',
50 'ioprio-util.c',
51 'iovec-util.c',
52 'iovec-wrapper.c',
53 'label.c',
54 'limits-util.c',
55 'locale-util.c',
56 'lock-util.c',
57 'log.c',
58 'login-util.c',
59 'memfd-util.c',
60 'memory-util.c',
61 'mempool.c',
62 'memstream-util.c',
63 'mkdir.c',
64 'mountpoint-util.c',
65 'namespace-util.c',
66 'nulstr-util.c',
67 'ordered-set.c',
68 'os-util.c',
69 'parse-util.c',
70 'path-lookup.c',
71 'path-util.c',
72 'percent-util.c',
73 'pidref.c',
74 'prioq.c',
75 'proc-cmdline.c',
76 'process-util.c',
77 'procfs-util.c',
78 'psi-util.c',
79 'random-util.c',
80 'ratelimit.c',
81 'recurse-dir.c',
82 'replace-var.c',
83 'rlimit-util.c',
84 'runtime-scope.c',
85 'sha256.c',
86 'sigbus.c',
87 'signal-util.c',
88 'siphash24.c',
89 'socket-util.c',
90 'sort-util.c',
91 'stat-util.c',
92 'strbuf.c',
93 'string-table.c',
94 'string-util.c',
95 'strv.c',
96 'strxcpyx.c',
97 'sync-util.c',
98 'sysctl-util.c',
99 'syslog-util.c',
100 'terminal-util.c',
101 'time-util.c',
102 'tmpfile-util.c',
103 'uid-classification.c',
104 'uid-range.c',
105 'unit-def.c',
106 'unit-file.c',
107 'unit-name.c',
108 'user-util.c',
109 'utf8.c',
110 'virt.c',
111 'xattr-util.c',
112 )
113
114 missing_audit_h = files('missing_audit.h')
115 missing_capability_h = files('missing_capability.h')
116 missing_socket_h = files('missing_socket.h')
117
118 missing_syscall_def_h = files('missing_syscall_def.h')
119 basic_sources += missing_syscall_def_h
120
121 generate_af_list = find_program('generate-af-list.sh')
122 af_list_txt = custom_target(
123 'af-list.txt',
124 output : 'af-list.txt',
125 command : [generate_af_list, cpp, config_h, missing_socket_h],
126 capture : true)
127
128 generate_arphrd_list = find_program('generate-arphrd-list.sh')
129 arphrd_list_txt = custom_target(
130 'arphrd-list.txt',
131 output : 'arphrd-list.txt',
132 command : [generate_arphrd_list, cpp, config_h],
133 capture : true)
134
135 generate_cap_list = find_program('generate-cap-list.sh')
136 cap_list_txt = custom_target(
137 'cap-list.txt',
138 output : 'cap-list.txt',
139 command : [generate_cap_list, cpp, config_h, missing_capability_h],
140 capture : true)
141
142 generate_errno_list = find_program('generate-errno-list.sh')
143 errno_list_txt = custom_target(
144 'errno-list.txt',
145 output : 'errno-list.txt',
146 command : [generate_errno_list, cpp],
147 capture : true)
148
149 generated_gperf_headers = []
150 foreach item : [['af', af_list_txt, 'af', ''],
151 ['arphrd', arphrd_list_txt, 'arphrd', 'ARPHRD_'],
152 ['cap', cap_list_txt, 'capability', ''],
153 ['errno', errno_list_txt, 'errno', '']]
154
155 fname = '@0@-from-name.gperf'.format(item[0])
156 gperf_file = custom_target(
157 fname,
158 input : item[1],
159 output : fname,
160 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
161 capture : true)
162
163 fname = '@0@-from-name.h'.format(item[0])
164 target1 = custom_target(
165 fname,
166 input : gperf_file,
167 output : fname,
168 command : [gperf,
169 '-L', 'ANSI-C', '-t', '--ignore-case',
170 '-N', 'lookup_@0@'.format(item[2]),
171 '-H', 'hash_@0@_name'.format(item[2]),
172 '-p', '-C',
173 '@INPUT@'],
174 capture : true)
175
176 fname = '@0@-to-name.h'.format(item[0])
177 awkscript = '@0@-to-name.awk'.format(item[0])
178 target2 = custom_target(
179 fname,
180 input : [awkscript, item[1]],
181 output : fname,
182 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
183 capture : true)
184
185 generated_gperf_headers += [target1, target2]
186 endforeach
187
188 basic_sources += generated_gperf_headers
189
190 ############################################################
191
192 arch_list = [
193 'alpha',
194 'arc',
195 'arm',
196 'arm64',
197 'i386',
198 'ia64',
199 'loongarch64',
200 'm68k',
201 'mips64',
202 'mips64n32',
203 'mipso32',
204 'parisc',
205 'powerpc',
206 'powerpc64',
207 'riscv32',
208 'riscv64',
209 's390',
210 's390x',
211 'sparc',
212 'x86_64'
213 ]
214
215 run_target(
216 'update-syscall-tables',
217 command : [update_syscall_tables_sh, meson.current_source_dir()] + arch_list)
218
219 syscall_list_txt = files('syscall-list.txt')
220
221 syscall_lists = []
222 foreach arch: arch_list
223 syscall_lists += files('syscalls-@0@.txt'.format(arch))
224 endforeach
225
226 missing_syscalls_py = find_program('missing_syscalls.py')
227
228 run_target(
229 'update-syscall-header',
230 command : [missing_syscalls_py,
231 missing_syscall_def_h,
232 syscall_lists])
233
234 ############################################################
235
236 filesystem_includes = ['linux/magic.h',
237 'linux/gfs2_ondisk.h']
238
239 check_filesystems = find_program('check-filesystems.sh')
240 r = run_command([check_filesystems, cpp, files('filesystems-gperf.gperf')] + filesystem_includes, check: false)
241 if r.returncode() != 0
242 error('Unknown filesystems defined in kernel headers:\n\n' + r.stdout())
243 endif
244
245 filesystems_gperf_h = custom_target(
246 'filesystems-gperf.h',
247 input : 'filesystems-gperf.gperf',
248 output : 'filesystems-gperf.h',
249 command : [gperf, '@INPUT@', '--output-file', '@OUTPUT@'])
250
251 generate_filesystem_list = find_program('generate-filesystem-list.py')
252 fname = 'filesystem-list.h'
253 filesystem_list_h = custom_target(
254 fname,
255 input : 'filesystems-gperf.gperf',
256 output : fname,
257 command : [generate_filesystem_list,
258 '@INPUT@'],
259 capture : true)
260
261 generate_filesystem_switch_case_h = find_program('generate-filesystem-switch-case.py')
262 fname = 'filesystem-switch-case.h'
263 filesystem_switch_case_h = custom_target(
264 fname,
265 input : 'filesystems-gperf.gperf',
266 output : 'filesystem-switch-case.h',
267 command : [generate_filesystem_switch_case_h,
268 '@INPUT@'],
269 capture : true)
270
271 basic_sources += [filesystem_list_h, filesystem_switch_case_h, filesystems_gperf_h]
272
273 libbasic = static_library(
274 'basic',
275 basic_sources,
276 fundamental_sources,
277 include_directories : basic_includes,
278 dependencies : [libcap,
279 libdl,
280 liblz4_cflags,
281 libm,
282 librt,
283 libxz_cflags,
284 libzstd_cflags,
285 threads,
286 userspace],
287 c_args : ['-fvisibility=default'],
288 build_by_default : false)
289
290 ############################################################
291
292 basic_gcrypt_sources = files(
293 'gcrypt-util.c',
294 )
295
296 # A convenience library that is separate from libbasic to avoid
297 # unnecessary linking to libgcrypt.
298 libbasic_gcrypt = static_library(
299 'basic-gcrypt',
300 basic_gcrypt_sources,
301 include_directories : basic_includes,
302 dependencies : [libgcrypt,
303 userspace],
304 c_args : ['-fvisibility=default'],
305 build_by_default : false)