Commit | Line | Data |
---|---|---|
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 | 10 | if [ "$KBUILD_VERBOSE" = "1" ]; then |
a680eedc SR |
11 | set -x |
12 | fi | |
13 | ||
14 | # This is a duplicate of RCS_FIND_IGNORE without escaped '()' | |
15 | ignore="( -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 | 21 | if [ "${KBUILD_SRC}" = "" ]; then |
a680eedc SR |
22 | tree= |
23 | else | |
709cc372 | 24 | tree=${srctree}/ |
a680eedc SR |
25 | fi |
26 | ||
4f628248 JS |
27 | # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH |
28 | if [ "${ALLSOURCE_ARCHS}" = "" ]; then | |
29 | ALLSOURCE_ARCHS=${SRCARCH} | |
30 | fi | |
31 | ||
a680eedc SR |
32 | # find sources in arch/$ARCH |
33 | find_arch_sources() | |
34 | { | |
f81b1be4 GL |
35 | for i in $archincludedir; do |
36 | prune="$prune -wholename $i -prune -o" | |
37 | done | |
38 | find ${tree}arch/$1 $ignore $prune -name "$2" -print; | |
a680eedc SR |
39 | } |
40 | ||
41 | # find sources in arch/$1/include | |
42 | find_arch_include_sources() | |
43 | { | |
f81b1be4 GL |
44 | include=$(find ${tree}arch/$1/ -name include -type d); |
45 | if [ -n "$include" ]; then | |
46 | archincludedir="$archincludedir $include" | |
47 | find $include $ignore -name "$2" -print; | |
48 | fi | |
a680eedc SR |
49 | } |
50 | ||
51 | # find sources in include/ | |
52 | find_include_sources() | |
53 | { | |
709cc372 | 54 | find ${tree}include $ignore -name config -prune -o -name "$1" -print; |
a680eedc SR |
55 | } |
56 | ||
57 | # find sources in rest of tree | |
58 | # we could benefit from a list of dirs to search in here | |
59 | find_other_sources() | |
60 | { | |
61 | find ${tree}* $ignore \ | |
62 | \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ | |
709cc372 | 63 | -name "$1" -print; |
a680eedc SR |
64 | } |
65 | ||
66 | find_sources() | |
67 | { | |
709cc372 | 68 | find_arch_sources $1 "$2" |
a680eedc SR |
69 | } |
70 | ||
71 | all_sources() | |
72 | { | |
f81b1be4 | 73 | find_arch_include_sources ${ARCH} '*.[chS]' |
a680eedc | 74 | if [ ! -z "$archinclude" ]; then |
709cc372 | 75 | find_arch_include_sources $archinclude '*.[chS]' |
a680eedc | 76 | fi |
4f628248 | 77 | find_include_sources '*.[chS]' |
f81b1be4 GL |
78 | for arch in $ALLSOURCE_ARCHS |
79 | do | |
80 | find_sources $arch '*.[chS]' | |
81 | done | |
4f628248 | 82 | find_other_sources '*.[chS]' |
a680eedc SR |
83 | } |
84 | ||
85 | all_kconfigs() | |
86 | { | |
953fae66 AD |
87 | for arch in $ALLSOURCE_ARCHS; do |
88 | find_sources $arch 'Kconfig*' | |
89 | done | |
90 | find_other_sources 'Kconfig*' | |
a680eedc SR |
91 | } |
92 | ||
93 | all_defconfigs() | |
94 | { | |
4f628248 | 95 | find_sources $ALLSOURCE_ARCHS "defconfig" |
a680eedc SR |
96 | } |
97 | ||
98 | docscope() | |
99 | { | |
eb8f844c DV |
100 | # always use absolute paths for cscope, as recommended by cscope |
101 | # upstream | |
102 | case "$tree" in | |
103 | /*) ;; | |
104 | *) tree=$PWD/$tree ;; | |
105 | esac | |
106 | (cd /; echo \-k; echo \-q; all_sources) > cscope.files | |
a680eedc SR |
107 | cscope -b -f cscope.out |
108 | } | |
109 | ||
110 | exuberant() | |
111 | { | |
a680eedc SR |
112 | all_sources | xargs $1 -a \ |
113 | -I __initdata,__exitdata,__acquires,__releases \ | |
114 | -I __read_mostly,____cacheline_aligned \ | |
115 | -I ____cacheline_aligned_in_smp \ | |
116 | -I ____cacheline_internodealigned_in_smp \ | |
117 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | |
7db86dc9 SS |
118 | -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ |
119 | --extra=+f --c-kinds=-px \ | |
5123b327 RV |
120 | --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ |
121 | --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' | |
a680eedc SR |
122 | |
123 | all_kconfigs | xargs $1 -a \ | |
124 | --langdef=kconfig --language-force=kconfig \ | |
125 | --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' | |
126 | ||
127 | all_kconfigs | xargs $1 -a \ | |
128 | --langdef=kconfig --language-force=kconfig \ | |
129 | --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' | |
130 | ||
131 | all_defconfigs | xargs -r $1 -a \ | |
132 | --langdef=dotconfig --language-force=dotconfig \ | |
133 | --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' | |
134 | ||
135 | } | |
136 | ||
137 | emacs() | |
138 | { | |
5123b327 RV |
139 | all_sources | xargs $1 -a \ |
140 | --regex='/^ENTRY(\([^)]*\)).*/\1/' \ | |
141 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' | |
a680eedc SR |
142 | |
143 | all_kconfigs | xargs $1 -a \ | |
144 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' | |
145 | ||
146 | all_kconfigs | xargs $1 -a \ | |
147 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' | |
148 | ||
149 | all_defconfigs | xargs -r $1 -a \ | |
150 | --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' | |
151 | } | |
152 | ||
153 | xtags() | |
154 | { | |
155 | if $1 --version 2>&1 | grep -iq exuberant; then | |
156 | exuberant $1 | |
157 | elif $1 --version 2>&1 | grep -iq emacs; then | |
158 | emacs $1 | |
159 | else | |
160 | all_sources | xargs $1 -a | |
161 | fi | |
162 | } | |
163 | ||
164 | ||
165 | # Support um (which uses SUBARCH) | |
a6ba0cb3 JS |
166 | if [ "${ARCH}" = "um" ]; then |
167 | if [ "$SUBARCH" = "i386" ]; then | |
a680eedc | 168 | archinclude=x86 |
a6ba0cb3 | 169 | elif [ "$SUBARCH" = "x86_64" ]; then |
a680eedc SR |
170 | archinclude=x86 |
171 | else | |
172 | archinclude=${SUBARCH} | |
173 | fi | |
174 | fi | |
175 | ||
176 | case "$1" in | |
177 | "cscope") | |
178 | docscope | |
179 | ;; | |
180 | ||
181 | "tags") | |
2e6cb8b0 | 182 | rm -f tags |
a680eedc SR |
183 | xtags ctags |
184 | ;; | |
185 | ||
186 | "TAGS") | |
2e6cb8b0 | 187 | rm -f TAGS |
a680eedc SR |
188 | xtags etags |
189 | ;; | |
190 | esac |