chiark / gitweb /
Prep v236: Apply missing upstream updates to the build system
[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_plain = 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         signal-util.c
323         signal-util.h
324         siphash24.c
325         siphash24.h
326         smack-util.c
327         smack-util.h
328         socket-util.c
329         socket-util.h
330         sparse-endian.h
331         stat-util.c
332         stat-util.h
333         stdio-util.h
334         string-table.c
335         string-table.h
336         string-util.c
337         string-util.h
338         strv.c
339         strv.h
340         syslog-util.c
341         syslog-util.h
342         terminal-util.c
343         terminal-util.h
344         time-util.c
345         time-util.h
346         umask-util.h
347         unaligned.h
348         unit-name.c
349         unit-name.h
350         user-util.c
351         user-util.h
352         utf8.c
353         utf8.h
354         util.c
355         util.h
356         verbs.c
357         verbs.h
358         virt.c
359         virt.h
360         xattr-util.c
361         xattr-util.h
362 '''.split())
363 #endif // 0
364
365 missing_h = files('missing.h')
366
367 generate_gperfs = find_program('generate-gperfs.py')
368
369 #if 0 /// elogind has only the cap and errno list.
370 # generate_af_list = find_program('generate-af-list.sh')
371 # af_list_txt = custom_target(
372 #         'af-list.txt',
373 #         output : 'af-list.txt',
374 #         command : [generate_af_list, cpp],
375 #         capture : true)
376
377 # generate_arphrd_list = find_program('generate-arphrd-list.sh')
378 # arphrd_list_txt = custom_target(
379 #         'arphrd-list.txt',
380 #         output : 'arphrd-list.txt',
381 #         command : [generate_arphrd_list, cpp],
382 #         capture : true)
383 #endif // 0
384
385 generate_cap_list = find_program('generate-cap-list.sh')
386 cap_list_txt = custom_target(
387         'cap-list.txt',
388         output : 'cap-list.txt',
389 #if 0 /// elogind needs musl_missing.h, so generate_cap_list must know the source root
390 #         command : [generate_cap_list, cpp, config_h, missing_h],
391 #else
392         command : [generate_cap_list, cpp, meson.source_root(), config_h, missing_h],
393 #endif // 0
394         capture : true)
395
396 generate_errno_list = find_program('generate-errno-list.sh')
397 errno_list_txt = custom_target(
398         'errno-list.txt',
399         output : 'errno-list.txt',
400         command : [generate_errno_list, cpp],
401         capture : true)
402
403 generated_gperf_headers = []
404 #if 0 /// elogind has only the cap and errno list.
405 # foreach item : [['af',     af_list_txt,     'af',         ''],
406 #                 ['arphrd', arphrd_list_txt, 'arphrd',     'ARPHRD_'],
407 #                 ['cap',    cap_list_txt,    'capability', ''],
408 #                 ['errno',  errno_list_txt,  'errno',      '']]
409 #else
410 foreach item : [['cap',    cap_list_txt,    'capability', ''],
411                 ['errno',  errno_list_txt,  'errno',      '']]
412 #endif // 0
413
414         fname = '@0@-from-name.gperf'.format(item[0])
415         gperf_file = custom_target(
416                 fname,
417                 input : item[1],
418                 output : fname,
419                 command : [generate_gperfs, item[2], item[3], '@INPUT@'],
420                 capture : true)
421
422         fname = '@0@-from-name.h'.format(item[0])
423         target1 = custom_target(
424                 fname,
425                 input : gperf_file,
426                 output : fname,
427                 command : [gperf,
428                            '-L', 'ANSI-C', '-t', '--ignore-case',
429                            '-N', 'lookup_@0@'.format(item[2]),
430                            '-H', 'hash_@0@_name'.format(item[2]),
431                            '-p', '-C',
432                            '@INPUT@'],
433                 capture : true)
434
435         fname = '@0@-to-name.h'.format(item[0])
436         awkscript = '@0@-to-name.awk'.format(item[0])
437         target2 = custom_target(
438                 fname,
439                 input : [awkscript, item[1]],
440                 output : fname,
441                 command : [awk, '-f', '@INPUT0@', '@INPUT1@'],
442                 capture : true)
443
444         generated_gperf_headers += [target1, target2]
445 endforeach
446
447 basic_sources = basic_sources_plain + [missing_h] + generated_gperf_headers
448
449 libbasic = static_library(
450         'basic',
451         basic_sources,
452         include_directories : includes,
453         dependencies : [threads,
454                         libcap,
455 #if 0 /// no blkid in elogind
456 #                         libblkid,
457 #endif // 0
458                         libselinux,
459                        ],
460         install : false)