WARNING - This guide is out of date. For a more up-to-date guide, see henzenmann's posts in this topic.
Assuming you want the newest set of compilers, and the newest KOS (with full C and C++ support and so on), then you'll want to use Jim Ursetto's makefile. It'll automatically download the required source code, build binutils, GCC, newlib, and g++. The only catch is that's it's a bit out of date, and requires some tweaking to get it to work on the latest versions of KOS (mostly, removing the patches required to get it working on earlier versions of KOS, since they're no longer required).
http://3e8.org/hacks/dc/dc-chain-0.1.tgz
I can't remember the exact instructions for building it at the moment. I'll get back to you on that.
One catch - the ARM compiler that this makefile builds doesn't generate working code, so it's kind of useless, and you'd have to revert to an older version (GCC 3.0.4) if you want it. You may as well not bother building it - current KOS snapshots include a pre-compiled version of the sound driver, which is the only part that actually needs the ARM compiler. Unless you want to write your own sound driver, you should be fine with that.
Oh yeah, you also need development libraries for zlib, libpng and libjpeg, and you might need to hack some of the makefiles in the KOS utils directory to get them to build (I had to add -lz to a couple of them)
Edit: My mistake - it doesn't download stuff for you. Oopsie...
Anyway, here's how you do it. I think. I haven't tested this in a while...
First off, you need to grab dc-build (above), the source code for
Binutils 2.15, GCC 3.4.3 (
core and
g++),
Newlib 1.12.0, and the newest KOS snapshot (
kos,
kos-ports).
Untar dc-chain-0.1.tgz. That'll give you a directory called dc-chain-0.1
Now, unpack binutils, newlib, and gcc (both files) into that directory. Unpack kos and kos-ports somewhere else (anywhere else - doesn't really matter - but extract them to the same directory). You should end up with a directory structure like this:
Code: Select all
kos
kos-ports
dc-chain-0.1
00PATCHES
00README
binutils-2.15
Loads of crap
gcc-3.4.3
More crap
Makefile
newlib-1.12.0
Even more crap
patches
Patch files
Got something that resembles that? Good.
Go into the patches directory and delete everything except gcc-3.4.1.diff and newlib-1.12.0-kos.diff.
Rename gcc-3.4.1.diff -> gcc-3.4.3.diff and open it in a text editor. Replace all instances of "3.4.1" with "3.4.3". Not sure if that's absolutely required (shouldn't be), but it couldn't hurt...
Open the Makefile. Edit these lines to tell it where you want to put the compiler, and where you have KOS installed (it wants the path to the kos directory, which was created when you unpacked the kos snapshot). I usually put the compiler in my home directory somewhere - that way, I don't need root access to install it, and I can get rid of it by simply deleting the thing.
Code: Select all
sh_prefix := /usr/local/dc/$(sh_target)
arm_prefix := /usr/local/dc/$(arm_target)
kos_root=/home/jim/dc/kos/kos-1.3.0
Also, change the version of GCC:
to:
Now, to build the toolchain. Pull up a terminal, go to the dc-build-0.1 directory, and do this:
If that didn't work, panic. If it worked, great.
Edit: Now you should build GCC 3.0.4 for the ARM sound CPU. See below for details.
On to KOS.
First, you need to create an appropriate environment file. Go to kos/doc, and look for environ.sh.sample. Copy it to kos/environ.sh, and open it in a text editor. Edit it to your requirements. You'll want to change KOS_BASE, KOS_LOADER (maybe), KOS_CC_BASE (wherever you installed the SH-4 compiler to), DC_ARM_BASE (wherever you installed the ARM compiler to) and maybe something else. Read it and see.
Open environ_dreamcast.sh, and after "-fno-optimize-sibling-calls" add "-fno-crossjumping".
Pull up a terminal, change to the KOS directory, and do this:
That prepares the environment for compiling stuff with KOS. Now, to build KOS itself...
If all goes well, it should finish without errors. You might have some failures in the utils directory, usually you just need to add some libraries (-lz or -lm usually) into the Makefile, and it'll work.
Next, go to kos-ports, and type make. It should build the addon libraries, and they should also build without errors. You might need to remove SDL (unless you want it, in which case you'll have to fix it) if it doesn't compile, but everything else should be OK.
You should be able to build most of the examples. Not all of them work, but most of them do. Just cd to the examples directory, and type make. Most of them should build correctly, and work properly when you run them.