CentOS
Reference: Tutorial Link
Quick quote from tutorial:
Step 1: As normal user
[user@host]$ mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
[user@host]$ echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
Step 2: As root
[root@host]# yum install rpm-build redhat-rpm-config asciidoc hmaccalc
[root@host]# yum install binutils-devel elfutils-libelf-devel newt-devel zlib-devel
Step 3: As normal user
[user@host]$ rpm -i http://vault.centos.org/6.3/updates/Source/SPackages/kernel-2.6.32-279.19.1.el6.src.rpm 2>&1 | grep -v mock
kernel source tree: /home/user/rpmbuild/BUILD/kernel*/linux*/
<-- cd into it to confirm those '*'.
So
make KERNEL_TREE=<put in the full path above>
Debian
<root of the kernel source tree>
is where the kernel source is.
On Ubuntut/Debain, download kernel source
apt-get install linux-source-3.2.0
That will put the kernel source tree in
/usr/src/linux-source-3.2.0
However the actual source tree need to be de-compressed
# cd /usr/src/linux-source-3.2.0
# ls -lh
total 77M
drwxr-xr-x 10 root root 4.0K Jan 24 22:40 debian
drwxr-xr-x 8 root root 4.0K Jan 24 22:40 debian.master
-rw-r--r-- 1 root root 77M Jan 8 17:46 linux-source-3.2.0.tar.bz2
# tar xf linux-source-3.2.0.tar.bz2
# ls -lh
total 77M
drwxr-xr-x 10 root root 4.0K Jan 24 22:40 debian
drwxr-xr-x 8 root root 4.0K Jan 24 22:40 debian.master
drwxrwxr-x 24 root root 4.0K Jan 8 17:45 linux-source-3.2.0
-rw-r--r-- 1 root root 77M Jan 8 17:46 linux-source-3.2.0.tar.bz2
The source tree is /usr/src/linux-source-3.2.0/linux-source-3.2.0
So
make KERNEL_TREE=/usr/src/linux-source-3.2.0/linux-source-3.2.0