chiark / gitweb /
Prep v238: Remove getnameinfo_pretty(), it is no longer used.
[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 = 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         procfs-util.c
321         procfs-util.h
322         process-util.c
323         process-util.h
324         random-util.c
325         random-util.h
326         refcnt.h
327         rm-rf.c
328         rm-rf.h
329         selinux-util.c
330         selinux-util.h
331         set.c
332         set.h
333         sigbus.c
334         sigbus.h
335         signal-util.c
336         signal-util.h
337         siphash24.c
338         siphash24.h
339         smack-util.c
340         smack-util.h
341         socket-util.c
342         socket-util.h
343         sparse-endian.h
344         special.h
345         stat-util.c
346         stat-util.h
347         stdio-util.h
348         string-table.c
349         string-table.h
350         string-util.c
351         string-util.h
352         strv.c
353         strv.h
354         syslog-util.c
355         syslog-util.h
356         terminal-util.c
357         terminal-util.h
358         time-util.c
359         time-util.h
360         umask-util.h
361         unaligned.h
362         unit-def.c
363         unit-def.h
364         unit-name.c
365         unit-name.h
366         user-util.c
367         user-util.h
368         utf8.c
369         utf8.h
370         util.c
371         util.h
372         verbs.c
373         verbs.h
374         virt.c
375         virt.h
376         xattr-util.c
377         xattr-util.h
378 '''.split())
379 #endif // 0
380
381 missing_h = files('missing.h')
382
383 generate_gperfs = find_program('generate-gperfs.py')
384
385 #if 0 /// elogind has only the cap and errno list.
386 # generate_af_list = find_program('generate-af-list.sh')
387 # af_list_txt = custom_target(
388 #         'af-list.txt',
389 #         output : 'af-list.txt',
390 #         command : [generate_af_list, cpp],
391 #         capture : true)
392
393 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
394 # arphrd_list_txt = custom_target(
395 #         'arphrd-list.txt',
396 #         output : 'arphrd-list.txt',
397 #         command : [generate_arphrd_list, cpp],
398 #         capture : true)
399 #endif // 0
400
401 generate_cap_list = find_program('generate-cap-list.sh')
402 cap_list_txt = custom_target(
403         'cap-list.txt',
404         output : 'cap-list.txt',
405 #if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
406 #         command : [generate_cap_list, cpp, config_h, missing_h],
407 #else
408         command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
409 #endif // 0
410         capture : true)
411
412 generate_errno_list = find_program('generate-errno-list.sh')
413 errno_list_txt = custom_target(
414         'errno-list.txt',
415         output : 'errno-list.txt',
416         command : [generate_errno_list, cpp],
417         capture : true)
418
419 generate_socket_protocol_list = find_program('generate-socket-protocol-list.sh')
420 socket_protocol_list_txt = custom_target(
421         'socket-protocol-list.txt',
422         output : 'socket-protocol-list.txt',
423         command : [generate_socket_protocol_list, cpp],
424         capture : true)
425
426 generated_gperf_headers = []
427 #if 0 /// elogind has only the cap and errno list.
428 # foreach item : [['af',     af_list_txt,     'af',         ''],
429 #                 ['arphrd', arphrd_list_txt, 'arphrd',     'ARPHRD_'],
430 #                 ['cap',    cap_list_txt,    'capability', ''],
431 #                 ['errno',  errno_list_txt,  'errno',      ''],
432 #                 ['socket-protocol', socket_protocol_list_txt, 'socket_protocol',     'IPPROTO_']]
433 #else
434 foreach item : [['cap',    cap_list_txt,    'capability', ''],
435                 ['errno',  errno_list_txt,  'errno',      '']]
436 #endif // 0
437
438         fname = '@0@-from-name.gperf'.format(item[0])
439         gperf_file = custom_target(
440                 fname,
441                 input : item[1],
442                 output : fname,
443                 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
444                 capture : true)
445
446         fname = '@0@-from-name.h'.format(item[0])
447         target1 = custom_target(
448                 fname,
449                 input : gperf_file,
450                 output : fname,
451                 command : [gperf,
452                            '-L', 'ANSI-C', '-t', '--ignore-case',
453                            '-N', 'lookup_@0@'.format(item[2]),
454                            '-H', 'hash_@0@_name'.format(item[2]),
455                            '-p', '-C',
456                            '@INPUT@'],
457                 capture : true)
458
459         fname = '@0@-to-name.h'.format(item[0])
460         awkscript = '@0@-to-name.awk'.format(item[0])
461         target2 = custom_target(
462                 fname,
463                 input : [awkscript, item[1]],
464                 output : fname,
465                 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
466                 capture : true)
467
468         generated_gperf_headers += [target1, target2]
469 endforeach
470
471 basic_sources += [missing_h] + generated_gperf_headers
472
473 libbasic = static_library(
474         'basic',
475         basic_sources,
476         include_directories : includes,
477         dependencies : [threads,
478                         libcap,
479 #if 0 /// no blkid in elogind
480 #                         libblkid,
481 #                         libmount,
482 #endif // 0
483                         libselinux],
484         c_args : ['-fvisibility=default'],
485         install : false)
486
487 #if 0 /// elogind does not need gcrypt
488 # # A convenience library that is separate from libbasic to avoid
489 # # unnecessary linking to libgcrypt.
490 # libbasic_gcrypt = static_library(
491 #         'basic-gcrypt',
492 #         'gcrypt-util.c',
493 #         'gcrypt-util.h',
494 #         include_directories : includes,
495 #         dependencies : [libgcrypt],
496 #         c_args : ['-fvisibility=default'])
497 #endif // 0