On my neverending quest to have a powerful cross compiler for m68k Classic Amiga (i.e. OS <= 3.x) for my Mac I had a closer look on the fresh new release of Volker Barthelmann’s C Compiler.
In this post I’ll describe how to install this nice piece of code on your machine in a few easy steps!
1. vasm 1.5b
First we build the cross assembler to assemble the output of vbcc.
Download the source code from the above link. Now extract it:
tar xvfz vasm.tar.gz cd vasm
Build the binary with:
make CPU=m68k SYNTAX=mot
Finally install with (note we use /opt/vbcc as the location for all this):
mkdir -p /opt/vbcc/bin cp vasmm68k_std vasmm68k_mot vobjdump /opt/vbcc/bin
Ok, the assembler is ready!
2. vlink 0.14
vlink’s homepage and the source can also be found on Frank Wille’s site:
Same game here: download source and untarring:
tar xvfz vlink.tar.gz cd vlink
Build:
mkdir objects make
Install:
mkdir -p /opt/vbcc/bin cp vlink /opt/vbcc/bin
Done!
3. vbcc 0.9b
Finally, the compiler itself:
Pepare:
tar xvfz vbcc.tar.gz cd vbcc
I removed the -DHAVE_AOS4 in the Makefile just to be sure.
Build:
mkdir bin make TARGET=m68k make TARGET=m68ks
Install:
cp bin/vbcc* bin/vc bin/vprof /opt/vbcc/bin
The compiler is in place now…
4. Target Environment
A cross compiler needs a target environment. This includes the system headers and libraries here for the m68k Amiga platform. Also the implementation for the c standard library (think of printf…) are required for the target.
Here I only install the amiga m68k target but vbcc supports also other targets. See the following homepage for more details:
- http://sun.hasenbraten.de/vbcc/
- http://mail.pb-owl.de/~frank/vbcc/2011-08-05/vbcc_target_m68k-amigaos.lha
- http://mail.pb-owl.de/~frank/vbcc/2011-08-05/vbcc_unix_config.zip
Download the given archives, one for the m68k target the other for the vbcc descriptions how to run the compiler on a unix-like operating system.
Unzip the archives (If you don’t have lha on your machine. Have a look in MacPorts!):
lha x vbcc_target_m68k-amigaos.lha unzip vbcc_unix_config.zip
Now install the files into our destination directory:
export VBCC=/opt/vbcc mv config $VBCC/ mv vbcc_target_m68k-amigaos/targets $VBCC/
Done! Now all components are in place and we are ready for our first compile…
5. First Test
Ok, for the first test, a simple hello world is fine (file hello.c):
#include <stdio.h> int main(int argc, char **argv) { printf("hello, world!\n"); return 0; }
To compile make sure you have the environment variable VBCC set to the install directory and tha PATH holds the bin directory there:
export VBCC=/opt/vbcc export PATH=$VBCC/bin:$PATH
The compiler always needs the target platform specified with the + switch:
cv +aos68k -o hello hello.c
If all went well you have created a Amiga OS LoadSeg’able binary called hello:
> file hello hello: AmigaOS loadseg()ble executable/binary
Now launch your favorite amiga emulator (e.g. P-UAE) and give it a try!
More information on the compiler and its options can be found in the documentation on the official home page of Volker:
6. Amiga OS Development
If you want to use the Amiga Libraries in your Programs you will need the OS headers and libraries from a NDK. For the last OS 3.9 you can download it here: NDK 3.9. Simply untar the contents somewhere and define the following environment variables:
export NDK=/path/to/NDK_3.9 export NDK_INC=$NDK/include/include_h export NDK_LIB=$NDK/linker_libs
Now a typical compile line looks like:
vc +aos68k -I$NDK_INC -L$NDK_LIB -o test test.c -lamiga
Use this to compile a sample taken from the NDK:
cd $NDK/Tutorials/ARexx/Host vc +aos68k -I$NDK_INC -L$NDK_LIB RexxShell.c -lamiga
You can compare your compile (a.out) with the official binary:
> ls -la RexxShell a.out -rwxr-xr-x 1 chris staff 6652 1 Nov 1999 RexxShell* -rwxr-xr-x 1 chris staff 5988 18 Aug 20:38 a.out*
Quite nice small result! Now head on to some own code and enjoy your new compiler!
Did the following things to make it default to aos68k:
cd $VBCC/config
ln -s aos68k vc.config
Then made it use NDK includes per default also by adding “-I$NDK_INC” to the end of the -cc and -ccv lines of $VBCC/config/aos68k.
Pingback: Directory trouble compiling latest m68k cross-compiler.