chiark / gitweb /
basic: split out update_reboot_parameter_and_warn() into its own .c/.h files
[elogind.git] / src / basic / meson.build
1 # SPDX-License-Identifier: LGPL-2.1+
2 #
3 # Copyright 2017 Zbigniew JÄ™drzejewski-Szmek
4 #
5 # elogind is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; either version 2.1 of the License, or
8 # (at your option) any later version.
9 #
10 # elogind is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with elogind; If not, see <http://www.gnu.org/licenses/>.
17
18 #if 0 /// elogind has a shorter list
19 # basic_sources = files('''
20 #         MurmurHash2.c
21 #         MurmurHash2.h
22 #         af-list.c
23 #         af-list.h
24 #         alloc-util.c
25 #         alloc-util.h
26 #         architecture.c
27 #         architecture.h
28 #         arphrd-list.c
29 #         arphrd-list.h
30 #         async.c
31 #         async.h
32 #         audit-util.c
33 #         audit-util.h
34 #         barrier.c
35 #         barrier.h
36 #         bitmap.c
37 #         bitmap.h
38 #         blkid-util.h
39 #         blockdev-util.c
40 #         blockdev-util.h
41 #         bpf-program.c
42 #         bpf-program.h
43 #         btrfs-ctree.h
44 #         btrfs-util.c
45 #         btrfs-util.h
46 #         build.h
47 #         bus-label.c
48 #         bus-label.h
49 #         calendarspec.c
50 #         calendarspec.h
51 #         cap-list.c
52 #         cap-list.h
53 #         capability-util.c
54 #         capability-util.h
55 #         cgroup-util.c
56 #         cgroup-util.h
57 #         chattr-util.c
58 #         chattr-util.h
59 #         clock-util.c
60 #         clock-util.h
61 #         conf-files.c
62 #         conf-files.h
63 #         copy.c
64 #         copy.h
65 #         cpu-set-util.c
66 #         cpu-set-util.h
67 #         crypt-util.c
68 #         crypt-util.h
69 #         def.h
70 #         device-nodes.c
71 #         device-nodes.h
72 #         dirent-util.c
73 #         dirent-util.h
74 #         env-util.c
75 #         env-util.h
76 #         errno-list.c
77 #         errno-list.h
78 #         escape.c
79 #         escape.h
80 #         ether-addr-util.c
81 #         ether-addr-util.h
82 #         exec-util.c
83 #         exec-util.h
84 #         exit-status.c
85 #         exit-status.h
86 #         extract-word.c
87 #         extract-word.h
88 #         fd-util.c
89 #         fd-util.h
90 #         fileio-label.c
91 #         fileio-label.h
92 #         fileio.c
93 #         fileio.h
94 #         format-util.h
95 #         fs-util.c
96 #         fs-util.h
97 #         glob-util.c
98 #         glob-util.h
99 #         gunicode.c
100 #         gunicode.h
101 #         hash-funcs.c
102 #         hash-funcs.h
103 #         hashmap.c
104 #         hashmap.h
105 #         hexdecoct.c
106 #         hexdecoct.h
107 #         hostname-util.c
108 #         hostname-util.h
109 #         in-addr-util.c
110 #         in-addr-util.h
111 #         io-util.c
112 #         io-util.h
113 #         ioprio.h
114 #         journal-importer.c
115 #         journal-importer.h
116 #         khash.c
117 #         khash.h
118 #         label.c
119 #         label.h
120 #         list.h
121 #         locale-util.c
122 #         locale-util.h
123 #         lockfile-util.c
124 #         lockfile-util.h
125 #         log.c
126 #         log.h
127 #         login-util.c
128 #         login-util.h
129 #         macro.h
130 #         memfd-util.c
131 #         memfd-util.h
132 #         mempool.c
133 #         mempool.h
134 #         missing_syscall.h
135 #         mkdir-label.c
136 #         mkdir.c
137 #         mkdir.h
138 #         module-util.h
139 #         mount-util.c
140 #         mount-util.h
141 #         nss-util.h
142 #         ordered-set.c
143 #         ordered-set.h
144 #         parse-util.c
145 #         parse-util.h
146 #         path-util.c
147 #         path-util.h
148 #         prioq.c
149 #         prioq.h
150 #         proc-cmdline.c
151 #         proc-cmdline.h
152 #         process-util.c
153 #         process-util.h
154 #         procfs-util.c
155 #         procfs-util.h
156 #         random-util.c
157 #         random-util.h
158 #         ratelimit.c
159 #         ratelimit.h
160 #         raw-clone.h
161 #         raw-reboot.h
162 #         reboot-util.c
163 #         reboot-util.h
164 #         refcnt.h
165 #         replace-var.c
166 #         replace-var.h
167 #         rlimit-util.c
168 #         rlimit-util.h
169 #         rm-rf.c
170 #         rm-rf.h
171 #         securebits-util.c
172 #         securebits-util.h
173 #         securebits.h
174 #         selinux-util.c
175 #         selinux-util.h
176 #         set.c
177 #         set.h
178 #         sigbus.c
179 #         sigbus.h
180 #         signal-util.c
181 #         signal-util.h
182 #         siphash24.c
183 #         siphash24.h
184 #         smack-util.c
185 #         smack-util.h
186 #         socket-label.c
187 #         socket-protocol-list.c
188 #         socket-protocol-list.h
189 #         socket-util.c
190 #         socket-util.h
191 #         sparse-endian.h
192 #         special.h
193 #         stat-util.c
194 #         stat-util.h
195 #         stdio-util.h
196 #         strbuf.c
197 #         strbuf.h
198 #         string-table.c
199 #         string-table.h
200 #         string-util.c
201 #         string-util.h
202 #         strv.c
203 #         strv.h
204 #         strxcpyx.c
205 #         strxcpyx.h
206 #         syslog-util.c
207 #         syslog-util.h
208 #         terminal-util.c
209 #         terminal-util.h
210 #         time-util.c
211 #         time-util.h
212 #         umask-util.h
213 #         unaligned.h
214 #         unit-def.c
215 #         unit-def.h
216 #         unit-name.c
217 #         unit-name.h
218 #         user-util.c
219 #         user-util.h
220 #         utf8.c
221 #         utf8.h
222 #         util.c
223 #         util.h
224 #         verbs.c
225 #         verbs.h
226 #         virt.c
227 #         virt.h
228 #         web-util.c
229 #         web-util.h
230 #         xattr-util.c
231 #         xattr-util.h
232 #         xml.c
233 #         xml.h
234 # '''.split())
235 #else
236 basic_sources_plain = files('''
237         alloc-util.c
238         alloc-util.h
239         audit-util.c
240         audit-util.h
241         build.h
242         bus-label.c
243         bus-label.h
244         capability-util.c
245         capability-util.h
246         cgroup-util.c
247         cap-list.c
248         cap-list.h
249         cgroup-util.h
250         conf-files.c
251         conf-files.h
252         copy.c
253         copy.h
254         def.h
255         dirent-util.c
256         dirent-util.h
257         env-util.c
258         env-util.h
259         errno-list.c
260         errno-list.h
261         escape.c
262         escape.h
263         exec-util.c
264         exec-util.h
265         extract-word.c
266         extract-word.h
267         fd-util.c
268         fd-util.h
269         fileio.c
270         fileio.h
271         fileio-label.c
272         fileio-label.h
273         format-util.h
274         fs-util.c
275         fs-util.h
276         gunicode.c
277         gunicode.h
278         hash-funcs.c
279         hash-funcs.h
280         hashmap.c
281         hashmap.h
282         hexdecoct.c
283         hexdecoct.h
284         hostname-util.c
285         hostname-util.h
286         io-util.c
287         io-util.h
288         khash.c
289         khash.h
290         label.c
291         label.h
292         list.h
293         locale-util.c
294         locale-util.h
295         log.c
296         log.h
297         login-util.c
298         login-util.h
299         macro.h
300         memfd-util.c
301         memfd-util.h
302         mempool.c
303         mempool.h
304         missing_syscall.h
305         mkdir.c
306         mkdir.h
307         mkdir-label.c
308         mount-util.c
309         mount-util.h
310         parse-printf-format.c
311         parse-printf-format.h
312         parse-util.c
313         parse-util.h
314         path-util.c
315         path-util.h
316         prioq.c
317         prioq.h
318         proc-cmdline.c
319         proc-cmdline.h
320         process-util.c
321         process-util.h
322         random-util.c
323         random-util.h
324         refcnt.h
325         rm-rf.c
326         rm-rf.h
327         selinux-util.c
328         selinux-util.h
329         set.c
330         set.h
331         sigbus.c
332         sigbus.h
333         signal-util.c
334         signal-util.h
335         siphash24.c
336         siphash24.h
337         smack-util.c
338         smack-util.h
339         socket-util.c
340         socket-util.h
341         sparse-endian.h
342         stat-util.c
343         stat-util.h
344         stdio-util.h
345         string-table.c
346         string-table.h
347         string-util.c
348         string-util.h
349         strv.c
350         strv.h
351         syslog-util.c
352         syslog-util.h
353         terminal-util.c
354         terminal-util.h
355         time-util.c
356         time-util.h
357         umask-util.h
358         unaligned.h
359         unit-def.c
360         unit-def.h
361         unit-name.c
362         unit-name.h
363         user-util.c
364         user-util.h
365         utf8.c
366         utf8.h
367         util.c
368         util.h
369         verbs.c
370         verbs.h
371         virt.c
372         virt.h
373         xattr-util.c
374         xattr-util.h
375 '''.split())
376 #endif // 0
377
378 missing_h = files('missing.h')
379
380 generate_gperfs = find_program('generate-gperfs.py')
381
382 #if 0 /// elogind has only the cap and errno list.
383 # generate_af_list = find_program('generate-af-list.sh')
384 # af_list_txt = custom_target(
385 #         'af-list.txt',
386 #         output : 'af-list.txt',
387 #         command : [generate_af_list, cpp],
388 #         capture : true)
389
390 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
391 # arphrd_list_txt = custom_target(
392 #         'arphrd-list.txt',
393 #         output : 'arphrd-list.txt',
394 #         command : [generate_arphrd_list, cpp],
395 #         capture : true)
396 #endif // 0
397
398 generate_cap_list = find_program('generate-cap-list.sh')
399 cap_list_txt = custom_target(
400         'cap-list.txt',
401         output : 'cap-list.txt',
402 #if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
403 #         command : [generate_cap_list, cpp, config_h, missing_h],
404 #else
405         command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
406 #endif // 0
407         capture : true)
408
409 generate_errno_list = find_program('generate-errno-list.sh')
410 errno_list_txt = custom_target(
411         'errno-list.txt',
412         output : 'errno-list.txt',
413         command : [generate_errno_list, cpp],
414         capture : true)
415
416 generate_socket_protocol_list = find_program('generate-socket-protocol-list.sh')
417 socket_protocol_list_txt = custom_target(
418         'socket-protocol-list.txt',
419         output : 'socket-protocol-list.txt',
420         command : [generate_socket_protocol_list, cpp],
421         capture : true)
422
423 generated_gperf_headers = []
424 #if 0 /// elogind has only the cap and errno list.
425 # foreach item : [['af',     af_list_txt,     'af',         ''],
426 #                 ['arphrd', arphrd_list_txt, 'arphrd',     'ARPHRD_'],
427 #                 ['cap',    cap_list_txt,    'capability', ''],
428 #                 ['errno',  errno_list_txt,  'errno',      ''],
429 #                 ['socket-protocol', socket_protocol_list_txt, 'socket_protocol',     'IPPROTO_']]
430 #else
431 foreach item : [['cap',    cap_list_txt,    'capability', ''],
432                 ['errno',  errno_list_txt,  'errno',      '']]
433 #endif // 0
434
435         fname = '@0@-from-name.gperf'.format(item[0])
436         gperf_file = custom_target(
437                 fname,
438                 input : item[1],
439                 output : fname,
440                 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
441                 capture : true)
442
443         fname = '@0@-from-name.h'.format(item[0])
444         target1 = custom_target(
445                 fname,
446                 input : gperf_file,
447                 output : fname,
448                 command : [gperf,
449                            '-L', 'ANSI-C', '-t', '--ignore-case',
450                            '-N', 'lookup_@0@'.format(item[2]),
451                            '-H', 'hash_@0@_name'.format(item[2]),
452                            '-p', '-C',
453                            '@INPUT@'],
454                 capture : true)
455
456         fname = '@0@-to-name.h'.format(item[0])
457         awkscript = '@0@-to-name.awk'.format(item[0])
458         target2 = custom_target(
459                 fname,
460                 input : [awkscript, item[1]],
461                 output : fname,
462                 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
463                 capture : true)
464
465         generated_gperf_headers += [target1, target2]
466 endforeach
467
468 basic_sources += [missing_h] + generated_gperf_headers
469
470 libbasic = static_library(
471         'basic',
472         basic_sources,
473         include_directories : includes,
474         dependencies : [threads,
475                         libcap,
476 #if 0 /// no blkid in elogind
477 #                         libblkid,
478 #endif // 0
479                         libmount,
480                         libselinux],
481         c_args : ['-fvisibility=default'],
482         install : false)
483
484 # A convenience library that is separate from libbasic to avoid
485 # unnecessary linking to libgcrypt.
486 libbasic_gcrypt = static_library(
487         'basic-gcrypt',
488         'gcrypt-util.c',
489         'gcrypt-util.h',
490         include_directories : includes,
491         dependencies : [libgcrypt],
492         c_args : ['-fvisibility=default'])