How to build Haiku on Mac OS X
Even if Mac OS X is Unix based, building Haiku on it still requires some tweaks.
I tested these instructions on Mac OS X 10.5.6 (Leopard). If they work on older versions (Tiger, Panther…) please let me know.
- Case-sensitive disk image
- Fetching the buildtools and the Haiku source code
- Install required software
- Let’s Patch
- Building the buildtools ;-)
- Building Haiku
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 will also be required (see Step 3 for installation tips)
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.
2) Click “New Image”, and enter the following parameters:
- Volume name: You should enter a short name without special character or spaces.
- Volume 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 ;-)
- Volume format: Mac OS Extended (Case-sensitive)
- Encryption: You should say “none”, unless you really want to slow down Haiku building…
- Partitions: (Tiger users will not have this - just skip it): Choose No partition map.
- Image format: Choose “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
cd /Volumes/Haiku/
“/Volumes/Haiku” refers here (and in all this tutorial) to the mounted disk image name. I named it “Haiku”, so if you chose another name, use it instead of “Haiku” after “/Volumes/”.
Checkout the buildtools:
svn checkout svn://svn.berlios.de/haiku/buildtools/trunk buildtools
[ Note to Tiger users: IIRC, Subversion is not available with Xcode 2.5. You have to install it manually. ]
And the sourcecode:
svn checkout svn://svn.berlios.de/haiku/haiku/trunk haiku
You should now have two folders “haiku” and “buildtools” into the mounted disk image.
Step 3: Install required software
Close your Terminal, and enter in a new one:
sudo port install gnuregex gawk yasm
(You will be prompted for the administrator password of the current account - Do not worry if nothing you type shows after the Password prompt, this is intended ;-) )
- If you plan to use optional packages, add wget to the list.
- If you plan to build a bootable Haiku CD, add cdrtools to the list.
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.
cd /Volumes/Haiku/buildtools/jam make sudo ./jam0 install [Enter your password] cd ..
Reopen a new Terminal, and enter jam -v.
You should get:
Jam 2.5-haiku-20080327. OS=MACOSX. Copyright 1993-2002 Christopher Seiwald.
Step 4: Let’s Patch
cd /Volumes/Haiku curl -O http://dev.haiku-os.org/raw-attachment/ticket/3298/haiku_gcc2_osx_2.patch patch -p0 < haiku_gcc2_osx_2.patch
Step 5: Building the buildtools ;-)
cd /Volumes/Haiku/haiku ./configure --build-cross-tools ../buildtools
If you want to build Haiku with GCC4, use:
./configure --build-cross-tools-gcc4 x86 ../buildtools/
If you do not know which one you should use, choose gcc2: Original BeOS R5 binaries (and many Haiku optional packages) will not run on a gcc4 build.
./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 6: Building Haiku
Installing to the hard drive
- 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 Leopard’s 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
And voilà, Haiku is installed on your Mac ! To boot on it, the best way is to install the rEFIt boot manager.
Instructions for VMware Fusion:
cd /Volumes/Haiku/haiku jam -q haiku-vmware-image
will build a VMware disk image: [Mounted Disk Image]/haiku/generated/haiku.vmdk.
To use it, follow these steps:
- Create a folder at the root of the disk image.
- Copy [Mounted Disk Image]/3rdparty/vmware/haiku.vmx inside this folder, and edit the copy.
- Change
ide0:0.fileName = "haiku.vmdk"toide0:0.fileName = "../haiku/generated/haiku.vmdk". Save the file. - Double-clicking on the file should start VMware Fusion and launch Haiku.
VMware will create some files in the folder you put haiku.vmx.
If you want easy access to the virtual machine file, make an alias of the haiku.vmx file (or put it into the Dock).
Lanching this alias will mount the disk image and start the VM, automatically.
Instructions for other virtualisation/emulation software:
Some of them (Parallels, …) can use the VMware disk image (see above).
For the others, you can create a raw disk image with:
cd /Volumes/Haiku/haiku jam haiku-image
The image will be created in [Mounted Disk Image]/haiku/generated/haiku.image.

