Thursday, July 21, 2011

Building xnu for Mac OS X 10.7


The Mac OS X kernel source (xnu) has been released for Mac OS X 10.7 Lion: here

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:

  1. Download the build tools source(s)

    $ curl -s -O http://opensource.apple.com/tarballs/dtrace/dtrace-90.tar.gz
    $ curl -s -O http://opensource.apple.com/tarballs/bootstrap_cmds/bootstrap_cmds-79.tar.gz

  2. Unpack the tools

    $ tar zxf dtrace-90.tar.gz
    $ tar zxf bootstrap_cmds-79.tar.gz

  3. Build dtrace

    $ cd dtrace-90
    $ 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 ..

  4. Build bootstrap_cmds

    $ cd bootstrap_cmds-79
    $ mkdir -p obj sym dst
    $ make install RC_ARCHS="i386" SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
    ...
    $ sudo ditto $PWD/dst/usr/local /usr/local
    Password:
    $ cd ..

  5. Download the xnu source

    $ curl -s -O http://opensource.apple.com/tarballs/xnu/xnu-1699.22.73.tar.gz

  6. Unpack xnu

    $ tar zxf xnu-1699.22.73.tar.gz

  7. Build xnu

    $ cd xnu-1699.22.73
    $ 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

No comments: