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