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