Skip to content

Instantly share code, notes, and snippets.

@mafice
Created February 16, 2012 16:35
Show Gist options
  • 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"
@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