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