Created
September 10, 2017 17:26
-
-
Save pulkomandy/dd2541c5493813713dd087d7b5d728d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install dependencies | |
sudo apt-get install curl git python nasm autoconf automake texinfo flex bison gawk build-essential unzip wget zip zlib1g-dev libcurl4-openssl-dev genisoimage libtool | |
# get Haiku and compiler sources | |
git clone --depth=1 https://github.com:/haiku/buildtools | |
git clone --depth=1 https://github.com:/haiku/haiku | |
# Build jam (with Haiku changes) | |
cd ~/buildtools/ | |
make | |
sudo ./jam0 install | |
# Fetch tags (needed to build Haiku) | |
cd ~/haiku/ | |
git remote add upstream https://git.haiku-os.org/haiku | |
git fetch upstream --tags | |
# Build the toolchain | |
mkdir generated | |
cd generated/ | |
../configure --build-cross-tools x86_64 ../../buildtools --use-gcc-pipe -j16 | |
# Compile Haiku | |
jam -q -j16 @nightly-raw | |
cd ~/ | |
# Create script to run "package" from HAiku tools (with apropriate libpath) | |
cat >package.sh <<-EOF | |
#!/bin/bash | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/haiku/generated/objects/linux/lib | |
$HOME/haiku/generated/objects/linux/x86_64/release/tools/package/package $@ | |
EOF | |
chmod a+x package.sh | |
# Download script to build cross-compiler | |
wget https://gist.githubusercontent.com/jessicah/5bc1da8f72ace11d77a42335951242e6/raw/build_cross_tools_gcc4 | |
chmod a+x build_cross_tools_gcc4 | |
mkdir cross | |
# Now we can finally build the cross compiler itself | |
./build_cross_tools_gcc4 x86_64-unknown-haiku ./haiku/ ./buildtools/ cross -j16 | |
sudo ln -s $HOME/cross/sysroot/boot/system/ /system | |
# Extract files from Haiku packages (to build an environment usable on the host) | |
find haiku/generated/objects/haiku/x86_64/packaging/repositories/ -name '*.hpkg' -exec ./package.sh extract -C cross/sysroot/boot/system/ {} \; | |
./package.sh extract -C cross/sysroot/boot/system/ ~/haiku/generated/download/gcc_syslibs-*.hpkg | |
./package.sh extract -C cross/sysroot/boot/system/ ~/haiku/generated/download/gcc_syslibs_devel-*.hpkg | |
# Fixup some library paths | |
cd ~/cross/sysroot/boot/system/develop/lib/ | |
ln -s ../../lib/libgcc_s.so libgcc_s.so | |
cd ~/ | |
# Add the toolchain binaries to the path | |
export PATH=$PATH:$HOME/cross/bin | |
# Now ready to build... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment