2008-12-03 21:24:13 +00:00
|
|
|
#!/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
|
|
|
|
|
2008-12-10 12:48:38 +00:00
|
|
|
if [ "$KBUILD_VERBOSE" = "1" ]; then
|
2008-12-03 21:24:13 +00:00
|
|
|
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
|
2008-12-10 12:48:38 +00:00
|
|
|
if [ "${KBUILD_SRC}" = "" ]; then
|
2008-12-03 21:24:13 +00:00
|
|
|
tree=
|
|
|
|
else
|
2008-12-10 12:10:13 +00:00
|
|
|
tree=${srctree}/
|
2008-12-03 21:24:13 +00:00
|
|
|
fi
|
|
|
|
|
2009-01-05 06:57:03 +00:00
|
|
|
# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
|
|
|
|
if [ "${ALLSOURCE_ARCHS}" = "" ]; then
|
|
|
|
ALLSOURCE_ARCHS=${SRCARCH}
|
|
|
|
fi
|
|
|
|
|
2008-12-03 21:24:13 +00:00
|
|
|
# find sources in arch/$ARCH
|
|
|
|
find_arch_sources()
|
|
|
|
{
|
2008-12-10 12:10:13 +00:00
|
|
|
find ${tree}arch/$1 $ignore -name "$2" -print;
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# find sources in arch/$1/include
|
|
|
|
find_arch_include_sources()
|
|
|
|
{
|
2008-12-10 12:10:13 +00:00
|
|
|
find ${tree}arch/$1/include $ignore -name "$2" -print;
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# find sources in include/
|
|
|
|
find_include_sources()
|
|
|
|
{
|
2008-12-10 12:10:13 +00:00
|
|
|
find ${tree}include $ignore -name config -prune -o -name "$1" -print;
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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 \
|
2008-12-10 12:10:13 +00:00
|
|
|
-name "$1" -print;
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
find_sources()
|
|
|
|
{
|
2008-12-10 12:10:13 +00:00
|
|
|
find_arch_sources $1 "$2"
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
all_sources()
|
|
|
|
{
|
2009-01-05 06:57:03 +00:00
|
|
|
for arch in $ALLSOURCE_ARCHS
|
|
|
|
do
|
|
|
|
find_sources $arch '*.[chS]'
|
|
|
|
done
|
2008-12-03 21:24:13 +00:00
|
|
|
if [ ! -z "$archinclude" ]; then
|
2008-12-10 12:10:13 +00:00
|
|
|
find_arch_include_sources $archinclude '*.[chS]'
|
2008-12-03 21:24:13 +00:00
|
|
|
fi
|
2009-01-05 06:57:03 +00:00
|
|
|
find_include_sources '*.[chS]'
|
|
|
|
find_other_sources '*.[chS]'
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
all_kconfigs()
|
|
|
|
{
|
2009-02-11 21:24:09 +00:00
|
|
|
for arch in $ALLSOURCE_ARCHS; do
|
|
|
|
find_sources $arch 'Kconfig*'
|
|
|
|
done
|
|
|
|
find_other_sources 'Kconfig*'
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
all_defconfigs()
|
|
|
|
{
|
2009-01-05 06:57:03 +00:00
|
|
|
find_sources $ALLSOURCE_ARCHS "defconfig"
|
2008-12-03 21:24:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
docscope()
|
|
|
|
{
|
2009-11-26 12:34:12 +00:00
|
|
|
# always use absolute paths for cscope, as recommended by cscope
|
|
|
|
# upstream
|
|
|
|
case "$tree" in
|
|
|
|
/*) ;;
|
|
|
|
*) tree=$PWD/$tree ;;
|
|
|
|
esac
|
|
|
|
(cd /; echo \-k; echo \-q; all_sources) > cscope.files
|
2008-12-03 21:24:13 +00:00
|
|
|
cscope -b -f cscope.out
|
|
|
|
}
|
|
|
|
|
|
|
|
exuberant()
|
|
|
|
{
|
|
|
|
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 \
|
2009-09-18 19:49:24 +00:00
|
|
|
-I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \
|
|
|
|
--extra=+f --c-kinds=-px \
|
2009-01-25 13:09:12 +00:00
|
|
|
--regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \
|
|
|
|
--regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/'
|
2008-12-03 21:24:13 +00:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2009-01-25 13:09:12 +00:00
|
|
|
all_sources | xargs $1 -a \
|
|
|
|
--regex='/^ENTRY(\([^)]*\)).*/\1/' \
|
|
|
|
--regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/'
|
2008-12-03 21:24:13 +00:00
|
|
|
|
|
|
|
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)
|
2008-12-10 12:48:38 +00:00
|
|
|
if [ "${ARCH}" = "um" ]; then
|
|
|
|
if [ "$SUBARCH" = "i386" ]; then
|
2008-12-03 21:24:13 +00:00
|
|
|
archinclude=x86
|
2008-12-10 12:48:38 +00:00
|
|
|
elif [ "$SUBARCH" = "x86_64" ]; then
|
2008-12-03 21:24:13 +00:00
|
|
|
archinclude=x86
|
|
|
|
else
|
|
|
|
archinclude=${SUBARCH}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
"cscope")
|
|
|
|
docscope
|
|
|
|
;;
|
|
|
|
|
|
|
|
"tags")
|
2009-04-22 03:38:23 +00:00
|
|
|
rm -f tags
|
2008-12-03 21:24:13 +00:00
|
|
|
xtags ctags
|
|
|
|
;;
|
|
|
|
|
|
|
|
"TAGS")
|
2009-04-22 03:38:23 +00:00
|
|
|
rm -f TAGS
|
2008-12-03 21:24:13 +00:00
|
|
|
xtags etags
|
|
|
|
;;
|
|
|
|
esac
|