Building Haiku on Mac OS X 10.10 Yosemite

This was written by Sambuddha Basu or samgtr on IRC.

The following was tested on Mac OS X 10.10 (Yosemite).

Requirements

  • At least 3 GB of free space on your hard drive
  • You will need the Xcode Tools: use the installer on your Mac OS X Install DVD, or download the latest version from Apple Developer Connection (free registration required)
  • You must be logged in as administrator to install some tools
  • MacPorts or Homebrew will also be required
Follow the steps in order to build Haiku on Mac OS X.
  1. Case-sensitive disk image
  2. Fetching the buildtools and the Haiku source code
  3. Install pre-requisite software
  4. Building the buildtools
  5. Building Haiku
  6. Emulating Haiku

Step 1: Case-sensitive disk image

The Mac OS file system, HFS+, is case-insensitive by default. This causes troubles during the build of some Haiku components, because of wrong headers inclusion (“String.h” (from Haiku) instead of “string.h” (from the system) for instance). If your Mac OS X partition is not in case-sensitive HFS+ (which is very likely), you need to create a case-sensitive disk image and put Haiku buildtools and source code on it.
  1. Open Disk Utility (in /Application/Utilities)
  2. Click “New Image”, and enter the following parameters:
    • Name: Name of the volume. It should not contain special characters or spaces.
    • Size: Haiku sources, compiled objects and the resulting Haiku disk image will take around 2.7 GB, but you should put more (8 GB for instance), especially if you want to add optional packages to the image. Only the consumed space on the image will be used on your hard drive, so don’t be afraid of setting a big value.
    • Format: Mac OS Extended (Case-sensitive)
    • Encryption: none
    • Partitions: No partition map
    • Image Format: sparse disk image
The image is automatically mounted on the Desktop. If you want to remount it later, just double-click on the image file.

Step 2: Fetching the buildtools and the Haiku source code

Open a Terminal (in /Application/Utilities), and enter:
cd /Volumes/Haiku/
“/Volumes/Haiku” refers here (and in all this tutorial) to the mounted disk image name. In this case, it is named “Haiku”, so if you chose another name, use it instead of “Haiku” after “/Volumes/”.

Checkout the buildtools:

git clone git://git.haiku-os.org/buildtools
or (if the git protocol is blocked by a firewall, or if you prefer to access the source through an encrypted channel):
git clone https://git.haiku-os.org/buildtools

Checkout the source code:

git clone git://git.haiku-os.org/haiku
or:
git clone https://git.haiku-os.org/haiku
You should now have two folders “haiku” and “buildtools” into the mounted disk image.

Step 3: Install required software

To install the prerequisite software using Macports do the following:
Install MacPorts (a standard Installer package is provided). Close your Terminal, and enter in a new one:
sudo port install cdrtools gawk wget nasm less mpfr gmp libmpc
(Also important: make sure you have the latest version of "bison" installed!)
You will be prompted for the administrator password of the current account. If you get an error “port: command not found”, the MacPorts shell configuration, stored in ~/.profile, is probably not configured correctly. If you’re using Bash, you probably have a ~/.bash_profile or ~/.bash_login file, preventing bash to read ~/.profile. Check the file used by Bash (in the mentioned order) and add these lines to the used file:
export PATH=/opt/local/bin:$PATH
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info
If you are using another shell, take a look a the shell documentation to see which file is parsed at login, and add the required commands. You can now retry the port install... command in a new Terminal.

Note: the ARM port is not yet supported for OS X, MacPorts has mtools but is missing sfdisk at least.

To install the prerequisite software using Homebrew instead, do the following:
Install Homebrew using the ruby command line installer provided on the linked page. Next install the prerequisite software to build Haiku using the following command:
brew install cdrtools gawk wget nasm less mpfr gmp libmpc
Note that you'll need to install gnu less from the dupes repository as OS X comes with BSD less while Haiku requires GNU less.

Also important: make sure you have the latest version of "bison" installed!)
To override an older system version of "bison", you enter:

brew install bison
brew link bison --force
After installing the prerequisite softwares, install the modified Haiku jam:
cd /Volumes/Haiku/buildtools/jam
make
sudo ./jam0 install
[Enter your password]
Reopen a new Terminal, and enter jam -v. You should get:
Jam 2.5-haiku-20111222. OS=MACOSX. Copyright 1993-2002 Christopher Seiwald

Step 4: Building the buildtools

Configure a GCC 2.95 Hybrid, from a non-Haiku platform
mkdir /Volumes/Haiku/haiku/generated
cd /Volumes/Haiku/haiku/generated
../configure --use-xattr --cross-tools-source ../../buildtools/ --build-cross-tools x86_gcc2 --build-cross-tools x86
./configure has some more options: use ./configure --help to list them. After some time, you should get:
binutils and gcc for cross compilation have been built successfully!

Step 5: Building Haiku

Compiling a basic raw Haiku disk image
This is the most basic build, it generally is good for quickly testing the OS after making modifications as it doesn't contain a lot of extra applications. Be sure to modify -j2 with the number of cpu cores on your build system to ensure the fastest build times.
jam -q -j2 @image
Compiling raw nightly disk images
This is the default nightly image build target. This contains a complete system with an included compiler. Be sure to modify -j2 with the number of cpu cores on your build system to ensure the fastest build times.
jam -q -j2 @nightly-raw

Step 6: Emulating Haiku

Instructions for VirtualBox
For emulating Haiku in VirtualBox, follow this guide.
Installing to the hard drive
You can boot Haiku on your Mac. Before installing, please consider the following points:
  • Only do this if you feel confident. There are serious risks of data loss here.
  • You need a Mac with an Intel processor.
  • Haiku must be installed to an internal hard drive. USB or FireWire external drives will not work.
  • You need to create a new partition on your hard drive. The Boot Camp Assistant or Disk Utility may help.
The first step is to determine the name of the partition where Haiku should be installed. Mac OS X uses the following naming scheme: diskXsY, where X is the disk number (starting with 0), and Y the partition number (starting with 1). You can use the diskutil list command to get the list of disks attached to the computer, and their partitions. Create or edit the file [Mounted Disk Image]/haiku/build/jam/UserBuildConfig, and add the following line :
DefineBuildProfile disk : disk : "/dev/diskXsY" ;
(with X and Y replaced by the actual partition numbers) This will create a “build profile” rule that will install Haiku to the partition. For more information about build profiles, see the file [Mounted Disk Image]/haiku/build/jam/UserBuildConfig.ReadMe. After this, start a Terminal, double check the disk and partition numbers and run:
cd /Volumes/Haiku/haiku
sudo chmod o+r /dev/diskX
[enter your password]
sudo chmod o+rw /dev/diskXsY
jam -q @disk
Haiku is installed on your Mac ! To boot on it, the best way is to install the rEFIt boot manager.