As you probably know, the Mac OS X kernel, XNU, is open source and building it from source is fairly straightforward (thanks to yearly instructions by Shantonu Sen).
However, building the kernel requires one to install a couple of dependencies that are not available on a Mac OS X installation by default (such as
ctfmerge that are part of the Dtrace project).
Since these dependencies are installed in the local Xcode Developer directory (or in
/usr/local, as long as it’s in your
PATH), one needs to install them on each new machine that one wants to build XNU on. Similarly, building
libsyscall requires one to modify the local Mac OS X SDK in Xcode which might not always be desirable.
Finally, installing XNU and the respective
libsystem_kernel.dylib user-space dynamic library requires a bunch of copying and manual terminal commands to be executed which is not ideal when one wants to quickly deploy a new version of the kernel to a virtual machine for example.
For this reason, I’ve written
xnu-make that should make the process of building, installing and deploying XNU to a remote machine a bit more self contained and straightforward.
xnu-make is composed of a
Makefile and two simple scripts:
deploy.sh. It packages XNU and dependencies as submodules and the
Makefile takes care of building the kernel,
libsyscall and dependencies without touching your Xcode installation or current Mac OS X SDK (it actually makes a copy of the SDK, updates it while building and symlinks it so that Xcode can find it should you need to). Then, the scripts take care of installing the kernel,
libsyscall, clearing the various kext and
dyld caches and offering you to reboot.
install.sh will take care of installing on your local machine (which you should probably never want, unless you’re building from a VM) and
deploy.sh will copy the build output and install them on a remote host (such as a VM or a physical remote machine).
You can find
xnu-make on GitHub. I’m hoping to improve it over time (I haven’t really tested the user space components installation much for example) but I think it’s a good starting point and it’s, at least, making my life a little bit easier.