Skip to content

The build scripts I use(d) to build the m68k-atari-mint cross-compiler tools for macOS

Notifications You must be signed in to change notification settings

pd95/m68k-atari-mint-cross-tools

Repository files navigation

m68k-atari-mint cross compiler scripts for macOS

This is a collection of Makefiles I'm using to build the m68k-atari-mint cross-compiler tools for macOS based on Vincent Rivières cross-tools description. The cross-compiler can be used to develop applications for the Atari ST and compatible systems. It is based on the works of the FreeMiNT project

The collection consists of the following:

Host tools:

  • GNU Binutils: assembler and linker
  • MiNTbin: supplemental MiNT specific tools for the GNU Binutils
  • GNU Compiler Collection (GCC): the C and C++ compiler, which depends on the following libraries:
    • GMP is the GNU Multiple Precision Arithmetic Library
    • MPFR is the GNU Multiple-precision floating-point rounding library, which depends on GMP.
    • MPC is the GNU Multiple-precision C library, which depends on GMP and MPFR.

Target libraries and applications:

  • MiNTLib which is the standard C library for FreeMiNT
  • PML, portable math library for C programs for FreeMiNT
  • GEMlib GEM bindings for writing GEM apps (=library to access AES and VDI layers)
  • CFLib GEM utility library (used by QED)
  • QED GEM text editor, a good test application to check the cross-compiler

Prerequisites

To use the Makefiles, you will have to install:

The scripts/Makefiles are automatically going to download the required sources and MiNT specific patches from Vincents page. For a few parts, I had to adjust the patches respectively write macOS specific patches. Those are stored in the archive folder.

GCC depends on three additional libraries (GMP, MPFR and MPC). As we want to statically link them to the compiler, they are also automatically built and stored in the gcclibs subfolder.

Goal

The goal of this package/bundle of scripts is to have a single command to build and install the whole cross-compiler tools.

The tools are installed in the /opt/cross-mint folder. You need administration rights to create this directory on your system.

Build

First, ensure that the /opt/cross-mint directory exists and is writable by your user.

To create the directory and take full ownership of it, you can use the following commands:

sudo mkdir -p /opt/cross-mint
sudo chown $USER /opt/cross-mint

To build and install the cross-compiler toolset, you should simply checkout this repository to a local folder and type make:

git clone https://github.com/pd95/m68k-atari-mint-cross-tools.git m68k-atari-mint
cd m68k-atari-mint
make

This will build and install the tool in /opt/cross-mint and will produce a "distribution package" in the packages directory.

Known problems

On older macOS versions (e.g. macOS Sierra 10.13) where the tar command is unable to extract bz2 or lz compressed files, you will encounter the error message tar: Unrecognized archive format while gcclibs is being executed.

To fix this you have to install gnu-tar and lzip using brew:

brew install gnu-tar lzip

Usage

To use the cross-compiler, you will have to add the compiler binary/manual pages location to your search path:

export PATH=$PATH:/opt/cross-mint/bin
export MANPATH=$MANPATH:/opt/cross-mint/share/man

Here is a primitive TOS program

hello.c:

#include <stdio.h>

int main(int argc, char* argv[])
{
    puts("Hello, world !");
    return 0;
}

It can be compiled with the command:

m68k-atari-mint-gcc hello.c -o hello.tos

Here is a simple AES test application:

alert.c:

#include <gem.h>

int main()
{
    appl_init();
    form_alert( 1, "[1][Hi there!][[Hi!|B[ye!]" );
    appl_exit();
    return 0;
}

which can be compiled with

m68k-atari-mint-gcc alert.c -lgem -o alert.prg