KallistiOS: Toolchain Setup - Linux





Toolchain Setup - Linux

Setting up a toolchain for building Dreamcast applications with KallistiOS is a relatively straightforward process on any reasonably POSIX-like system, like all distributions of Linux. After setting up a few prerequisite software packages in a distribution-specific manner, everything else should work fairly similarly regardless of what distribution of Linux you're on.

Installing Prerequisites

As discussed on the general setup page, there are several prerequisites that must be installed to successfully build a toolchain for KOS. Many (or even most) of these will probably already be installed on your system if you do any other sort of software development, however it is never a bad idea to ensure that they're installed and up-to-date before you start.

Below are various lists for different distributions of what packages you will want to install ahead of time for the setup of the toolchain. It is assumed here that you know how to invoke your package manager to do so already.

On Debian (and other Debian-like distros, such as Ubuntu):
gawk patch bzip2 tar make libgmp-dev libmpfr-dev libmpc-dev gettext wget libelf-dev texinfo bison flex sed git build-essential diffutils curl python subversion libjpeg-dev libpng-dev

On Arch (Thanks Nia) and Manjaro (Thanks insomagent):
gawk patch bzip2 tar make gmp mpfr libmpc gettext wget libelf texinfo bison flex sed gcc glibc make diffutils curl python2 subversion libjpeg-turbo libpng

Others:
Please feel free to send me lists of packages to include on this page!

Now that the prerequisite programs and libraries are installed, you should create the directory where the toolchain will exist. For the purposes of this guide, we will assume that the toolchain will exist in the directory /opt/toolchains/dc. You can use any directory you would like to do this, however some scripts and such will have to be adjusted if you wish to use a different directory. These will be mentioned at the appropriate time. To create the directory to install the toolchain in (and give your regular user permission to write to the directory), run the following command with superuser privileges (i.e, as the root user or through su or sudo).

mkdir -p -m 777 /opt/toolchains/dc

Selecting Which KOS Version to Install

At this point, you should select which version of KOS to install. Basically, you can either select to install a release version (such as 2.1.0), or the current development version. In general, the development tree is fairly stable, however the API sometimes undergoes changes without any warning in the development tree. If you're doing a long-term development project with KOS (for instance, developing a commercial indie game), then you might consider using the latest release version (and potentially updating it when a new point release comes out). However, if you're just tinkering around and don't care about minor API changes here and there, you may want to follow the development version on SourceForge (or GitHub — they should generally contain the same code). The development version (obviously) contains the latest code advancements, but also might contain the latest and greatest features bugs too.

No matter whether you choose to stick with a point release or the development version, the process for building the toolchain is relatively the same.

Option 1 — Installing the development version from the git repository

Run the following commands to grab KOS and kos-ports from the git repository hosted by SourceForge:

cd /opt/toolchains/dc
git clone git://git.code.sf.net/p/cadcdev/kallistios kos
git clone git://git.code.sf.net/p/cadcdev/kos-ports kos-ports

Option 2 — Installing a release version

Grab the release version that you wish to use off of the SourceForge downloads page. You will want both the kos and kos-ports tarballs from the download page. Assuming that the files have downloaded to a directory called Downloads in your home directory, run the following commands to move everything into place (if the files have downloaded elsewhere, adjust the first command as appropriate). Note: These commands are for 2.1.0 as written — adjust the version number as appropriate.

cd ~/Downloads
tar xf kos-2.1.0-src.tar.gz
tar xf kos-ports-2.1.0-src.tar.gz
mv kos-2.1.0-src /opt/toolchains/dc/kos
mv kos-ports-2.1.0-src /opt/toolchains/dc/kos-ports

Installing the Compiler Toolchain

Now that you have KOS downloaded, we will use a few tools included with it to build a complete compiler toolchain that can be used to build Dreamcast binaries. Specifically, we will be using the dc-chain utility that is included to build the compiler relatively simply. This step will probably take a significant amount of time (and hard drive space) to complete. The process is relatively simple, assuming that everything works, anyway. Just run the following commands to build the toolchain:

cd /opt/toolchains/dc/kos/utils/dc-chain
./download.sh --no-deps
./unpack.sh --no-deps
make
Note: If you are installing in a directory other than /opt/toolchains/dc, you must edit the Makefile in the dc-chain directory to point to where you're installing. Edit the lines that define the sh_prefix and arm_prefix to point to the correct places.

If no errors have polluted your screen then you should have a working compiler toolchain that can be used to build KOS and Dreamcast binaries that use it.

Optional: Install GDB and Insight

The dc-chain utility can also be used to build a Dreamcast version of the GNU Debugger and the Insight frontend to GDB. If you would like to do so, then run the following commands:

cd /opt/toolchains/dc/kos/utils/dc-chain
make gdb insight

Building KOS and kos-ports

Once the compiler toolchain has been built, you must compile KOS itself. This too is a relatively straightforward process:

cd /opt/toolchains/dc/kos
cp doc/environ.sh.sample environ.sh
chmod u+x environ.sh
source environ.sh
make
Note: If you're installing to a different directory than /opt/toolchains/dc, you will need to edit the environ.sh file to point to the correct place. Specifically, you will have to edit the KOS_BASE, KOS_CC_BASE, DC_ARM_BASE, and PATH lines to point to the correct places.

As of KOS 2.1.0, kos-ports is not necessarily meant to be built all at once anymore, but rather as you need individual packages. It is sill possible to build all of the ported libraries at once if you wish, but it is recommended to just build each piece as you need it. To build an individual library, go to its directory in the kos-ports tree and just run make install clean. As an example, here's how you would build the libpng port:

cd /opt/toolchains/dc/kos-ports/libpng
make install clean

If you wish to build all ports at the same time, then you can run the following commands to do so:

cd /opt/toolchains/dc/kos-ports
utils/build-all.sh

Finishing up

When building KOS and anything using it, you will need to make sure that the environ.sh script that was set up in the previous step is loaded into your shell. The easiest way to do this is to simply add it to your shell's startup sequence. If you're using Bash, then this is as simple as editing the .bash_profile and/or .bashrc files in your home directory and adding the following line to the end of them:

source /opt/toolchains/dc/kos/environ.sh

You're now done! Go out and do great things and make some cool software. We'd love to hear from you if you do, so check in on the mailing list, IRC, or on the DCEmulation forums (check the lists page for links).



Gamedev Home

KallistiOS

Home
The "Scene"
Download
Documentation (v2.0.0)
Roadmap
Installation
FAQ
Lists/Forums/etc



Hosted by:
SourceForge.net Logo