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