Date: 20230805

Building gcc for the motorola 68000

The last version of gcc still supports the m68k.

First get and build binutils. This setup uses an out-of-tree build to avoid polluting the source dir:

$ wget https://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.xz
$ tar Jxvf binutils-2.40.tar.xz
$ mkdir binutils-2.40-m68k-elf
$ cd binutils-2.40-m68k-elf
$ ../binutils-2.40/configure --prefix=$HOME/.local --target=m68k-elf
$ make
$ make install

Then add the prefix to your path if not done already. In bash this is:

PATH=$PATH:$HOME/.local/bin
export PATH

Then build gcc, only for c language and without any libc. You need to:

apt install libgmp-dev libmpfr-dev libmpc-dev

Also, it HAS TO BE an out-of-tree build, according to this link:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42557#c5

$ wget https://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-13.2.0/gcc-13.2.0.tar.xz
$ tar Jxvf gcc-13.2.0-tar.xz
$ mkdir gcc-13.2.0-m68k-elf
$ cd gcc-13.2.0-m68k-elf
$ ../gcc-13.2.0/configure --prefix=$HOME/.local --target=m68k-elf --enable-languages=c --disable-libssp
$ make
$ make install

Test it:

$ $HOME/.local/bin/m68k-elf-gcc --version
m68k-elf-gcc (GCC) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Enjoy the m68k!