chiark / gitweb /
831782733bc347f491cf3af2ed62161a1f819c56
[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 #         os-util.c
136 #         os-util.h
137 #         parse-util.c
138 #         parse-util.h
139 #         path-util.c
140 #         path-util.h
141 #         prioq.c
142 #         prioq.h
143 #         proc-cmdline.c
144 #         proc-cmdline.h
145 #         process-util.c
146 #         process-util.h
147 #         procfs-util.c
148 #         procfs-util.h
149 #         random-util.c
150 #         random-util.h
151 #         ratelimit.c
152 #         ratelimit.h
153 #         raw-clone.h
154 #         raw-reboot.h
155 #         reboot-util.c
156 #         reboot-util.h
157 #         refcnt.h
158 #         replace-var.c
159 #         replace-var.h
160 #         rlimit-util.c
161 #         rlimit-util.h
162 #         rm-rf.c
163 #         rm-rf.h
164 #         securebits-util.c
165 #         securebits-util.h
166 #         securebits.h
167 #         selinux-util.c
168 #         selinux-util.h
169 #         set.h
170 #         sigbus.c
171 #         sigbus.h
172 #         signal-util.c
173 #         signal-util.h
174 #         siphash24.c
175 #         siphash24.h
176 #         smack-util.c
177 #         smack-util.h
178 #         socket-label.c
179 #         socket-protocol-list.c
180 #         socket-protocol-list.h
181 #         socket-util.c
182 #         socket-util.h
183 #         sparse-endian.h
184 #         special.h
185 #         stat-util.c
186 #         stat-util.h
187 #         stdio-util.h
188 #         strbuf.c
189 #         strbuf.h
190 #         string-table.c
191 #         string-table.h
192 #         string-util.c
193 #         string-util.h
194 #         strv.c
195 #         strv.h
196 #         strxcpyx.c
197 #         strxcpyx.h
198 #         syslog-util.c
199 #         syslog-util.h
200 #         terminal-util.c
201 #         terminal-util.h
202 #         time-util.c
203 #         time-util.h
204 #         umask-util.h
205 #         unaligned.h
206 #         unit-def.c
207 #         unit-def.h
208 #         unit-name.c
209 #         unit-name.h
210 #         user-util.c
211 #         user-util.h
212 #         utf8.c
213 #         utf8.h
214 #         util.c
215 #         util.h
216 #         verbs.c
217 #         verbs.h
218 #         virt.c
219 #         virt.h
220 #         web-util.c
221 #         web-util.h
222 #         xattr-util.c
223 #         xattr-util.h
224 #         xml.c
225 #         xml.h
226 # '''.split())
227 #else
228 basic_sources = files('''
229         alloc-util.c
230         alloc-util.h
231         audit-util.c
232         audit-util.h
233         build.h
234         bus-label.c
235         bus-label.h
236         capability-util.c
237         capability-util.h
238         cgroup-util.c
239         cap-list.c
240         cap-list.h
241         cgroup-util.h
242         conf-files.c
243         conf-files.h
244         copy.c
245         copy.h
246         def.h
247         dirent-util.c
248         dirent-util.h
249         env-util.c
250         env-util.h
251         errno-list.c
252         errno-list.h
253         escape.c
254         escape.h
255         exec-util.c
256         exec-util.h
257         extract-word.c
258         extract-word.h
259         fd-util.c
260         fd-util.h
261         fileio.c
262         fileio.h
263         fileio-label.c
264         fileio-label.h
265         format-util.h
266         fs-util.c
267         fs-util.h
268         gunicode.c
269         gunicode.h
270         hash-funcs.c
271         hash-funcs.h
272         hashmap.c
273         hashmap.h
274         hexdecoct.c
275         hexdecoct.h
276         hostname-util.c
277         hostname-util.h
278         io-util.c
279         io-util.h
280         khash.c
281         khash.h
282         label.c
283         label.h
284         list.h
285         locale-util.c
286         locale-util.h
287         log.c
288         log.h
289         login-util.c
290         login-util.h
291         macro.h
292         memfd-util.c
293         memfd-util.h
294         mempool.c
295         mempool.h
296         missing_syscall.h
297         mkdir.c
298         mkdir.h
299         mkdir-label.c
300         mount-util.c
301         mount-util.h
302         parse-printf-format.c
303         parse-printf-format.h
304         parse-util.c
305         parse-util.h
306         path-util.c
307         path-util.h
308         prioq.c
309         prioq.h
310         proc-cmdline.c
311         proc-cmdline.h
312         procfs-util.c
313         procfs-util.h
314         process-util.c
315         process-util.h
316         random-util.c
317         random-util.h
318         refcnt.h
319         rm-rf.c
320         rm-rf.h
321         selinux-util.c
322         selinux-util.h
323         set.c
324         set.h
325         sigbus.c
326         sigbus.h
327         signal-util.c
328         signal-util.h
329         siphash24.c
330         siphash24.h
331         smack-util.c
332         smack-util.h
333         socket-util.c
334         socket-util.h
335         sparse-endian.h
336         special.h
337         stat-util.c
338         stat-util.h
339         stdio-util.h
340         string-table.c
341         string-table.h
342         string-util.c
343         string-util.h
344         strv.c
345         strv.h
346         syslog-util.c
347         syslog-util.h
348         terminal-util.c
349         terminal-util.h
350         time-util.c
351         time-util.h
352         umask-util.h
353         unaligned.h
354         unit-def.c
355         unit-def.h
356         unit-name.c
357         unit-name.h
358         user-util.c
359         user-util.h
360         utf8.c
361         utf8.h
362         util.c
363         util.h
364         verbs.c
365         verbs.h
366         virt.c
367         virt.h
368         xattr-util.c
369         xattr-util.h
370 '''.split())
371 #endif // 0
372
373 missing_h = files('missing.h')
374
375 generate_gperfs = find_program('generate-gperfs.py')
376
377 #if 0 /// elogind has only the cap and errno list.
378 # generate_af_list = find_program('generate-af-list.sh')
379 # af_list_txt = custom_target(
380 #         'af-list.txt',
381 #         output : 'af-list.txt',
382 #         command : [generate_af_list, cpp],
383 #         capture : true)
384
385 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
386 # arphrd_list_txt = custom_target(
387 #         'arphrd-list.txt',
388 #         output : 'arphrd-list.txt',
389 #         command : [generate_arphrd_list, cpp],
390 #         capture : true)
391 #endif // 0
392
393 generate_cap_list = find_program('generate-cap-list.sh')
394 cap_list_txt = custom_target(
395         'cap-list.txt',
396         output : 'cap-list.txt',
397 #if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
398 #         command : [generate_cap_list, cpp, config_h, missing_h],
399 #else
400         command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
401 #endif // 0
402         capture : true)
403
404 generate_errno_list = find_program('generate-errno-list.sh')
405 errno_list_txt = custom_target(
406         'errno-list.txt',
407         output : 'errno-list.txt',
408         command : [generate_errno_list, cpp],
409         capture : true)
410
411 generate_socket_protocol_list = find_program('generate-socket-protocol-list.sh')
412 socket_protocol_list_txt = custom_target(
413         'socket-protocol-list.txt',
414         output : 'socket-protocol-list.txt',
415         command : [generate_socket_protocol_list, cpp],
416         capture : true)
417
418 generated_gperf_headers = []
419 #if 0 /// elogind has only the cap and errno list.
420 # foreach item : [['af',     af_list_txt,     'af',         ''],
421 #                 ['arphrd', arphrd_list_txt, 'arphrd',     'ARPHRD_'],
422 #                 ['cap',    cap_list_txt,    'capability', ''],
423 #                 ['errno',  errno_list_txt,  'errno',      ''],
424 #                 ['socket-protocol', socket_protocol_list_txt, 'socket_protocol',     'IPPROTO_']]
425 #else
426 foreach item : [['cap',    cap_list_txt,    'capability', ''],
427                 ['errno',  errno_list_txt,  'errno',      '']]
428 #endif // 0
429
430         fname = '@0@-from-name.gperf'.format(item[0])
431         gperf_file = custom_target(
432                 fname,
433                 input : item[1],
434                 output : fname,
435                 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
436                 capture : true)
437
438         fname = '@0@-from-name.h'.format(item[0])
439         target1 = custom_target(
440                 fname,
441                 input : gperf_file,
442                 output : fname,
443                 command : [gperf,
444                            '-L', 'ANSI-C', '-t', '--ignore-case',
445                            '-N', 'lookup_@0@'.format(item[2]),
446                            '-H', 'hash_@0@_name'.format(item[2]),
447                            '-p', '-C',
448                            '@INPUT@'],
449                 capture : true)
450
451         fname = '@0@-to-name.h'.format(item[0])
452         awkscript = '@0@-to-name.awk'.format(item[0])
453         target2 = custom_target(
454                 fname,
455                 input : [awkscript, item[1]],
456                 output : fname,
457                 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
458                 capture : true)
459
460         generated_gperf_headers += [target1, target2]
461 endforeach
462
463 basic_sources += [missing_h] + generated_gperf_headers
464 basic_gcrypt_sources = files(
465         'gcrypt-util.c',
466         'gcrypt-util.h')
467
468 libbasic = static_library(
469         'basic',
470         basic_sources,
471         include_directories : includes,
472         dependencies : [threads,
473                         libcap,
474 #if 0 /// no blkid in elogind
475 #                         libblkid,
476 #                         libmount,
477 #endif // 0
478                         libselinux],
479         c_args : ['-fvisibility=default'],
480         install : false)
481
482 #if 0 /// elogind does not need gcrypt
483 # # A convenience library that is separate from libbasic to avoid
484 # # unnecessary linking to libgcrypt.
485 # libbasic_gcrypt = static_library(
486 #         'basic-gcrypt',
487 #         basic_gcrypt_sources,
488 #         include_directories : includes,
489 #         dependencies : [libgcrypt],
490 #         c_args : ['-fvisibility=default'])
491 #endif // 0