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