Building from source
People who are already setup for cross-compiling Genode from a Linux host should not need much time or effort to build HoG from source. Indeed the build basically consists of compiling Genode Labs's latest and greatest, using its native build system ; and building this project's shared library, using a one-step build system based on Jam.
The below assumes that you are setup with the Genode compiler, i.e. that you have retrieved the Genode specific build of GCC. If not, head to the Toolchain page.
Out of the box, HoG is configured to be built with the Genode 19.05 toolchain (gcc8). The latest Genode 21.05 toolchain (gcc10) can also be used, by tweaking the GccToolChain and VersionLibGCC Jamrules variables mentionned below in the "configuring HoG build" section.
First, retrieve a compatible version of Genode. At the time of this writing, you'll need to check out the sources for Genode 21.05:
git clone https://github.com/genodelabs/genode.git cd genode git checkout 21.05
Alternatively, you may pick the latest SculptOS-compatible branch:
git checkout sculpt-21.03
In that case you might need to edit jam/jamrules-pkg-versions after cloning the HoG sources from fossil (in the next step), to select appropriate pkg/lib dependancies (e.g. instead of stdcxx for 21.05, select stdcxx for 20.11 whose hash starts with "80f380...").
Then retrieve the HoG sources from this repository. They can be downloaded as a zip file (click on any check-in/revision, then look for the "Downloads: ZIP archive" link), or you may install fossil (i.e. : apt-get fossil) and use it to clone this repository:
cd .. # e.g. side-by-side with the github.com Genode repository fossil clone http://chiselapp.com/user/ttcoder/repository/genode-haiku/ genode-haiku.fossil fossil open genode-haiku.fossil cd genode-haiku/ nano Jamrules
The last step mentionned up here is for editing Jamrules (see below).
The build is done with Jam, a super sweet alternative to gmake. If you don't have jam out of the box (e.g. on Linux ?) make sure to install it.
It's probably best to install the ftjam variant, since on Ubuntu 20.x the vanilla "jam" package seems to be broken.
If you intend to only build haiku.lib.so (to e.g. create a "genode/contrib/" SculptOS package) then you might be able to take a shortcut and skip the rest of this page : if your Genode build directory already contains the binaries matching your checked-out Genode version, you're about done and just need to invoke this:
(possibly with "-j4" to speed up the build). Then lift the library file from within the haiku-on-genode/system/ folder. However, if you intend to build a full bootable system, or if you're missing some of the Genode libraries that haiku.lib.so needs to link against (ld.lib.so, vfs.lib.so, ldso_so_support.lib.a), you'll need to build part or all of the Genode components mentionned below.
Genode build (for full-blown HoG O.S.)
The below assumes that you have the Genode SDK to compile against, or even (to build HoG O.S.) the full Genode source code, ready to build. If in doubt, follow the official Genode build instructions, e.g. here.
HoG expects to find Genode libraries and components in certain hardcoded subpaths of the Genode build dir, especially within bin/. Hence, rather than use tool/depot/download, the following steps are recommended instead :
./tool/create_builddir x86_64 nano build/x86_64/etc/build.conf # enable -j4, and most extra repos except maybe for genode-world ./tool/ports/prepare_port nova ./tool/ports/prepare_port grub2 ./tool/ports/prepare_port x86emu ./tool/ports/prepare_port stb ./tool/ports/prepare_port ttf-bitstream-vera ./tool/ports/prepare_port jpeg ./tool/ports/prepare_port libc ./tool/ports/prepare_port stdcxx make -C build/x86_64 KERNEL=nova BOARD=pc kernel core/nova lib/ld/nova # for the USB and Audio drivers: ./tool/ports/prepare_port dde_linux ./tool/ports/prepare_port dde_bsd make -C build/x86_64 KERNEL=nova run/libc_select # automagically builds more components, esp. those needed by HoG like vfs.lib.so make -C build/x86_64 KERNEL=nova drivers/rtc make -C build/x86_64 KERNEL=nova drivers/audio server/mixer # for mp3 etc decoding: ./tool/depot/download cnuke/bin/x86_64/libav/2019-11-23 ./tool/depot/download cnuke/bin/x86_64/zlib/2019-11-18 make -C build/x86_64 KERNEL=nova drivers/usb
If you do build for NOVA x64 bits and follow the above steps, the steps in the next section should go smoothly as Jam will be able to locate the Genode files it needs, including those presented in the following list, and some optional extras (audio_drv, libav, etc) and match them with HoG and successfully create an ISO boot image:
Configuring the HoG buildIn theory you'll only need to configure one variable, namely GenodeRepos. See below for the more complex cases.
That variable (and the others) can be configured by one of three methods. Choose the one most convenient for you:
By setting an environ variable:
export GenodeRepos=/home/john/develop/genode/repos jam haiku.lib.so
By passing the variable to jam with the -s switch:
jam -s GenodeRepos=/home/john/develop/genode/repos haiku.lib.so
Or by editing the "Jamrules" file:
nano Jamrules # look for the "GenodeRepos=..." definition and edit it jam haiku.lib.so
HoG build (full-blown standalone HoG O.S.)
We may now build haiku.lib.so and package it in a runnable/"stand-alone" ISO image. In this case, we are building from the HoG source tree, pulling in Genode binaries to us and emulating (parts of) the Genode build system, so things are a little more involved.
Before compiling you'll need to edit the Jamrules file (at the top of the file hierarchy) to configure the correct path values for the GenodeRepos variable,
and maybe also for
Alternatively, these variables can be set in the bash environment, or provided as command-line arguments
with the "-s" switch, e.g. "jam -s GenodeRepos=/home/john.smith/develop/genode/repos".
Then run jam with the "t1" target, which will compile and run a simple "test level 1" scenario:
If the stars are aligned, that should create an .iso file and emulate it in qemu. You may then try a more complex test (up to t6) or even the "Haiku demos" scenario (jam hog-demos.run). Type "jam help" for help.
Beyond the basics (optional)Using Jam to compile the full-bore Haiku library (t6 mode) takes a few minutes. You can speed it up by building with four threads with the -j4 switch, e.g. "jam -j4 t6".
If you are curious about what you are about to embark on, first do a dry-run with the -n switch, e.g. "jam -n t1", which will dump the (possibly huge) list of calls to gcc et al to be performed.
Patching Genode (optional)It's recommended you tweak Genode in places, for improved support to Haiku in the "stand-alone OS" build scenario:
- dde_bsd audio driver (optional): for improved HDA support of some AMD motherboards (xxxx work in progress xxxx)
Building Jam from source (optional)Unfortunately the jam landscape is fragmented into several jam variants which are not fully compatible with each other (think of it as linux distros *g*). Thus it might be useful to build the same Jam variant we use, instead of installing FTJam. This should allow you to run "jam t1" instead of "jam hog-test.run", and avoid some stack/memory corruption issues seen with FTJam.
The following script should build the exact same version of Jam used by the HoG project:
mkdir build_jam && cd build_jam wget --execute robots=off --recursive --no-parent --no-directories https://git.haiku-os.org/buildtools/plain/jam/ # chmod a+x yyacc # ? make # # you'll probably need something like this to use the newly built jam: # export "PATH=$(PWD):$PATH"