]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - scripts/tags.sh
bootchart: improve output based on Dave Jones' feedback
[mirror_ubuntu-artful-kernel.git] / scripts / tags.sh
CommitLineData
a680eedc
SR
1#!/bin/sh
2# Generate tags or cscope files
3# Usage tags.sh <mode>
4#
5# mode may be any of: tags, TAGS, cscope
6#
7# Uses the following environment variables:
8# ARCH, SUBARCH, srctree, src, obj
9
a6ba0cb3 10if [ "$KBUILD_VERBOSE" = "1" ]; then
a680eedc
SR
11 set -x
12fi
13
14# This is a duplicate of RCS_FIND_IGNORE without escaped '()'
15ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
16 -name CVS -o -name .pc -o -name .hg -o \
17 -name .git ) \
18 -prune -o"
19
20# Do not use full path is we do not use O=.. builds
a6ba0cb3 21if [ "${KBUILD_SRC}" = "" ]; then
a680eedc
SR
22 tree=
23else
709cc372 24 tree=${srctree}/
a680eedc
SR
25fi
26
27# find sources in arch/$ARCH
28find_arch_sources()
29{
709cc372 30 find ${tree}arch/$1 $ignore -name "$2" -print;
a680eedc
SR
31}
32
33# find sources in arch/$1/include
34find_arch_include_sources()
35{
709cc372 36 find ${tree}arch/$1/include $ignore -name "$2" -print;
a680eedc
SR
37}
38
39# find sources in include/
40find_include_sources()
41{
709cc372 42 find ${tree}include $ignore -name config -prune -o -name "$1" -print;
a680eedc
SR
43}
44
45# find sources in rest of tree
46# we could benefit from a list of dirs to search in here
47find_other_sources()
48{
49 find ${tree}* $ignore \
50 \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
709cc372 51 -name "$1" -print;
a680eedc
SR
52}
53
54find_sources()
55{
709cc372
JS
56 find_arch_sources $1 "$2"
57 find_include_sources "$2"
58 find_other_sources "$2"
a680eedc
SR
59}
60
61all_sources()
62{
709cc372 63 find_sources $SRCARCH '*.[chS]'
a680eedc 64 if [ ! -z "$archinclude" ]; then
709cc372 65 find_arch_include_sources $archinclude '*.[chS]'
a680eedc
SR
66 fi
67}
68
69all_kconfigs()
70{
709cc372 71 find_sources $SRCARCH 'Kconfig*'
a680eedc
SR
72}
73
74all_defconfigs()
75{
76 find_sources $SRCARCH "defconfig"
77}
78
79docscope()
80{
81 (echo \-k; echo \-q; all_sources) > cscope.files
82 cscope -b -f cscope.out
83}
84
85exuberant()
86{
a680eedc
SR
87 all_sources | xargs $1 -a \
88 -I __initdata,__exitdata,__acquires,__releases \
89 -I __read_mostly,____cacheline_aligned \
90 -I ____cacheline_aligned_in_smp \
91 -I ____cacheline_internodealigned_in_smp \
92 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
93 --extra=+f --c-kinds=+px \
94 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'
95
96 all_kconfigs | xargs $1 -a \
97 --langdef=kconfig --language-force=kconfig \
98 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
99
100 all_kconfigs | xargs $1 -a \
101 --langdef=kconfig --language-force=kconfig \
102 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
103
104 all_defconfigs | xargs -r $1 -a \
105 --langdef=dotconfig --language-force=dotconfig \
106 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
107
108}
109
110emacs()
111{
112 all_sources | xargs $1 -a
113
114 all_kconfigs | xargs $1 -a \
115 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
116
117 all_kconfigs | xargs $1 -a \
118 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
119
120 all_defconfigs | xargs -r $1 -a \
121 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'
122}
123
124xtags()
125{
126 if $1 --version 2>&1 | grep -iq exuberant; then
127 exuberant $1
128 elif $1 --version 2>&1 | grep -iq emacs; then
129 emacs $1
130 else
131 all_sources | xargs $1 -a
132 fi
133}
134
135
136# Support um (which uses SUBARCH)
a6ba0cb3
JS
137if [ "${ARCH}" = "um" ]; then
138 if [ "$SUBARCH" = "i386" ]; then
a680eedc 139 archinclude=x86
a6ba0cb3 140 elif [ "$SUBARCH" = "x86_64" ]; then
a680eedc
SR
141 archinclude=x86
142 else
143 archinclude=${SUBARCH}
144 fi
145fi
146
147case "$1" in
148 "cscope")
149 docscope
150 ;;
151
152 "tags")
153 xtags ctags
154 ;;
155
156 "TAGS")
157 xtags etags
158 ;;
159esac