string: factorize skip_spaces and export it to be generally available
[safe/jmp/linux-2.6] / scripts / tags.sh
index 47274dc..d52f7a0 100755 (executable)
@@ -7,7 +7,7 @@
 # Uses the following environment variables:
 # ARCH, SUBARCH, srctree, src, obj
 
-if [ $KBUILD_VERBOSE == 1 ]; then
+if [ "$KBUILD_VERBOSE" = "1" ]; then
        set -x
 fi
 
@@ -18,28 +18,33 @@ ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
           -prune -o"
 
 # Do not use full path is we do not use O=.. builds
-if [ ${src} == ${obj} ]; then
+if [ "${KBUILD_SRC}" = "" ]; then
        tree=
 else
-       tree=${srctree}
+       tree=${srctree}/
+fi
+
+# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
+if [ "${ALLSOURCE_ARCHS}" = "" ]; then
+       ALLSOURCE_ARCHS=${SRCARCH}
 fi
 
 # find sources in arch/$ARCH
 find_arch_sources()
 {
-       find ${tree}arch/$1 $ignore -name $2 -print;
+       find ${tree}arch/$1 $ignore -name "$2" -print;
 }
 
 # find sources in arch/$1/include
 find_arch_include_sources()
 {
-       find ${tree}arch/$1/include $ignore -name $2 -print;
+       find ${tree}arch/$1/include $ignore -name "$2" -print;
 }
 
 # find sources in include/
 find_include_sources()
 {
-       find ${tree}include $ignore -name config -prune -o -name $1 -print;
+       find ${tree}include $ignore -name config -prune -o -name "$1" -print;
 }
 
 # find sources in rest of tree
@@ -48,32 +53,38 @@ find_other_sources()
 {
        find ${tree}* $ignore \
             \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
-              -name $1 -print;
+              -name "$1" -print;
 }
 
 find_sources()
 {
-       find_arch_sources $1 $2
-       find_include_sources $2
-       find_other_sources $2
+       find_arch_sources $1 "$2"
 }
 
 all_sources()
 {
-       find_sources $SRCARCH *.[chS]
+       for arch in $ALLSOURCE_ARCHS
+       do
+               find_sources $arch '*.[chS]'
+       done
        if [ ! -z "$archinclude" ]; then
-               find_arch_include_sources $archinclude *.[chS]
+               find_arch_include_sources $archinclude '*.[chS]'
        fi
+       find_include_sources '*.[chS]'
+       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()
@@ -84,15 +95,16 @@ docscope()
 
 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                      \
-       --extra=+f --c-kinds=+px                                \
-       --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'
+       -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
+       --extra=+f --c-kinds=-px                                \
+       --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'                  \
+       --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
 
        all_kconfigs | xargs $1 -a                              \
        --langdef=kconfig --language-force=kconfig              \
@@ -110,7 +122,9 @@ exuberant()
 
 emacs()
 {
-       all_sources | xargs $1 -a
+       all_sources | xargs $1 -a                               \
+       --regex='/^ENTRY(\([^)]*\)).*/\1/'                      \
+       --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
 
        all_kconfigs | xargs $1 -a                              \
        --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'
@@ -135,10 +149,10 @@ xtags()
 
 
 # Support um (which uses SUBARCH)
-if [ ${ARCH} == um ]; then
-       if [ $SUBARCH == i386 ]; then
+if [ "${ARCH}" = "um" ]; then
+       if [ "$SUBARCH" = "i386" ]; then
                archinclude=x86
-       elif [ $SUBARCH == x86_64 ]; then
+       elif [ "$SUBARCH" = "x86_64" ]; then
                archinclude=x86
        else
                archinclude=${SUBARCH}
@@ -151,10 +165,12 @@ case "$1" in
                ;;
 
        "tags")
+               rm -f tags
                xtags ctags
                ;;
 
        "TAGS")
+               rm -f TAGS
                xtags etags
                ;;
 esac