Getting and Building the Haiku Source Code

Article contributed by wkornewald on Sat, 2006-10-28 09:10

Document Obsolete

2010-January: This document is now obsolete. We are in the process of consolidating and re-organizing the website documentation. For now please refer to the in-progress website documentation.

Please note this document mainly pertains to building Haiku under BeOS R5 and later. If you're using a non-BeOS host platform, you might find this guide more useful.

Getting the source

All commands must be executed in the Terminal.

Go to the parent directory for Haiku's repository and enter:

svn checkout http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk haiku

This will checkout the source into a new subdirectory called "haiku". Members of Haiku should login with their BerliOS account to get commit access:

svn checkout https://developername@svn.berlios.de/svnroot/repos/haiku/haiku/trunk haiku

After the initial checkout (also in case not the entire tree was checked out successfully) you can fetch source code updates with the following command in your repository's root folder:

svn update

Installing the cross-compiler

Download the Haiku cross-compiler and extract it to "/boot" (for example by setting the "Destination" in Expander to just "/boot"). Then you need to configure your tree to use this cross compiler. Go to the root folder of your checked out Haiku repository and invoke the configure script with the "cross-tools-prefix" option like this:

configure --cross-tools-prefix /boot/apps/haiku/cross-tools/bin/i586-pc-haiku-

Be careful to include all of the string up to and including the last dash, as all the cross compiler tools have this prefix (they are for example called "i586-pc-haiku-ar"). You need to specify this prefix everytime you run configure.

Building the source

You can now start the build process with:

jam

Note that this will just build any target that is found in the tree. This is usually not that useful, as many parts might not build and are not required. So optionally, a target can be specified by adding a target name. For example, "jam app_server" will only build the app_server target. Normally though you will want to build an image or installation using the commands below. Add the "-a" option to rebuild the whole source or only the specified target in case Jam didn't notice source changes.

Building an image

You can build a Haiku image with:

jam haiku-image

This will place a file named "haiku.image" into the "generated" folder.

To build an image for testing in VMWare:

jam haiku-vmware-image

This will place a file named "haiku.vmdk" into the "generated" folder.

Instead of building an image, you may install Haiku on a mounted partition using:

HAIKU_INSTALL_DIR=/target_folder jam install-haiku

Further reading

Please read "Version Control with Subversion" for a detailed introduction.

FixFi

Comments

HAIKU_INSTALL_DIR=/hda1 jam

HAIKU_INSTALL_DIR=/hda1 jam install-haiku

^ ^ that went fine.
but how can I boot it?

Adding Haiku to your (Linux/etc-)bootloader

You might want to look at this comment and thread:
http://haiku-os.org/community/forum/installing_haiku_via_linux_and_grub#...

Unless your harddisk is clean and there's no system installed, you've already got some kind of boot loader/menu installed. If you're using Linux, ("/hda1" looks like the way Linux names disk devices), it's probably GRUB, and you need to look into "chainloading" an unknown (to Grub) OS/filesystem on your /hda1 partition. I would guess the most common way to have Grub installed is to have it's settings stored in a file called menu.lst in subfolder called "boot" on your main Linux partition, but I'm not 100% sure about this.

Haiku installs a simple bootstrap loader at the start of its own partition (your /hda1?), so Grub simply has to chainload the first track of /hda1, or whatever that is in Grub-terms. IIRC Grub and Linux use the same device names, which makes it easy for you in Linux, if you have to edit Grub's settings by hand.

CAUTION: this isn't for everyone to try ;)

NOTE: Just so others reading these comments and thinking of trying this method, using HAIKU_INSTALL_DIR=<some_partition> essentially WIPES OUT that entire partition. So use that option with extreme care! There won't be any warnings or prompts when you install to it - it will just do it.

Re: Adding Haiku to your (Linux/etc-)bootloader

Linux usually maps drives as such:
/dev/hda1 < Physical Partition 1
/dev/hda2 < Physical Partition 2
/dev/hda3 < Physical Partition 3
/dev/hda4 < Physical Partition 4
/dev/hda5 < Logical Partition 1
/dev/hda6 < Logical Partition 2

Grub would name the drives:

hd(0,0) < Physical Partition 1
hd(0,1) < Physical Partition 2
hd(0,2) < Physical Partition 3
hd(0,3) < Physical Partition 4
hd(0,4) < Logical Partition 1 (within the extended partition)
hd(0,5) < Logical Partition 2 (within the extended partition)

Sample grub file:

Open /boot/grub/menu.lst

eg Ubuntu GUI: "sudo gedit /boot/grub/menu.lst"
eg Ubuntu Console: "sudo nano /boot/grub/menu.lst"

insert at the end after a new line:

title Haiku
rootnoverify(hd0,0)
makeactive
chainloader +1

You can also edit menu entries (but not save) in the menu at boot. Very useful for testing.
To do this, press e on the menu item, then use arrows, and e again to edit individual lines. d deletes a line, and b will boot with the changes. i inserts a line.

Re: Getting and Building the Haiku Source Code

Another point to note - the first step will take a year and a day :)

Re: Getting and Building the Haiku Source Code

For checking out sources as a registered developer, a shorter (single-line) checkout cmd can be done as:

svn checkout svn+ssh://developername@svn.berlios.de/svnroot/repos/haiku/haiku/trunk haiku

where developername is your account name @ berlios.de

Re: Getting and Building the Haiku Source Code

