XNU kernel Source for Mac Os X 10.6 Snow Leopard  has ben release on opensource.apple.com

Building xnu requires some open source (but not pre-installed) tools. Darwinbuild is the most reliable way for building these dependencies and xnu itself. Until that is ready, you can build the tools manually as follows:

make a dir in desktop or some where else (eg Kernel)

Open Terminal and type

cd ~/desktop/Kernel

(if you created a Kernel dir in desktop)

  1. Download the build tools source(s)

    $ curl -s -O http://www.opensource.apple.com/tarballs/cxxfilt/cxxfilt-9.tar.gz
    $ curl -s -O http://www.opensource.apple.com/tarballs/dtrace/dtrace-78.tar.gz
    $ curl -s -O http://www.opensource.apple.com/tarballs/kext_tools/kext_tools-177.tar.gz
    $ curl -s -O http://www.opensource.apple.com/tarballs/bootstrap_cmds/bootstrap_cmds-72.tar.gz
  2. Unpack the tools

    $ tar zxf cxxfilt-9.tar.gz
    $ tar zxf dtrace-78.tar.gz
    $ tar zxf kext_tools-177.tar.gz
    $ tar zxf bootstrap_cmds-72.tar.gz
  3. Build cxxfilt

    $ cd cxxfilt-9
    $ mkdir -p obj sym dst
    $ make install RC_ARCHS="i386 x86_64" RC_CFLAGS="-arch i386 -arch x86_64 -pipe" RC_OS=macos RC_RELEASE=SnowLeopard SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..
  4. Build dtrace

    $ cd dtrace-78
    $ mkdir -p obj sym dst
    $ xcodebuild install -target ctfconvert -target ctfdump -target ctfmerge ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..
  5. Build kext_tools

    $ cd kext_tools-177
    $ mkdir -p obj sym dst
    $ xcodebuild install -target kextsymboltool -target setsegname ARCHS="i386 x86_64" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..
  6. Build bootstrap_cmds

    $ cd bootstrap_cmds-72
    $ mkdir -p obj sym dst
    $ make install RC_ARCHS="i386" RC_CFLAGS="-arch i386 -pipe" RC_OS=macos RC_RELEASE=SnowLeopard SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..
  7. Download the xnu source

    $ curl -s -O http://www.opensource.apple.com/tarballs/xnu/xnu-1456.1.26.tar.gz
  8. Unpack xnu

    $ tar zxf xnu-1456.1.26.tar.gz
  9. Build xnu

    $ cd xnu-1456.1.26
    $ make ARCH_CONFIGS="I386 X86_64" KERNEL_CONFIGS="RELEASE"
    ...
    $ file BUILD/obj/RELEASE_*/mach_kernel
    BUILD/obj/RELEASE_I386/mach_kernel: Mach-O executable i386
    BUILD/obj/RELEASE_X86_64/mach_kernel: Mach-O 64-bit executable x86_64

Original Post :  here

To build a modified XNU with a .diff of an XNU kernel you need to:

1. Download and Apply the patch

download the .diff file and place it in your kernel folder (eg. ~/desktop/Kernel/patch.diff )

Patch the source  with :

cd ~/desktop/Kernel/

patch -p0 -i patch.diff

2. build the kernel (make sure you have remove the BUILD folder in  xnu-1456.1.26 folder i you have try to build before

$ cd xnu-1456.1.26
$ make ARCH_CONFIGS=”I386 X86_64″ KERNEL_CONFIGS=”RELEASE”

(for i386 and x86_64 build)

or

$ cd xnu-1456.1.26
$ make ARCH_CONFIGS=”I386″ KERNEL_CONFIGS=”RELEASE”

(for i386 build only (legacy kernel))