Blame view
scripts/tags.sh
3.52 KB
a680eedc6
|
1 2 3 4 5 6 7 8 |
#!/bin/sh # Generate tags or cscope files # Usage tags.sh <mode> # # mode may be any of: tags, TAGS, cscope # # Uses the following environment variables: # ARCH, SUBARCH, srctree, src, obj |
a6ba0cb35
|
9 |
if [ "$KBUILD_VERBOSE" = "1" ]; then |
a680eedc6
|
10 11 12 13 14 15 16 17 18 19 |
set -x fi # This is a duplicate of RCS_FIND_IGNORE without escaped '()' ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ -name CVS -o -name .pc -o -name .hg -o \ -name .git ) \ -prune -o" # Do not use full path is we do not use O=.. builds |
a6ba0cb35
|
20 |
if [ "${KBUILD_SRC}" = "" ]; then |
a680eedc6
|
21 22 |
tree= else |
709cc372c
|
23 |
tree=${srctree}/ |
a680eedc6
|
24 25 26 27 28 |
fi # find sources in arch/$ARCH find_arch_sources() { |
709cc372c
|
29 |
find ${tree}arch/$1 $ignore -name "$2" -print; |
a680eedc6
|
30 31 32 33 34 |
} # find sources in arch/$1/include find_arch_include_sources() { |
709cc372c
|
35 |
find ${tree}arch/$1/include $ignore -name "$2" -print; |
a680eedc6
|
36 37 38 39 40 |
} # find sources in include/ find_include_sources() { |
709cc372c
|
41 |
find ${tree}include $ignore -name config -prune -o -name "$1" -print; |
a680eedc6
|
42 43 44 45 46 47 48 49 |
} # find sources in rest of tree # we could benefit from a list of dirs to search in here find_other_sources() { find ${tree}* $ignore \ \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ |
709cc372c
|
50 |
-name "$1" -print; |
a680eedc6
|
51 52 53 54 |
} find_sources() { |
709cc372c
|
55 56 57 |
find_arch_sources $1 "$2" find_include_sources "$2" find_other_sources "$2" |
a680eedc6
|
58 59 60 61 |
} all_sources() { |
709cc372c
|
62 |
find_sources $SRCARCH '*.[chS]' |
a680eedc6
|
63 |
if [ ! -z "$archinclude" ]; then |
709cc372c
|
64 |
find_arch_include_sources $archinclude '*.[chS]' |
a680eedc6
|
65 66 67 68 69 |
fi } all_kconfigs() { |
709cc372c
|
70 |
find_sources $SRCARCH 'Kconfig*' |
a680eedc6
|
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
} all_defconfigs() { find_sources $SRCARCH "defconfig" } docscope() { (echo \-k; echo \-q; all_sources) > cscope.files cscope -b -f cscope.out } exuberant() { |
a680eedc6
|
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
all_sources | xargs $1 -a \ -I __initdata,__exitdata,__acquires,__releases \ -I __read_mostly,____cacheline_aligned \ -I ____cacheline_aligned_in_smp \ -I ____cacheline_internodealigned_in_smp \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ --extra=+f --c-kinds=+px \ --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' all_kconfigs | xargs $1 -a \ --langdef=kconfig --language-force=kconfig \ --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' all_defconfigs | xargs -r $1 -a \ --langdef=dotconfig --language-force=dotconfig \ --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' } emacs() { all_sources | xargs $1 -a all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' all_kconfigs | xargs $1 -a \ --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' all_defconfigs | xargs -r $1 -a \ --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' } xtags() { if $1 --version 2>&1 | grep -iq exuberant; then exuberant $1 elif $1 --version 2>&1 | grep -iq emacs; then emacs $1 else all_sources | xargs $1 -a fi } # Support um (which uses SUBARCH) |
a6ba0cb35
|
136 137 |
if [ "${ARCH}" = "um" ]; then if [ "$SUBARCH" = "i386" ]; then |
a680eedc6
|
138 |
archinclude=x86 |
a6ba0cb35
|
139 |
elif [ "$SUBARCH" = "x86_64" ]; then |
a680eedc6
|
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
archinclude=x86 else archinclude=${SUBARCH} fi fi case "$1" in "cscope") docscope ;; "tags") xtags ctags ;; "TAGS") xtags etags ;; esac |