I updated the article to reflect Ithamar's suggestion. The other method suggested adding the entry to ~/.profile to ensure that SSH was always used - do subsequent svn updates's automatically use it if the original checkout was done with SSH?

Re: Getting and Building the Haiku Source Code

Yup, just doing 'svn up' will update the repository just fine, without having any env vars setup ;)

Re: Getting and Building the Haiku Source Code

Hi to everyone!
I'm trying to get involved in Haiku development.

My work PC is behind an ISA server and this server seems to block the svn access (we internally use http access to our svn repository). The message is "svn: Connection refused" by SmartSVN 3.0.1 :(

Any ideas how to access the Haiku rep in my situation?

And another question.
A've registered here (at haiku-os.org). Does it the same as "Berlios account", e.g. can I use this account to access your rep?

Re: Getting and Building the Haiku Source Code

Quote:

My work PC is behind an ISA server and this server seems to block the svn access (we internally use http access to our svn repository). The message is "svn: Connection refused" by SmartSVN 3.0.1 :(

Any ideas how to access the Haiku rep in my situation?

I believe you can access the repo using HTTP by pointing your svn client here: http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk

Quote:

And another question.
A've registered here (at haiku-os.org). Does it the same as "Berlios account", e.g. can I use this account to access your rep?

You do not need any account to access the repo, you should be able to get full access to all the source using anonymous SVN access.

The account you register here on the website is used for this website, these forums, and also for the bug tracking site: http://dev.haiku-os.org).

A Berlios account would be needed also if you are seeking commit access to the Haiku repository - but commit access to the Haiku repo is generally only granted by the Haiku development admins after an evaluation period where the developer would generally submit patches or code to the project (using diffs on the mailing list or bug tracking system). If the Haiku developers feel that the code properly follows the guidelines, is high quality, and valuable to the project - they may often grant commit access to the developer so they can continue contributing directly.

The best way to get involved with development is to use the haiku-development mailing list instead of the forums. You can get more information about the various mailing lists here: http://haiku-os.org/community/ml

Hope that helps,

Urias

Re: Getting and Building the Haiku Source Code

Urias McCullough wrote:

I believe you can access the repo using HTTP by pointing your svn client here: http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk

It works. Thanks for a detailed answer!

Building specific apps?

I tried the 'jam app_server' in Max after using './configure target=r5' and it said it couldn't find the target... Which is odd becaue I've got the source tree checked out and built a Haiku image without issue - what gives?

Re: Building specific apps?

The app_server is not supposed to be built for R5, only Haiku. If you check the Jamfile for app_server you'll see that it's not marked as BeOS compatible.

Re: jam app_server

It appears you have configured your Haiku source tree to use something else than "haiku" as the default target. This is done by passing --target=r5 for example to the configure line. You can still build the app_server by specifying:

TARGET_PLATFORM=haiku jam app_server

The app_server can be built in a special mode for running inside a window on BeOS or ZETA. The target for this is called "libbe_test":

TARGET_PLATFORM=libbe_test jam -q install-test-apps

This will build not only the app_server, but also a bunch of test apps and needed libraries, all for running inside the virtual Haiku app_server. Great for testing Haiku specific features in R5, like the new interface layout management. See src/tests/servers/app/... There are various testing tools with a "run" script inside their folder which runs the respective app inside the test environment.

updated: HAIKU_INSTALL_DIR

HAIKU_INSTALL_DIR=/target_folder jam install-haiku

Does not work;

...skipped install-haiku for lack of <HaikuImage>haiku.image-copy-files...

ls -l /boot/home/src/Haiku/trunk/haiku/generated
drwxr-xr-x   1 baron    users        2.0k Apr 19 17:51 build
-rw-r--r--   1 baron    users        100M Jun  1 12:50 haiku.image
-rw-r--r--   1 baron    users        102k Jun  1 11:20 haiku.image-copy-files
-rw-r--r--   1 baron    users         791 Jun  1 10:33 haiku.image-init-vars
-rw-r--r--   1 baron    users        4.7k Jun  1 10:33 haiku.image-make-dirs
-rw-r--r--   1 baron    users           0 Jun  1 11:20 haiku.image-unzip-files
drwxr-xr-x   1 baron    users        2.0k Apr 19 21:08 objects
drwxr-xr-x   1 baron    users        2.0k May 22 09:40 tmp                      

So what does the (var?) do there?

Also when I mountimage haiku.image and do a ls -l I see that the files have a date different then 1 Jun (22 may when I last successfully build a haiku-image)

Edit: I see that the error must have been sooner but I got only the the last messages therefor I tried a couple of times more and saw I had to delete a couple of objects (.o) to have it advance. Not there yet due to lack of time.

Re: Getting and Building the Haiku Source Code

This guide should be updated. Command used are now
svn co http://svn.berlios.de/svnroot/repos/haiku/haiku/trunk trunk
svn checkout https://developername@svn.berlios.de/svnroot/repos/haiku/haiku/trunk trunk

Re: Getting and Building the Haiku Source Code

cannot jam ...
last command:
Yacc1 generated//objects/r5/x86/common/tools/rc/parser.cpp generated/objects/r5/x86/common/tools/rc/parser.hpp
/boot/home/config/bison: cannot open file '/etc/m4sugar/m4sugar.m4': No such file or directory
Lex generated/objects/r5/common/tools/rc/lexar.cpp
/bin/sh: flex: command not found

there is a broken link to flex in /boot/home/config/bin linking to /boot/trunk/generated/objects/haiku/x86/release/bin/flex/flex