]> nv-tegra.nvidia Code Review - linux-3.10.git/blobdiff - scripts/tags.sh
kbuild: Fix gcc -x syntax
[linux-3.10.git] / scripts / tags.sh
index 4e7547209852b13fa1844cae687af17bad217564..cff8faad73d15dab529f71943e5c5544b2ad9217 100755 (executable)
@@ -5,7 +5,7 @@
 # mode may be any of: tags, TAGS, cscope
 #
 # Uses the following environment variables:
-# ARCH, SUBARCH, srctree, src, obj
+# ARCH, SUBARCH, SRCARCH, srctree, src, obj
 
 if [ "$KBUILD_VERBOSE" = "1" ]; then
        set -x
@@ -17,23 +17,48 @@ ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
           -name .git )                                   \
           -prune -o"
 
-# Do not use full path is we do not use O=.. builds
+# Do not use full path if we do not use O=.. builds
+# Use make O=. {tags|cscope}
+# to force full paths for a non-O= build
 if [ "${KBUILD_SRC}" = "" ]; then
        tree=
 else
        tree=${srctree}/
 fi
 
+# Find all available archs
+find_all_archs()
+{
+       ALLSOURCE_ARCHS=""
+       for arch in `ls ${tree}arch`; do
+               ALLSOURCE_ARCHS="${ALLSOURCE_ARCHS} "${arch##\/}
+       done
+}
+
+# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
+if [ "${ALLSOURCE_ARCHS}" = "" ]; then
+       ALLSOURCE_ARCHS=${SRCARCH}
+elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then
+       find_all_archs
+fi
+
 # find sources in arch/$ARCH
 find_arch_sources()
 {
-       find ${tree}arch/$1 $ignore -name "$2" -print;
+       for i in $archincludedir; do
+               prune="$prune -wholename $i -prune -o"
+       done
+       find ${tree}arch/$1 $ignore $prune -name "$2" -print;
 }
 
 # find sources in arch/$1/include
 find_arch_include_sources()
 {
-       find ${tree}arch/$1/include $ignore -name "$2" -print;
+       include=$(find ${tree}arch/$1/ -name include -type d);
+       if [ -n "$include" ]; then
+               archincludedir="$archincludedir $include"
+               find $include $ignore -name "$2" -print;
+       fi
 }
 
 # find sources in include/
@@ -54,26 +79,33 @@ find_other_sources()
 find_sources()
 {
        find_arch_sources $1 "$2"
-       find_include_sources "$2"
-       find_other_sources "$2"
 }
 
 all_sources()
 {
-       find_sources $SRCARCH '*.[chS]'
+       find_arch_include_sources ${SRCARCH} '*.[chS]'
        if [ ! -z "$archinclude" ]; then
                find_arch_include_sources $archinclude '*.[chS]'
        fi
+       find_include_sources '*.[chS]'
+       for arch in $ALLSOURCE_ARCHS
+       do
+               find_sources $arch '*.[chS]'
+       done
+       find_other_sources '*.[chS]'
 }
 
 all_kconfigs()
 {
-       find_sources $SRCARCH 'Kconfig*'
+       for arch in $ALLSOURCE_ARCHS; do
+               find_sources $arch 'Kconfig*'
+       done
+       find_other_sources 'Kconfig*'
 }
 
 all_defconfigs()
 {
-       find_sources $SRCARCH "defconfig"
+       find_sources $ALLSOURCE_ARCHS "defconfig"
 }
 
 docscope()
@@ -82,17 +114,47 @@ docscope()
        cscope -b -f cscope.out
 }
 
