xref: /linux/tools/perf/util/generate-cmdlist.sh (revision 34dc1baba215b826e454b8d19e4f24adbeb7d00d)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4echo "/* Automatically generated by $0 */
5struct cmdname_help
6{
7    char name[16];
8    char help[80];
9};
10
11static struct cmdname_help common_cmds[] = {"
12
13sed -n -e 's/^perf-\([^ 	]*\)[ 	].* common.*/\1/p' command-list.txt |
14sort |
15while read cmd
16do
17     sed -n '
18     /^NAME/,/perf-'"$cmd"'/H
19     ${
20            x
21            s/.*perf-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
22	    p
23     }' "Documentation/perf-$cmd.txt"
24done
25
26echo "#ifdef HAVE_LIBELF_SUPPORT"
27sed -n -e 's/^perf-\([^ 	]*\)[ 	].* full.*/\1/p' command-list.txt |
28sort |
29while read cmd
30do
31     sed -n '
32     /^NAME/,/perf-'"$cmd"'/H
33     ${
34            x
35            s/.*perf-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
36	    p
37     }' "Documentation/perf-$cmd.txt"
38done
39echo "#endif /* HAVE_LIBELF_SUPPORT */"
40
41echo "#if defined(HAVE_LIBTRACEEVENT) && (defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE_SUPPORT))"
42sed -n -e 's/^perf-\([^ 	]*\)[ 	].* audit*/\1/p' command-list.txt |
43sort |
44while read cmd
45do
46     sed -n '
47     /^NAME/,/perf-'"$cmd"'/H
48     ${
49            x
50            s/.*perf-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
51	    p
52     }' "Documentation/perf-$cmd.txt"
53done
54echo "#endif /* HAVE_LIBTRACEEVENT && (HAVE_LIBAUDIT_SUPPORT || HAVE_SYSCALL_TABLE_SUPPORT) */"
55
56echo "#ifdef HAVE_LIBTRACEEVENT"
57sed -n -e 's/^perf-\([^ 	]*\)[ 	].* traceevent.*/\1/p' command-list.txt |
58sort |
59while read cmd
60do
61     sed -n '
62     /^NAME/,/perf-'"$cmd"'/H
63     ${
64            x
65            s/.*perf-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
66            p
67     }' "Documentation/perf-$cmd.txt"
68done
69echo "#endif /* HAVE_LIBTRACEEVENT */"
70echo "};"
71