]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/build.c
dissect: add --make-archive option to convert DDI to tarball
[thirdparty/systemd.git] / src / basic / build.c
CommitLineData
91b79ba8
ZJS
1/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
d6b4d1c7
ZJS
3#include <stdio.h>
4
4453ebe4 5#include "alloc-util.h"
91b79ba8 6#include "build.h"
4453ebe4 7#include "extract-word.h"
d6b4d1c7 8#include "macro.h"
4453ebe4
LP
9#include "string-util.h"
10#include "terminal-util.h"
c47511da 11#include "version.h"
91b79ba8
ZJS
12
13const char* const systemd_features =
14
15 /* PAM and MAC frameworks */
16
17#if HAVE_PAM
18 "+PAM"
19#else
20 "-PAM"
21#endif
22
23#if HAVE_AUDIT
24 " +AUDIT"
25#else
26 " -AUDIT"
27#endif
28
29#if HAVE_SELINUX
30 " +SELINUX"
31#else
32 " -SELINUX"
33#endif
34
35#if HAVE_APPARMOR
36 " +APPARMOR"
37#else
38 " -APPARMOR"
39#endif
40
41#if ENABLE_IMA
42 " +IMA"
43#else
44 " -IMA"
45#endif
46
47#if ENABLE_SMACK
48 " +SMACK"
49#else
50 " -SMACK"
51#endif
52
53#if HAVE_SECCOMP
54 " +SECCOMP"
55#else
56 " -SECCOMP"
57#endif
58
7e8facb3 59 /* cryptographic libraries */
91b79ba8
ZJS
60
61#if HAVE_GCRYPT
62 " +GCRYPT"
63#else
64 " -GCRYPT"
65#endif
66
67#if HAVE_GNUTLS
68 " +GNUTLS"
69#else
70 " -GNUTLS"
71#endif
72
73#if HAVE_OPENSSL
74 " +OPENSSL"
75#else
76 " -OPENSSL"
77#endif
78
79 /* all other libraries, sorted alphabetically */
80
81#if HAVE_ACL
82 " +ACL"
83#else
84 " -ACL"
85#endif
86
87#if HAVE_BLKID
88 " +BLKID"
89#else
90 " -BLKID"
91#endif
92
93#if HAVE_LIBCURL
94 " +CURL"
95#else
96 " -CURL"
97#endif
98
99#if HAVE_ELFUTILS
100 " +ELFUTILS"
101#else
102 " -ELFUTILS"
103#endif
104
105#if HAVE_LIBFIDO2
106 " +FIDO2"
107#else
108 " -FIDO2"
109#endif
110
111#if HAVE_LIBIDN2
112 " +IDN2"
113#else
114 " -IDN2"
115#endif
116
117#if HAVE_LIBIDN
118 " +IDN"
119#else
120 " -IDN"
121#endif
122
123#if HAVE_LIBIPTC
124 " +IPTC"
125#else
126 " -IPTC"
127#endif
128
129#if HAVE_KMOD
130 " +KMOD"
131#else
132 " -KMOD"
133#endif
134
135#if HAVE_LIBCRYPTSETUP
136 " +LIBCRYPTSETUP"
137#else
138 " -LIBCRYPTSETUP"
139#endif
140
a3c1b0d7
VS
141#if HAVE_LIBCRYPTSETUP_PLUGINS
142 " +LIBCRYPTSETUP_PLUGINS"
143#else
144 " -LIBCRYPTSETUP_PLUGINS"
145#endif
146
91b79ba8
ZJS
147#if HAVE_LIBFDISK
148 " +LIBFDISK"
149#else
150 " -LIBFDISK"
151#endif
152
153#if HAVE_PCRE2
154 " +PCRE2"
155#else
156 " -PCRE2"
157#endif
158
159#if HAVE_PWQUALITY
160 " +PWQUALITY"
161#else
162 " -PWQUALITY"
163#endif
164
165#if HAVE_P11KIT
166 " +P11KIT"
167#else
168 " -P11KIT"
169#endif
170
171#if HAVE_QRENCODE
172 " +QRENCODE"
173#else
174 " -QRENCODE"
175#endif
176
6d39da79
FB
177#if HAVE_TPM2
178 " +TPM2"
179#else
180 " -TPM2"
181#endif
182
91b79ba8
ZJS
183 /* compressors */
184
185#if HAVE_BZIP2
186 " +BZIP2"
187#else
188 " -BZIP2"
189#endif
190
191#if HAVE_LZ4
192 " +LZ4"
193#else
194 " -LZ4"
195#endif
196
197#if HAVE_XZ
198 " +XZ"
199#else
200 " -XZ"
201#endif
202
203#if HAVE_ZLIB
204 " +ZLIB"
205#else
206 " -ZLIB"
207#endif
208
209#if HAVE_ZSTD
210 " +ZSTD"
211#else
212 " -ZSTD"
213#endif
214
215 /* other stuff that doesn't fit above */
216
6b35ed80
YW
217#if BPF_FRAMEWORK
218 " +BPF_FRAMEWORK"
219#else
220 " -BPF_FRAMEWORK"
221#endif
222
91b79ba8
ZJS
223#if HAVE_XKBCOMMON
224 " +XKBCOMMON"
225#else
226 " -XKBCOMMON"
227#endif
228
229#if ENABLE_UTMP
230 " +UTMP"
231#else
232 " -UTMP"
233#endif
234
235#if HAVE_SYSV_COMPAT
236 " +SYSVINIT"
237#else
238 " -SYSVINIT"
239#endif
240
b68f4cad
LP
241#if HAVE_LIBARCHIVE
242 " +LIBARCHIVE"
243#else
244 " -LIBARCHIVE"
245#endif
246
91b79ba8
ZJS
247 " default-hierarchy=" DEFAULT_HIERARCHY_NAME
248 ;
d6b4d1c7 249
4453ebe4
LP
250static char *systemd_features_with_color(void) {
251 const char *p = systemd_features;
252 _cleanup_free_ char *ret = NULL;
253 int r;
254
255 for (;;) {
256 _cleanup_free_ char *word = NULL;
257 char *q;
258
259 r = extract_first_word(&p, &word, NULL, 0);
260 if (r < 0) {
261 log_warning_errno(r, "Cannot split features string, ignoring: %m");
262 return NULL;
263 }
264 if (r == 0)
265 return TAKE_PTR(ret);
266
267 if (ret && !strextend(&ret, " ")) {
268 log_oom_warning();
269 return NULL;
270 }
271
272 if (word[0] == '+')
273 q = strextend(&ret, ANSI_HIGHLIGHT_GREEN, CHAR_TO_STR(word[0]), ANSI_GREEN, word+1, ANSI_NORMAL);
274 else if (word[0] == '-')
275 q = strextend(&ret, ANSI_HIGHLIGHT_RED, CHAR_TO_STR(word[0]), ANSI_RED, word+1, ANSI_NORMAL);
276 else
277 q = strextend(&ret, word);
278 if (!q) {
279 log_oom_warning();
280 return NULL;
281 }
282 }
283}
284
d6b4d1c7 285int version(void) {
4453ebe4
LP
286 _cleanup_free_ char *b = NULL;
287
288 if (colors_enabled())
289 b = systemd_features_with_color();
290
0c90efc9
ZJS
291 printf("%ssystemd " STRINGIFY(PROJECT_VERSION) "%s (" GIT_VERSION ")\n%s\n",
292 ansi_highlight(), ansi_normal(),
4453ebe4 293 b ?: systemd_features);
d6b4d1c7
ZJS
294 return 0;
295}