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