Skip to content

Instantly share code, notes, and snippets.

@mafice
Created February 16, 2012 16:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mafice/1846291 to your computer and use it in GitHub Desktop.
Save mafice/1846291 to your computer and use it in GitHub Desktop.
create a build environment for XNU kernel (does not work well)
#!/bin/sh
#
# xcodeがなんやかんやなせいなのか、動かなくなっちゃいました(ゝω・)v
#
#
# Run this shell script on Mac OS X *Lion*.
# I referred to http://osx86.boeaja.info/2009/10/building-xnu-kernel-on-snow-leopard/
# You can download XNU kernel source code from http://www.opensource.apple.com/tarballs/xnu/
#
cd /tmp
mkdir prepare_env_for_build_xnu
cd prepare_env_for_build_xnu
#
# Download tarballs
#
curl -O http://www.opensource.apple.com/tarballs/cxxfilt/cxxfilt-9.tar.gz
curl -O http://www.opensource.apple.com/tarballs/dtrace/dtrace-90.tar.gz
curl -O http://www.opensource.apple.com/tarballs/kext_tools/kext_tools-252.2.tar.gz
curl -O http://www.opensource.apple.com/tarballs/bootstrap_cmds/bootstrap_cmds-80.tar.gz
#
# Extract tarballs
#
tar xf cxxfilt-9.tar.gz
tar xf dtrace-90.tar.gz
tar xf kext_tools-252.2.tar.gz
tar xf bootstrap_cmds-80.tar.gz
#
# Build and Install softwares
#
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=Lion SRCROOT=$PWD \
OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
sudo ditto $PWD/dst/usr/local /usr/local
cd ..
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
cd ..
cd kext_tools-252.2
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
cd ..
cd bootstrap_cmds-80
make install RC_ARCHS="i386" RC_CFLAGS="-arch i386 -pipe" RC_OS=macos RC_RELEASE=Lion \
SRCROOT=$PWD OBJROOT=$PWD/obj SYMROOT=$PWD/sym DSTROOT=$PWD/dst
sudo ditto $PWD/dst/usr/local /usr/local
echo "Done"
@mxswd
Copy link

mxswd commented Apr 1, 2012

Hey,

So FYI, this doesn't work anymore because of CC been clang.

@mxswd
Copy link

mxswd commented Apr 1, 2012

And the reason for that is the ./configure at the start selects xcode's CC

@mafice
Copy link
Author

mafice commented Apr 1, 2012

Thank you for letting me know.
I'll refer to your comments when I build XNU.

@Hnasar
Copy link

Hnasar commented Jun 22, 2012

whenever I try to build kextsymboltool, xcode tells me: xcodebuild: error: The project 'kext_tools.xcodeproj' does not contain a target named 'kextsymboltool

@mafice
Copy link
Author

mafice commented Jun 23, 2012

@Hnasar I have the same issue. Maybe the official documentation helps you.

@barracuda156
Copy link

Apparently TargetConfig is required too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment