1 // SPDX-License-Identifier: GPL-2.0
5 #include <tools/config.h>
9 #include <subcmd/parse-options.h>
17 static struct version version
;
19 static struct option version_options
[] = {
20 OPT_BOOLEAN(0, "build-options", &version
.build_options
,
21 "display the build options"),
25 static const char * const version_usage
[] = {
26 "perf version [<options>]",
30 static void on_off_print(const char *status
)
34 if (!strcmp(status
, "OFF"))
35 color_fprintf(stdout
, PERF_COLOR_RED
, "%-3s", status
);
37 color_fprintf(stdout
, PERF_COLOR_GREEN
, "%-3s", status
);
42 static void status_print(const char *name
, const char *macro
,
45 printf("%22s: ", name
);
47 printf(" # %s\n", macro
);
50 #define STATUS(__d, __m) \
52 if (IS_BUILTIN(__d)) \
53 status_print(#__m, #__d, "on"); \
55 status_print(#__m, #__d, "OFF"); \
58 static void library_status(void)
60 STATUS(HAVE_DWARF_SUPPORT
, dwarf
);
61 STATUS(HAVE_DWARF_GETLOCATIONS_SUPPORT
, dwarf_getlocations
);
62 STATUS(HAVE_GLIBC_SUPPORT
, glibc
);
63 STATUS(HAVE_GTK2_SUPPORT
, gtk2
);
64 #ifndef HAVE_SYSCALL_TABLE_SUPPORT
65 STATUS(HAVE_LIBAUDIT_SUPPORT
, libaudit
);
67 STATUS(HAVE_SYSCALL_TABLE_SUPPORT
, syscall_table
);
68 STATUS(HAVE_LIBBFD_SUPPORT
, libbfd
);
69 STATUS(HAVE_LIBELF_SUPPORT
, libelf
);
70 STATUS(HAVE_LIBNUMA_SUPPORT
, libnuma
);
71 STATUS(HAVE_LIBNUMA_SUPPORT
, numa_num_possible_cpus
);
72 STATUS(HAVE_LIBPERL_SUPPORT
, libperl
);
73 STATUS(HAVE_LIBPYTHON_SUPPORT
, libpython
);
74 STATUS(HAVE_SLANG_SUPPORT
, libslang
);
75 STATUS(HAVE_LIBCRYPTO_SUPPORT
, libcrypto
);
76 STATUS(HAVE_LIBUNWIND_SUPPORT
, libunwind
);
77 STATUS(HAVE_DWARF_SUPPORT
, libdw
-dwarf
-unwind
);
78 STATUS(HAVE_ZLIB_SUPPORT
, zlib
);
79 STATUS(HAVE_LZMA_SUPPORT
, lzma
);
80 STATUS(HAVE_AUXTRACE_SUPPORT
, get_cpuid
);
81 STATUS(HAVE_LIBBPF_SUPPORT
, bpf
);
82 STATUS(HAVE_AIO_SUPPORT
, aio
);
83 STATUS(HAVE_ZSTD_SUPPORT
, zstd
);
86 int cmd_version(int argc
, const char **argv
)
88 argc
= parse_options(argc
, argv
, version_options
, version_usage
,
89 PARSE_OPT_STOP_AT_NON_OPTION
);
91 printf("perf version %s\n", perf_version_string
);
93 if (version
.build_options
|| version_verbose
== 1)