Q:

Linux kernel makefile cscope target

When I generate Linux kernel cscope database by issuing make cscope I get database file along with  a list of files with relative path. This is a problem for me because later on when I attach that external kernel's database in vim editor from whatever directory but kernel's I can easily search for specific symbol BUT I can't open file that symbol is contained in.
I've written the next bash script
#!/bin/bash

SNAME="$0"
SNAME=${SNAME##*/}

function usage()
{
    echo Generate Linux kernel cscope database
    echo "Usage: $SNAME [PATH]"
    echo -n "You must provide this script with an ABSOLUTE path of your "
    echo "kernel's root directory"
}

if [[ -z "$1" ]]; then
    usage
    exit -1
fi

KDIR="$1"

echo -n "Collecting a list of files... "
if find "$KDIR" -path "${KDIR}/arch/*" ! -path "${KDIR}/arch/x86*" -prune -o \
        -path "${KDIR}/include/asm-*" \
        ! -path "${KDIR}/include/asm-generic*" \
        ! -path "${KDIR}/include/asm-x86*" -prune -o \
        -path "${KDIR}/tmp*" -prune -o \
        -path "${KDIR}/Documentation*" -prune -o \
        -path "${KDIR}/scripts*" -prune -o \
        -name "*.[chxsS]" -print > cscope.files; then
    echo done
else
    echo failed
fi

echo -n "Building cscope database... "
cscope -k -qb && echo done || echo failed

that collects all files I need (x86/x86_64 architecture) using absolute path and then I successfully build cscope database manually. But I think it must be some easier way to accomplish this. Maybe some Makefile's target like make cscope_abs or make cscope_ext that I have not found yet.
Any suggestions?

A:

make cscope

or for your specific case - 
ARCH=x86 make cscope

A:

First, it is simpler to create a cscope database specific to a particular architecture as follows : In Linux kernel's top folder, run
ARCH=x86 make cscope

This creates a cscope with relative paths. 
Now you can ask vim to interpret the paths relative to the location of the cscope.out file in one of two ways:
Way 1 : Use cscoperelative. Output of :help csre :
If 'cscoperelative' is set, then in absence of a prefix given to cscope
(prefix is the argument of -P option of cscope), basename of cscope.out
location (usually the project root directory) will be used as the prefix
to construct an absolute path.  The default is off.  Note: This option is
only effective when cscope (cscopeprg) is initialized without a prefix
path (-P).  Examples: >
    :set csre
    :set nocsre

Way 2 : (From Aaron Hs' answer in this question) When adding the cscope database in vim, specify base location. Example:
:cs add <base_location>/cscope.out <base_location>/

From vim's help page for cscope add:
USAGE   :cs add {file|dir} [pre-path] [flags]

    [pre-path] is the pathname used with the -P command to cscope.

A:

From the cscope manpage here:

-P path
      Prepend path to relative file names in a pre-built cross-reference file so you do not have to change to the directory where the
  cross-reference file was built. This option is only valid with the -d
  option.

So I guess the following command from the top-level kernel directory should do the trick (sorry no linux machine handy):
cscope -d -P `pwd`

my 2 cents,