Comments
Re: How to build Haiku on Mac OS X
Hello Vincent,
This actually works. I just built Haiku on my Mac OS X.
Please put more emphasis on the Admin account needed line. There is no way to switch to a admin terminal account in Terminal afaik.
Using a Dutch translation over here I was puzzled by which choice the sparse diskimage exactly was: a screenprint would have been very nice. I now solved it by temporarily switching to English as my main language.
The main trouble I encountered was install macports. This is very shortly put down here. And where everything else is installed using terminal this one can be done using the standard provided .dmg file. Then I encountered the real troublemaker: "sudo: port: command not found", port was not recognised as a command. Until I googled the errorline to find the solution, I was rather puzzled by this one.
Could you insert the solution in the tutorial
create a new file using a new terminal
vi ./bash_profile
export PATH=$PATH:/opt/local/bin
export MANPATH=$MANPATH:/opt/local/share/man
export INFOPATH=$INFOPATH:/opt/local/share/info
After copying pasting or typing, and reinserting the first missing characters, comes the real hard part of vi: getting out of it saving the file:
Type :w (write) and :q (quit) or :wq (write and quit)
then if you want to:
sudo port -d selfupdate
Please mention why somebody would compile with GCC4 in stead of GCC2.
Oh and before I forget please make some corrections on the use./configure make sure the command is on a seperate line, my printerfriendly version made me doubt if the dots should or should not be included in the statements.
I created both a VMware image and a Raw image (after that) The latter was finished in a couple of seconds, maybe because the compilation were all done in the VMware image part.
A final bit of help. If you want to unmount your newly created Haiku disk and you are stuck by disk utility manager (whats keeping me) it might be that it was opened by you as another user before you realised you had to use your admin account.
Very good tutorial though! Thank you.
Now I go figure out howto use the images in Parallels and Virtualbox :-)
Re: How to build Haiku on Mac OS X
Vincent, in section 4 (patching) where you talk about FreeBSD and Darwin (line 522), the instructions are confusing. What you need to do is specify that you want to ADD the Darwin section BEFORE the FreeBSD section. This will make the instructions clearer.
Also, the MacPorts section talks about modifying the ~/.bash_profile file. Yes, this will work, but it will override any settings people have in their ~/.profile file. And as far as I'm aware, on OSX it is recommended to use .profile instead of .bash_profile. Both work for the purpose of building Haiku, but some people may discover that other tools break since their defintions are in .profile.
Speaking of MacPorts, if you decide to install optional packages (Firefox, Vision, Pe, etc) which is done by modifying the /Volumes/Haiku/haiku/build/jam/UserBuildConfig file, then you will also need to get 'wget' from the ports collection. eg.
sudo port install wgetOne more important piece of information I'd add to the document is the minimum size of the disk image. A fully utilised disk image uses 2.68Gb, so obviously the user has to specify a slightly larger disk image size. I've got mine set to 4.37Gb (which is also the DVD size). Dont overdo it, since very soon you'll be building Haiku from within Haiku itself.
Building the buildtools doesn't take that LONG. It finished in less than 3 minutes on my laptop. Haiku itself takes 15 minutes to compile. Not bad. (well, coming from Zeta 1.5, where it takes more than 2 hours to compile).
Re: How to build Haiku on Mac OS X
Hello, the ./configure --build-cross-tools ../buildtools doesn't work for me. My terminal states: ./configure: No such file or directory
I'm not an advanced user, but I'm quite sure this should run a script. Any ideas what this might be?
edit: I've done it easily on ubuntu...
edit #2: OK, so now I've tried to run the configure script inside /haiku/gcc like so: ./configure --build-cross-tools ../../buildtools
and my bash outputs, configure: error: --build-cross-tools: invalid option; use --help to show usage.
I'm not getting it. I will try to dig deeper, but I'm quite unsure what problem would cause this. Any idea?
Re: How to build Haiku on Mac OS X
You have to cd into the "haiku" directory (
cd /Volumes/Haiku/haiku, orcd /Volume/MyDiskImage/haikuif you named your disk image volume "MyDiskImage") to run the configure script inside.It will take care of configuring the Haiku sources and building the buildtools.
You do not have to make anything into the buildtools directory, and I think you can even remove it after the configure.
Re: How to build Haiku on Mac OS X
Yes, but I am running the ./configure in my /Volumes/Haiku/haiku directory... That's the problem. I simply tried to access the script directly, to test it out...
Re: How to build Haiku on Mac OS X
Yes, but I am running the ./configure in my /Volumes/Haiku/haiku directory... That's the problem. I simply tried to access the script directly, to test it out...
If you get a "./configure: No such file or directory" when you're in the haiku directory, then some files (at least the configure script) are missing.
You should run
to restore the missing files.
Re: How to build Haiku on Mac OS X
As of April 2009, when building Haiku under MacOSX, you will also need yasm. From the Terminal, execute the following:
sudo port install yasm
This should be added to section 3 (whoever has modify priviledges).
Re: How to build Haiku on Mac OS X
My fingers itch of wanting to try it! Still if Haiku could run natively from this unibody MB pro... :-D !
Re: How to build Haiku on Mac OS X
As of April 2009, when building Haiku under MacOSX, you will also need yasm. From the Terminal, execute the following:
sudo port install yasm
This should be added to section 3 (whoever has modify priviledges).
Actually, with the recent change, yasm 0.7.2 or newer is required - does OS X come with a version that recent?
The suggested approach now is to download the sources and compile/install a newer version manually.
Re: How to build Haiku on Mac OS X
I’m currently rewriting some parts of the article, I should send an updated version soon.
The yasm provided by MacPorts should work without problems :
Re: How to build Haiku on Mac OS X
I've got Haiku running natively on a MacBookPro (C2D, Oct 07 generation). You need to enable the new ATA interface and disable the legacy IDE interface from the src/add-ons/kernel/bus_managers/Jamfile (insert a # to comment out a line). I also changed src/add-ons/kernel/busses/scsi/ahci/ahci.c and inserted the following on line 90:
{ 0x8086, 0x27c4, "Intel ICH7-M (AHCI mode)" },
BTW - This was added a year ago to the src image, but was removed for some reason(unknown to me).
You then need to figure out a way to install an image to the physical disk. I used bootcamp to originally partition the drive, and I use VMWare fusion to access the partition (configure Fusion to think it's accessing a Windows BootCamp partition, when in reality its Haiku). You will need to initialised the partition as BeFS initially (from any BeOS/Haiku distro, I used Zeta). Configure Fusion to access both the freshly compiled haiku.vmdk image, and the bootcamp parition. Copy all the files from the haiku.vmdk image to the partition, run makebootable /Haiku (or whatever your partition is named), and your ready to reboot (hold option key to select Haiku).
Not too challenging, I hope?
BTW - Vesa will be stuck at a lower resolution (1152xsomething), and you'll have USB problems if you enable both HDAudio and OpenSoundSystem.
Re: How to build Haiku on Mac OS X
and you'll have USB problems if you enable both HDAudio and OpenSoundSystem.
If both HDA and OSS support your chip, you should NOT enable both - currently Haiku doesn't have a way to prevent two drivers from utilizing the same hardware, and if both drivers detect that they support your hardware, you will likely encounter all sorts of bad issues.
Re: How to build Haiku on Mac OS X
{ 0x8086, 0x27c4, "Intel ICH7-M (AHCI mode)" },
BTW - This was added a year ago to the src image, but was removed for some reason(unknown to me).
According to the revision history, it was not a proper AHCI device id:
http://dev.haiku-os.org/changeset/22877/haiku/trunk/src/add-ons/kernel/busses/scsi/ahci/ahci.c
It was removed for apparently the same reason it was rejected from linux' AHCI driver. I found this thread:
http://marc.info/?l=linux-ide&m=117104516801714&w=2
If you read through that thread, apparently some OEM BIOS incorrectly specify the same devid for AHCI mode on that controller or something... I guess Apple falls into that group.
I'm not sure what the right solution is, unfortunately.
Re: How to build Haiku on Mac OS X
Well, I've just tried R30142, and it boots fine without the AHCI device id definition. I guess that's another thing which has been fixed during the last 6 months. Excellent. I'll edit my original post and say that it's no longer required.
Re: How to build Haiku on Mac OS X
I also changed src/add-ons/kernel/busses/scsi/ahci/ahci.c and inserted the following on line 90:
{ 0x8086, 0x27c4, "Intel ICH7-M (AHCI mode)" },
Edit Zenja, 14 April 2009 - This is no longer necessary. Haiku will now boot without any problems without this change.
Re: How to build Haiku on Mac OS X
Just an update - my box had an older version of MacPorts base installed (1.60), which has an older version of yasm (0.71). Haiku needs a newer version, otherwise you will get a HAIKU_YASM not set error. I needed to update MacPorts by typing:
sudo port selfupdate
This brings MacPorts base to 1.71. Before you update yasm, you need to deactivate the older version (in my case 0.71).
sudo port uninstall yasm
sudo port install yasm
The latest (April 2009) version of yasm is 0.80
Rerun the configure script and you should be set.
Re: How to build Haiku on Mac OS X
Just an update - my box had an older version of MacPorts base installed (1.60), which has an older version of yasm (0.71). Haiku needs a newer version, otherwise you will get a HAIKU_YASM not set error. I needed to update MacPorts by typing:
Actually, the version required has since been relaxed to any 0.7.x version of yasm... so 0.7.1 would have been fine.
What was happening was that your BuildConfig in generated/build was missing the HAIKU_YASM variable which is only populated during configure.
Just letting you know :)
Re: How to build Haiku on Mac OS X
Something is wrong with building now on mac building buildtools gcc2.
I am now on 30628
Jam 2.5-haiku-20080327. OS=MACOSX. Copyright 1993-2002 Christopher Seiwald.
applied the patch in step 4.
This is the last part of a large output stream.
config.status: WARNING: /Volumes/Haiku/buildtools/legacy/gcc/gcc/intl/Makefile.in seems to ignore the --datarootdir setting
config.status: creating po/Makefile.in
config.status: creating fixinc/Makefile
config.status: creating cp/Makefile
config.status: creating auto-host.h
config.status: auto-host.h is unchanged
config.status: linking /Volumes/Haiku/buildtools/legacy/gcc/gcc/intl/libgettext.h to intl/libintl.h
config.status: executing default-1 commands
config.status: executing default commands
creating libintl.h
/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
/bin/sh: -c: line 1: syntax error: unexpected end of file
make[1]: *** [intl.all] Error 2
make: *** [cross] Error 2
ERROR: Building gcc failed.
If needed I can put the entire stream on one of the mailing lists.
Clues hints etc very welcome.
Arnold
Re: How to build Haiku on Mac OS X
Same troubles :)
Re: How to build Haiku on Mac OS X
Good to know I am not the only one to experience this inconvenience.
I hoped it was due to not updating the buildtools but no. Svn now on 30675. Applying the patch again fails and the configure step now makes terminal not responding for way too long. Last remark being " fpic not supported fPIC assumed"
Hope the experts can soon figure this one out.
Re: How to build Haiku on Mac OS X
Weird... I just made a full build from scratch, and it worked without any problems.
Could you please try again and post the full Terminal output on http://haiku.pastebin.com/ ? Also indicate your Mac OS X and MacPorts version (to get it, type ports -v in a Terminal).
Re: How to build Haiku on Mac OS X
Well, think you should known this, indeed starting all over results in a successful build of the tools!
Still, I don't want to start all over all the time.
So maybe my terminal output will give a clue of what went wrong when trying to pick up and use svn update etc instead.
Thnx Vincent!
Snow Leopard
With Snow Leopard, Apple have finally shipped a 64 bit OS and tool chain. To build Haiku with 64 Linux, the advice here should be followed, which essentially suggests to use the --use-32bit option in ./configure. However, SnowLeopard toolchain is based on BSD-64, and the linker does not support the -m32 option.
Building Haiku on Snow Leopard is currently not possible. Further investigation needed.
BTW - the configure option will fail on i386.c in gcc_legacy due to incorrect prototype for strcat(). Just comment out that line, and near the top of the file add #include "string.h".
Re: Snow Leopard
Hello,
I have already taken a look at the Snow Leopard issues.
First, I fixed the buildtools (gcc2 had the strcat() issue that you noticed, gcc4 had a linking problem — duplicate symbol)
I have made a new buildtools patch to adress these issues:
http://dev.haiku-os.org/raw-attachment/ticket/3298/buildtools_macosx.patch
Another problem is that Jam is built in 64 bits mode by default; that makes it very unstable.
To make it build in 32 bits mode:
- Replace line 4 of buildtools/jam/Makefile with "CFLAGS = -m32"
- Add after line 51 of buildtools/jam/Jamfile ("if $(OS) = NT ...") those lines:
As you noticed, ld does not like -m32. Actually, removing it is not a problem — it will detect the right architecture automatically.
You can use this patch: http://vinduv.pastebin.com/f53eb3bd1
And the last problem: the keymap parser, which is compiled for Mac OS X, is hard-coded to use /opt/local/lib/libgnuregex.dylib. This is fine when you use the one installed by MacPorts. But since MacPorts now installs a 64 bits version, the linking will fail.
The only workaround I found for now is to replace libgnuregex.dylib by a 32 bit compiled version.
Yes, that is complicated, but after doing all of this, you should be able to build and install Haiku without any further issues ;-)
Re: Snow Leopard
Hi,
I followed your instructions ( Mac OS 10.6.1 / Xcode 3.2 Component versions Xcode IDE: 1610.0 Xcode Core: 1608.0 ToolSupport: 1591.0) and at least I can configure both ggc2 and ggc4 (trying to do a hybrid build with a ggc2 base and gcc4 libs), however the build fails (r33411) while building bfs_disk_system, see the build output:
http://pastebin.com/m712fab9
Any ideas?
Also, if you have a link to the 32bit version of "/opt/local/lib/libgnuregex.dylib" handy, I would also appreciate ;-)
Thanks for help in advance!
Rossi
Re: How to build Haiku on Mac OS X
To work around the libgnuregex.dylib 64 bit problem on Snow Leopard, the following command from Terminal will install a universal version of the lib, which also happens to have the required 32 bit version. After updating libgnuregex.dylib, Haiku can once again be compiled from Mac OS X (snow leopard).
sudo port upgrade --enforce-variants expat gnuregex +universal
Re: How to build Haiku on Mac OS X
Thanks for the update.