chiark / gitweb /
Move gcrypt-util to basic/
[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 #         bpf-program.c
40 #         bpf-program.h
41 #         btrfs-ctree.h
42 #         btrfs-util.c
43 #         btrfs-util.h
44 #         build.h
45 #         bus-label.c
46 #         bus-label.h
47 #         calendarspec.c
48 #         calendarspec.h
49 #         cap-list.c
50 #         cap-list.h
51 #         capability-util.c
52 #         capability-util.h
53 #         cgroup-util.c
54 #         cgroup-util.h
55 #         chattr-util.c
56 #         chattr-util.h
57 #         clock-util.c
58 #         clock-util.h
59 #         conf-files.c
60 #         conf-files.h
61 #         copy.c
62 #         copy.h
63 #         cpu-set-util.c
64 #         cpu-set-util.h
65 #         crypt-util.c
66 #         crypt-util.h
67 #         def.h
68 #         device-nodes.c
69 #         device-nodes.h
70 #         dirent-util.c
71 #         dirent-util.h
72 #         env-util.c
73 #         env-util.h
74 #         errno-list.c
75 #         errno-list.h
76 #         escape.c
77 #         escape.h
78 #         ether-addr-util.c
79 #         ether-addr-util.h
80 #         exec-util.c
81 #         exec-util.h
82 #         exit-status.c
83 #         exit-status.h
84 #         extract-word.c
85 #         extract-word.h
86 #         fd-util.c
87 #         fd-util.h
88 #         fileio-label.c
89 #         fileio-label.h
90 #         fileio.c
91 #         fileio.h
92 #         format-util.h
93 #         fs-util.c
94 #         fs-util.h
95 #         glob-util.c
96 #         glob-util.h
97 #         gunicode.c
98 #         gunicode.h
99 #         hash-funcs.c
100 #         hash-funcs.h
101 #         hashmap.c
102 #         hashmap.h
103 #         hexdecoct.c
104 #         hexdecoct.h
105 #         hostname-util.c
106 #         hostname-util.h
107 #         in-addr-util.c
108 #         in-addr-util.h
109 #         io-util.c
110 #         io-util.h
111 #         ioprio.h
112 #         journal-importer.c
113 #         journal-importer.h
114 #         khash.c
115 #         khash.h
116 #         label.c
117 #         label.h
118 #         list.h
119 #         locale-util.c
120 #         locale-util.h
121 #         lockfile-util.c
122 #         lockfile-util.h
123 #         log.c
124 #         log.h
125 #         login-util.c
126 #         login-util.h
127 #         macro.h
128 #         memfd-util.c
129 #         memfd-util.h
130 #         mempool.c
131 #         mempool.h
132 #         missing_syscall.h
133 #         mkdir-label.c
134 #         mkdir.c
135 #         mkdir.h
136 #         module-util.h
137 #         mount-util.c
138 #         mount-util.h
139 #         nss-util.h
140 #         ordered-set.c
141 #         ordered-set.h
142 #         parse-util.c
143 #         parse-util.h
144 #         path-util.c
145 #         path-util.h
146 #         prioq.c
147 #         prioq.h
148 #         proc-cmdline.c
149 #         proc-cmdline.h
150 #         process-util.c
151 #         process-util.h
152 #         random-util.c
153 #         random-util.h
154 #         ratelimit.c
155 #         ratelimit.h
156 #         raw-clone.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.c
170 #         set.h
171 #         sigbus.c
172 #         sigbus.h
173 #         signal-util.c
174 #         signal-util.h
175 #         siphash24.c
176 #         siphash24.h
177 #         smack-util.c
178 #         smack-util.h
179 #         socket-label.c
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-name.c
206 #         unit-name.h
207 #         unit-def.c
208 #         unit-def.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_plain = 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         process-util.c
312         process-util.h
313         random-util.c
314         random-util.h
315         refcnt.h
316         rm-rf.c
317         rm-rf.h
318         selinux-util.c
319         selinux-util.h
320         set.c
321         set.h
322         sigbus.c
323         sigbus.h
324         signal-util.c
325         signal-util.h
326         siphash24.c
327         siphash24.h
328         smack-util.c
329         smack-util.h
330         socket-util.c
331         socket-util.h
332         sparse-endian.h
333         stat-util.c
334         stat-util.h
335         stdio-util.h
336         string-table.c
337         string-table.h
338         string-util.c
339         string-util.h
340         strv.c
341         strv.h
342         syslog-util.c
343         syslog-util.h
344         terminal-util.c
345         terminal-util.h
346         time-util.c
347         time-util.h
348         umask-util.h
349         unaligned.h
350         unit-def.c
351         unit-def.h
352         unit-name.c
353         unit-name.h
354         user-util.c
355         user-util.h
356         utf8.c
357         utf8.h
358         util.c
359         util.h
360         verbs.c
361         verbs.h
362         virt.c
363         virt.h
364         xattr-util.c
365         xattr-util.h
366 '''.split())
367 #endif // 0
368
369 missing_h = files('missing.h')
370
371 generate_gperfs = find_program('generate-gperfs.py')
372
373 #if 0 /// elogind has only the cap and errno list.
374 # generate_af_list = find_program('generate-af-list.sh')
375 # af_list_txt = custom_target(
376 #         'af-list.txt',
377 #         output : 'af-list.txt',
378 #         command : [generate_af_list, cpp],
379 #         capture : true)
380
381 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
382 # arphrd_list_txt = custom_target(
383 #         'arphrd-list.txt',
384 #         output : 'arphrd-list.txt',
385 #         command : [generate_arphrd_list, cpp],
386 #         capture : true)
387 #endif // 0
388
389 generate_cap_list = find_program('generate-cap-list.sh')
390 cap_list_txt = custom_target(
391         'cap-list.txt',
392         output : 'cap-list.txt',
393 #if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
394 #         command : [generate_cap_list, cpp, config_h, missing_h],
395 #else
396         command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
397 #endif // 0
398         capture : true)
399
400 generate_errno_list = find_program('generate-errno-list.sh')
401 errno_list_txt = custom_target(
402         'errno-list.txt',
403         output : 'errno-list.txt',
404         command : [generate_errno_list, cpp],
405         capture : true)
406
407 generated_gperf_headers = []
408 #if 0 /// elogind has only the cap and errno list.
409 # foreach item : [['af',     af_list_txt,     'af',         ''],
410 #                 ['arphrd', arphrd_list_txt, 'arphrd',     'ARPHRD_'],
411 #                 ['cap',    cap_list_txt,    'capability', ''],
412 #else
413 foreach item : [['cap',    cap_list_txt,    'capability', ''],
414                 ['errno',  errno_list_txt,  'errno',      '']]
415 #endif // 0
416
417         fname = '@0@-from-name.gperf'.format(item[0])
418         gperf_file = custom_target(
419                 fname,
420                 input : item[1],
421                 output : fname,
422                 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
423                 capture : true)
424
425         fname = '@0@-from-name.h'.format(item[0])
426         target1 = custom_target(
427                 fname,
428                 input : gperf_file,
429                 output : fname,
430                 command : [gperf,
431                            '-L', 'ANSI-C', '-t', '--ignore-case',
432                            '-N', 'lookup_@0@'.format(item[2]),
433                            '-H', 'hash_@0@_name'.format(item[2]),
434                            '-p', '-C',
435                            '@INPUT@'],
436                 capture : true)
437
438         fname = '@0@-to-name.h'.format(item[0])
439         awkscript = '@0@-to-name.awk'.format(item[0])
440         target2 = custom_target(
441                 fname,
442                 input : [awkscript, item[1]],
443                 output : fname,
444                 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
445                 capture : true)
446
447         generated_gperf_headers += [target1, target2]
448 endforeach
449
450 basic_sources += [missing_h] + generated_gperf_headers
451
452 libbasic = static_library(
453         'basic',
454         basic_sources,
455         include_directories : includes,
456         dependencies : [threads,
457                         libcap,
458 #if 0 /// no blkid in elogind
459 #                         libblkid,
460 #endif // 0
461                         libselinux],
462         c_args : ['-fvisibility=default'],
463         install : false)
464
465 # A convenience library that is separate from libbasic to avoid
466 # unnecessary linking to libgcrypt.
467 libbasic_gcrypt = static_library(
468         'basic-gcrypt',
469         'gcrypt-util.c',
470         'gcrypt-util.h',
471         include_directories : includes,
472         dependencies : [libgcrypt],
473         c_args : ['-fvisibility=default'])