Even if Mac OS X is Unix based, building Haiku on it still requires some tweaks. These instructions were tested on Mac OS X 10.5.5 (Leopard). They may not work on older versions of Mac OS X (Tiger, Panther etc.)
Requirements
- 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.
1) Open Disk Utility (in /Application/Utilities)
2) Click "New Image", and enter the following parameters:
- Volume name: You should enter a short name without special character or spaces.
- Volume size: the minimum volume size is 2.68 Gb, the recommended size is the double. Do not worry about making the image bigger, since only the consumed space will be used on your hard drive.
- Volume format: Mac OS Extended (Case-sensitive, Journaled)
- 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
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. 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: in Tiger, as I remember, Subversion is not available with Xcode 2.5. You have to install it manually.
And the source code:
svn checkout svn://svn.berlios.de/haiku/haiku/trunk haiku
You should now have two folders "haiku" and "buildtools" into the mounted disk image.
To update your code from now on, go to the haiku/trunk/ folder and type:
svn update
Step 3: Install required software
First, install MacPorts (A standard Installer package is provided)
Close your Terminal, and enter in a new one:
sudo port install gnuregex gawk wget
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 get an error "port: command not found", the MacPorts shell configuration is probably not taken into account. You probably have a ~/.bash_profile or ~/.bash_login file overwriting MacPorts config located in ~/.profile. When a "login shell" starts up, it reads the file "/etc/profile" and then "~/.bash_profile" or "~/.bash_login" or "~/.profile" (whichever one exists - it only reads one of these, checking for them in the order mentioned). Check the file used by Bash (in the mentioned order) and add these lines to the used file:
nano ~/.bash_profile or nano ~/.bash_login or nano ~/.profile
Add at the end of the chosen file :
export PATH=/opt/local/bin:$PATH export MANPATH=$MANPATH:/opt/local/share/man export INFOPATH=$INFOPATH:/opt/local/share/info
To save the file and quit the editor, type CTRL-X, Y and RETURN. 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 command in a new Terminal:
sudo port install gnuregex gaw wget
After MacPorts finished installing the tools, install the modified Haiku jam:
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
With your favorite text editor, open the file:
[Mounted Disk Image]/buildtools/legacy/gcc/config.guess
Go to line 522, and add this:
*:Darwin:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` exit 0 ;;
before:
*:FreeBSD:*:*) if test -x /usr/bin/objformat -a "elf" = "`/usr/bin/objformat`"; then echo ${UNAME_MACHINE}-unknown-freebsdelf else echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'` fi exit 0 ;;
Warning! When you copy-paste preformatted text from a web page, some versions of Safari replace every space with a no-break space. You can use the search/replace function of your text editor to replaces these "spaces" with real ones. (or copy the text by hand... or use another browser).
Save the file, and open:
[Mounted Disk Image]/buildtools/legacy/gcc/Makefile.in
Replace (line 144):
MAKEINFO = `if [ -f $$r/texinfo/makeinfo/Makefile ] ; \ then echo $$r/texinfo/makeinfo/makeinfo ; \ else echo makeinfo ; fi`
By:
MAKEINFO = `if which -s makeinfo ; \ then echo makeinfo ; \ else echo $$r/texinfo/makeinfo/makeinfo ; fi`
These patches are from the Haiku development mailing list, thanks to their authors!
Step 5: Building the buildtools
Now, you can compile GCC2 with:
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 now 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 this command to list them:
./configure --help
After some time, you should get:
binutils and gcc for cross compilation have been built successfully!
Step 6: Customizing the UserBuildConfig
Now you could already start to build RAW or VMWare images. Before we come to that, however, let's have a look at the UserBuildConfig that can be used to customize and automate some things.
In trunk/haiku/build/jam/ there's a UserBuildConfig.ReadMe that explains various options. Don't simply rename it and use it as UserBuildConfig!
You start by duplicating the UserBuildConfig.sample and the remove the .sample suffix to get your UserBuildConfig. From the .ReadMe you can copy interesting parts into your config and customize them there.Step 7: Building Haiku
Since on-disk install from Mac OS X does not seems possible at this time, you will need to use an emulation or virtualisation software.
Instructions for VMWare Fusion:
The command:
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" to ide0: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). Launching this alias will mount the disk image and start the VM, automatically.
Haiku should run in:
Q (free),
Parallels Desktop (commercial) and,
VirtualBox (free).
Note: For more information refer to the topic Running Haiku in a virtual machine.
Some of them (like Parallels and Virtual box, maybe others) can use the VMWare disk image (see above). For the others you can create a raw disk image.
Create a raw disk image
cd /Volumes/Haiku/haiku jam haiku-image
The image will be created in [Mounted Disk Image]/haiku/generated/haiku.image.