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 is we do not use O=.. builds
21 if [ "${KBUILD_SRC}" = "" ]; then
27 # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
28 if [ "${ALLSOURCE_ARCHS}" = "" ]; then
29 ALLSOURCE_ARCHS=${SRCARCH}
32 # find sources in arch/$ARCH
35 for i in $archincludedir; do
36 prune="$prune -wholename $i -prune -o"
38 find ${tree}arch/$1 $ignore $prune -name "$2" -print;
41 # find sources in arch/$1/include
42 find_arch_include_sources()
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;
51 # find sources in include/
52 find_include_sources()
54 find ${tree}include $ignore -name config -prune -o -name "$1" -print;
57 # find sources in rest of tree
58 # we could benefit from a list of dirs to search in here
61 find ${tree}* $ignore \
62 \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
68 find_arch_sources $1 "$2"
73 find_arch_include_sources ${SRCARCH} '*.[chS]'
74 if [ ! -z "$archinclude" ]; then
75 find_arch_include_sources $archinclude '*.[chS]'
77 find_include_sources '*.[chS]'
78 for arch in $ALLSOURCE_ARCHS
80 find_sources $arch '*.[chS]'
82 find_other_sources '*.[chS]'
87 for arch in $ALLSOURCE_ARCHS; do
88 find_sources $arch 'Kconfig*'
90 find_other_sources 'Kconfig*'
95 find_sources $ALLSOURCE_ARCHS "defconfig"
100 # always use absolute paths for cscope, as recommended by cscope
104 *) tree=$PWD/$tree ;;
106 (cd /; echo \-k; echo \-q; all_sources) > cscope.files
107 cscope -b -f cscope.out
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 \
118 -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
119 --extra=+f --c-kinds=-px \
120 --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
121 --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
123 all_kconfigs | xargs $1 -a \
124 --langdef=kconfig --language-force=kconfig \
125 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'
127 all_kconfigs | xargs $1 -a \
128 --langdef=kconfig --language-force=kconfig \
129 --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/'
131 all_defconfigs | xargs -r $1 -a \
132 --langdef=dotconfig --language-force=dotconfig \
133 --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
139 all_sources | xargs $1 -a \
140 --regex='/^ENTRY(\([^)]*\)).*/\1/' \
141 --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
143 all_kconfigs | xargs $1 -a \
144 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
146 all_kconfigs | xargs $1 -a \
147 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/'
149 all_defconfigs | xargs -r $1 -a \
150 --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'
155 if $1 --version 2>&1 | grep -iq exuberant; then
157 elif $1 --version 2>&1 | grep -iq emacs; then
160 all_sources | xargs $1 -a
165 # Support um (which uses SUBARCH)
166 if [ "${ARCH}" = "um" ]; then
167 if [ "$SUBARCH" = "i386" ]; then
169 elif [ "$SUBARCH" = "x86_64" ]; then
172 archinclude=${SUBARCH}