2 # Generate tags or cscope files
5 # mode may be any of: tags, TAGS, cscope
7 # Uses the following environment variables:
8 # ARCH, SUBARCH, SRCARCH, srctree, src, obj
10 if [ "$KBUILD_VERBOSE" = "1" ]; then
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 \
20 # Do not use full path if we do not use O=.. builds
21 if [ "${KBUILD_SRC}" = "" ]; then
27 # Find all available archs
31 for arch
in `ls ${tree}arch`; do
32 ALLSOURCE_ARCHS
="${ALLSOURCE_ARCHS} "${arch##\/}
36 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
37 if [ "${ALLSOURCE_ARCHS}" = "" ]; then
38 ALLSOURCE_ARCHS
=${SRCARCH}
39 elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then
43 # find sources in arch/$ARCH
46 for i
in $archincludedir; do
47 prune
="$prune -wholename $i -prune -o"
49 find ${tree}arch
/$1 $ignore $prune -name "$2" -print;
52 # find sources in arch/$1/include
53 find_arch_include_sources
()
55 include
=$
(find ${tree}arch
/$1/ -name include
-type d
);
56 if [ -n "$include" ]; then
57 archincludedir
="$archincludedir $include"
58 find $include $ignore -name "$2" -print;
62 # find sources in include/
63 find_include_sources
()
65 find ${tree}include
$ignore -name config
-prune -o -name "$1" -print;
68 # find sources in rest of tree
69 # we could benefit from a list of dirs to search in here
72 find ${tree}* $ignore \
73 \
( -name include
-o -name arch
-o -name '.tmp_*' \
) -prune -o \
79 find_arch_sources
$1 "$2"
84 find_arch_include_sources
${SRCARCH} '*.[chS]'
85 if [ ! -z "$archinclude" ]; then
86 find_arch_include_sources
$archinclude '*.[chS]'
88 find_include_sources
'*.[chS]'
89 for arch
in $ALLSOURCE_ARCHS
91 find_sources
$arch '*.[chS]'
93 find_other_sources
'*.[chS]'
98 for arch
in $ALLSOURCE_ARCHS; do
99 find_sources
$arch 'Kconfig*'
101 find_other_sources
'Kconfig*'
106 find_sources
$ALLSOURCE_ARCHS "defconfig"
111 # always use absolute paths for cscope, as recommended by cscope
115 *) tree
=$PWD/$tree ;;
117 (cd /; echo \
-k; echo \
-q; all_sources
) > cscope.files
118 cscope
-b -f cscope.out
123 all_sources |
xargs $1 -a \
124 -I __initdata
,__exitdata
,__acquires
,__releases \
125 -I __read_mostly
,____cacheline_aligned \
126 -I ____cacheline_aligned_in_smp \
127 -I ____cacheline_internodealigned_in_smp \
128 -I EXPORT_SYMBOL
,EXPORT_SYMBOL_GPL \
129 -I DEFINE_TRACE
,EXPORT_TRACEPOINT_SYMBOL
,EXPORT_TRACEPOINT_SYMBOL_GPL \
130 --extra=+f
--c-kinds=-px \
131 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
132 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
134 all_kconfigs |
xargs $1 -a \
135 --langdef=kconfig
--language-force=kconfig \
136 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
138 all_kconfigs |
xargs $1 -a \
139 --langdef=kconfig
--language-force=kconfig \
140 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
142 all_defconfigs |
xargs -r $1 -a \
143 --langdef=dotconfig
--language-force=dotconfig \
144 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
150 all_sources |
xargs $1 -a \
151 --regex='/^ENTRY(\([^)]*\)).*/\1/' \
152 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
154 all_kconfigs |
xargs $1 -a \
155 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
157 all_kconfigs |
xargs $1 -a \
158 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
160 all_defconfigs |
xargs -r $1 -a \
161 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'
166 if $1 --version 2>&1 |
grep -iq exuberant
; then
168 elif $1 --version 2>&1 |
grep -iq emacs
; then
171 all_sources |
xargs $1 -a
176 # Support um (which uses SUBARCH)
177 if [ "${ARCH}" = "um" ]; then
178 if [ "$SUBARCH" = "i386" ]; then
180 elif [ "$SUBARCH" = "x86_64" ]; then
183 archinclude
=${SUBARCH}