1 // SPDX-License-Identifier: GPL-2.0
4 #include "util/debug.h"
5 #include "util/header.h"
6 #include <tools/config.h>
10 #include <subcmd/parse-options.h>
16 static struct version version
;
18 static struct option version_options
[] = {
19 OPT_BOOLEAN(0, "build-options", &version
.build_options
,
20 "display the build options"),
24 static const char * const version_usage
[] = {
25 "perf version [<options>]",
29 static void on_off_print(const char *status
)
33 if (!strcmp(status
, "OFF"))
34 color_fprintf(stdout
, PERF_COLOR_RED
, "%-3s", status
);
36 color_fprintf(stdout
, PERF_COLOR_GREEN
, "%-3s", status
);
41 static void status_print(const char *name
, const char *macro
,
44 printf("%22s: ", name
);
46 printf(" # %s\n", macro
);
49 #define STATUS(feature) \
51 if (feature.is_builtin) \
52 status_print(feature.name, feature.macro, "on"); \
54 status_print(feature.name, feature.macro, "OFF"); \
57 static void library_status(void)
59 for (int i
= 0; supported_features
[i
].name
; ++i
)
60 STATUS(supported_features
[i
]);
63 int cmd_version(int argc
, const char **argv
)
65 argc
= parse_options(argc
, argv
, version_options
, version_usage
,
66 PARSE_OPT_STOP_AT_NON_OPTION
);
68 printf("perf version %s\n", perf_version_string
);
70 if (version
.build_options
|| verbose
> 0)