+dogtags()
+{
+       all_sources | gtags -i -f -
+}
+
 exuberant()
 {
-       all_sources > all
        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                      \
+       -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
        --extra=+f --c-kinds=+px                                \
-       --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'
+       --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/'        \
+       --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \
+       --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/'               \
+       --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/'     \
+       --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/'                     \
+       --regex-c++='/PAGEFLAG\(([^,)]*).*/SetPage\1/'                  \
+       --regex-c++='/PAGEFLAG\(([^,)]*).*/ClearPage\1/'                \
+       --regex-c++='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/'           \
+       --regex-c++='/TESTPAGEFLAG\(([^,)]*).*/Page\1/'                 \
+       --regex-c++='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/'               \
+       --regex-c++='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/'           \
+       --regex-c++='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/'       \
+       --regex-c++='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/'     \
+       --regex-c++='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/'           \
+       --regex-c++='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/'       \
+       --regex-c++='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/'              \
+       --regex-c++='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/'            \
+       --regex-c++='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/'               \
+       --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/'            \
+       --regex-c++='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/'          \
+       --regex-c++='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/'          \
+       --regex-c++='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'      \
+       --regex-c++='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/'  \
+       --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
+       --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
+       --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
        all_kconfigs | xargs $1 -a                              \
        --langdef=kconfig --language-force=kconfig              \
@@ -105,12 +167,37 @@ exuberant()
        all_defconfigs | xargs -r $1 -a                         \
        --langdef=dotconfig --language-force=dotconfig          \
        --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'
-
 }
 
 emacs()
 {
-       all_sources | xargs $1 -a
+       all_sources | xargs $1 -a                               \
+       --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/'            \
+       --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'   \
+       --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/'          \
+       --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \
+       --regex='/PAGEFLAG\(([^,)]*).*/Page\1/'                 \
+       --regex='/PAGEFLAG\(([^,)]*).*/SetPage\1/'              \
+       --regex='/PAGEFLAG\(([^,)]*).*/ClearPage\1/'            \
+       --regex='/TESTSETFLAG\(([^,)]*).*/TestSetPage\1/'       \
+       --regex='/TESTPAGEFLAG\(([^,)]*).*/Page\1/'             \
+       --regex='/SETPAGEFLAG\(([^,)]*).*/SetPage\1/'           \
+       --regex='/__SETPAGEFLAG\(([^,)]*).*/__SetPage\1/'       \
+       --regex='/TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/'   \
+       --regex='/__TESTCLEARFLAG\(([^,)]*).*/TestClearPage\1/' \
+       --regex='/CLEARPAGEFLAG\(([^,)]*).*/ClearPage\1/'       \
+       --regex='/__CLEARPAGEFLAG\(([^,)]*).*/__ClearPage\1/'   \
+       --regex='/__PAGEFLAG\(([^,)]*).*/__SetPage\1/'          \
+       --regex='/__PAGEFLAG\(([^,)]*).*/__ClearPage\1/'        \
+       --regex='/PAGEFLAG_FALSE\(([^,)]*).*/Page\1/'           \
+       --regex='/TESTSCFLAG\(([^,)]*).*/TestSetPage\1/'        \
+       --regex='/TESTSCFLAG\(([^,)]*).*/TestClearPage\1/'      \
+       --regex='/SETPAGEFLAG_NOOP\(([^,)]*).*/SetPage\1/'      \
+       --regex='/CLEARPAGEFLAG_NOOP\(([^,)]*).*/ClearPage\1/'  \
+       --regex='/__CLEARPAGEFLAG_NOOP\(([^,)]*).*/__ClearPage\1/' \
+       --regex='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \
+       --regex='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \
+       --regex='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/'
 
        all_kconfigs | xargs $1 -a                              \
        --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
@@ -145,16 +232,30 @@ if [ "${ARCH}" = "um" ]; then
        fi
 fi
 
+remove_structs=
 case "$1" in
        "cscope")
                docscope
                ;;
 
+       "gtags")
+               dogtags
+               ;;
+
        "tags")
+               rm -f tags
                xtags ctags
+               remove_structs=y
                ;;
 
        "TAGS")
+               rm -f TAGS
                xtags etags
+               remove_structs=y
                ;;
 esac
+
+# Remove structure forward declarations.
+if [ -n "$remove_structs" ]; then
+    LANG=C sed -i -e '/^\([a-zA-Z_][a-zA-Z0-9_]*\)\t.*\t\/\^struct \1;.*\$\/;"\tx$/d' $1
+fi