Created: 2026-08-30T16:53:00Z
Recently, I've been working a lot on the GCC port for MorphOS. That is because I want to build ObjFW as .library for MorphOS. Unfortunately, the baserel support in GCC for MorphOS is completely broken as of the 3.20 SDK. But the good news is that with a bunch of GCC patches, I got it to work and objfw.library now ships as part of the MorphOS 3.21 beta.
However, the MorphOS 3.21 beta is not public, and neither is its beta SDK which includes my fixes. So that poses a problem for anyone who wants to build baserel code for MorphOS.
Since I use pkgsrc myself to build a cross-compiler and am one of many pkgsrc developers, I have imported all required patches into pkgsrc – making the pkgsrc package the only publicly available cross-compiler with those patches at the time of writing. As a result, whenever I have been asked how to build a cross-compiler for MorphOS, I have just pointed to pkgsrc. However, most people are unfamiliar with pkgsrc, making it seem more difficult than it needs to be.
Therefore, I decided to write this blog post to provide a quick guide on how to set up pkgsrc and the MorphOS cross-compiler.
Let's first clone the pkgsrc repository and bootstrap it in $HOME/.pkg (you can also install it elsewhere by replacing it in all instructions; we're also assuming you already have a working native compiler for your system installed):
git clone https://github.com/NetBSD/pkgsrc --depth 1
cd pkgsrc/bootstrap && ./bootstrap --prefix $HOME/.pkg --unprivileged --make-jobs 8
After a while, it should have finished bootstrapping. You should now add it to your path:
export PATH="$PATH:$HOME/.pkg/sbin:$HOME/.pkg/bin"
You might want to make this permanent, e.g. by putting it into your .profile.
We need to accept the MorphOS SDK license and the LHA license before we can build the cross-compiler. While at it, let's also default to building with 8 threads:
echo "ACCEPTABLE_LICENSES += lha-license" >>$HOME/.pkg/etc/mk.conf
echo "ACCEPTABLE_LICENSES += morphos-sdk-license" >>$HOME/.pkg/etc/mk.conf
echo "MAKE_JOBS = 8" >>$HOME/.pkg/etc/mk.conf
Assuming you're still in pkgsrc/bootstrap, it's time to build the cross-compiler:
cd ../cross/ppc-morphos-gcc && bmake install clean-depends clean
Congratulations, after patiently waiting for a while, you now have a MorphOS cross-compiler!
Now, try the following as a quick test:
echo "#include <stdio.h>\nint main() { puts(\"Hello world!\"); return 0; }" >test.c
ppc-morphos-gcc -noixemul test.c
If at a later point in time want to update the cross-compiler, you can do it like so:
cd pkgsrc && git pull
cd cross/ppc-morphos-gcc && bmake replace clean-depends clean