a gcc-based cross-compiler for classic 68K and PPC Macintoshes
Go to file
2017-09-30 03:01:49 +02:00
binutils put macsbug name in separate section so it can be stripped out - and hack ld so that it won't be stripped out by -gc-sections 2017-09-29 22:02:21 +02:00
cmake Elf2Mac now generates CODE resources itself; --mac-flat for the old functionality 2017-09-24 16:00:00 +02:00
Console set -ffunction-sections option on libretro and libConsole, and use gc-sections in Samples/HelloWorld. 2017-09-29 22:31:35 +02:00
ConvertObj ConvertObj: add MacsBug names 2017-09-29 22:21:32 +02:00
docs add mac os rt architectures document (APPLE) 2012-04-10 23:56:07 +02:00
Elf2Mac Elf2Mac: --mac-single option for generating single-segment apps 2017-09-29 22:17:50 +02:00
gcc enable -ffunction-sections for libgcc and libc 2017-09-30 03:01:49 +02:00
hfsutils Prevent hfsutils from rebuilding configure script 2017-04-22 03:45:20 +02:00
ImportLibraries PPC: Add generated import libraries 2015-09-10 00:06:26 +02:00
InterfacesAndLibraries add empty InterfacesAndLibraries 2017-04-25 03:33:23 +02:00
libelf hack libelf to work 2017-09-29 02:05:38 +02:00
libretro set -ffunction-sections option on libretro and libConsole, and use gc-sections in Samples/HelloWorld. 2017-09-29 22:31:35 +02:00
MakeAPPL MakeAPPL: fix warning 2015-07-20 03:27:45 +02:00
PEFTools PEFTools/PEF.h tweak 2017-09-19 00:48:08 +02:00
ResourceFiles AppleDouble support 2017-09-23 21:05:40 +02:00
Rez ad boost include directory in CMakeLists, and, as a hack force use of /usr/local/include 2017-04-13 01:17:58 +02:00
Samples set -ffunction-sections option on libretro and libConsole, and use gc-sections in Samples/HelloWorld. 2017-09-29 22:31:35 +02:00
TestApps MultiSeg Apps: First working version (exceptions don't work) 2017-09-26 11:27:53 +02:00
.gitignore Major rearrangement of build-toolchain.sh; interfaces & libraries now taken from InterfacesAndLibraries/ 2017-04-25 03:33:16 +02:00
build-toolchain.bash Take only libelf from elfutils and simplify the build system 2017-09-28 18:31:03 +02:00
CMakeLists.txt Take only libelf from elfutils and simplify the build system 2017-09-28 18:31:03 +02:00
COPYING add README, COPYING and license notices 2012-04-24 03:22:36 +02:00
COPYING.RUNTIME Add GCC Runtime Library Exception to license for libretro 2015-07-15 23:23:19 +02:00
prepare-headers.sh Make things work with Universal Interfaces 3.0 2017-09-21 15:41:10 +02:00
prepare-rincludes.sh move RIncludes install location, convert line endings 2015-07-20 03:29:25 +02:00
README.md AppleDouble support 2017-09-23 21:05:40 +02:00

Retro68

A GCC-based cross-compilation environment for 68K and PowerPC Macs. Why? Because there is no decent C++11 Compiler targeting Apple's System 6. If that's not a sufficient reason for you, I'm sure you will find something more useful elsewhere.

If you are crazy enough to try it out, please say hello at wolfgang.thaller@gmx.net.

Installing/Building

Prerequisites

  • Linux or Mac OS X
  • boost
  • CMake 2.8
  • GCC dependencies: GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
  • bison version 3.0.2 or later
  • Apple Universal Interfaces (version 3.x; version 3.4 is tested)
  • An ancient Mac and/or an emulator.

For Ubuntu Linux, the following should help a bit:

sudo apt-get install cmake libgmp-dev libmpfr-dev libmpc-dev libboost-all-dev bison

On a Mac, get the homebrew package manager and:

brew install boost --c++11
brew install cmake gmp mpfr libmpc bison

In theory, you can also run Retro68 on a PowerMac G4 or G5 running Mac OS 10.4 (Tiger). In that case, get the tigerbrew package manager and

brew install gcc cmake

Apple Universal Interfaces

Before you can build Retro68, you need to find a copy of Apple's Universal Interfaces and put it inside the InterfacesAndLibraries directory in the source tree. Version 3.4 has received the most testing, but any 3.x version could theoretically work. The exact directory layout inside the InterfacesAndLibraries directory does not matter. The resource forks of the files are not required.

The Universal Interfaces used to be a free download from Apple. However, they have taken the site off-line and the license agreement does not allow redistribution, which is why it's not included in this repository. The concept of fair use might cover keeping it available for reasons of historical interest, or it might not. I am not a lawyer.

The Universal Interfaces were also included with Apple's free-to-download Macintosh Programmer's Workshop (MPW; redistribution is not officially allowed, either) and with Metrowerks CodeWarrior.

One of the most easily found downloads is the MPW 3.5 Golden Master release, usually in a file named mpg-gm.img_.bin. At the time of this writing, this can be found at:

http://macintoshgarden.org/apps/macintosh-programmers-workshop
https://www.macintoshrepository.org/1360-macintosh-programmer-s-workshop-mpw-3-0-to-3-5

You will need a Mac or a Mac emulator (with DiscCopy) to read that file.

Compiling Retro68

Once you have all the prerequisites, execute these commands from the top level of the Retro68 directory:

cd ..
mkdir Retro68-build
cd Retro68-build
../Retro68/build-toolchain.bash

The toolchain will be installed in the "toolchain" directory inside the build directory.

If you're building this on a PowerMac running Mac OS X 10.4, tell the build script to use the gcc you've installed via tigerbrew:

../Retro68/build-toolchain.bash --host-cxx-compiler=g++-5

Build options and recompiling

Building all of Retro68 involves building binutils and gcc... twice, so it takes quite a while.

You can pass the --no-68k, --no-ppc or --no-carbon flags to build-toolchain to limit yourself to the old Macs you're really interested in (note that --no-ppc implies --no-carbon).

After the initial build, you can use the --skip-thirdparty option in order to skip gcc and binutils and just compile the Retro68-specific tools, libraries and sample programs. The build-host, build-target, build-target-ppc and build-target-carbon directories are CMake build directories generated from the top-level CMakeLists.txt, so you can also cd to one of these and run make separately if you've made changes.

Sample programs

Sample programs are built in several formats:

  • On Macs: Real Mac Applications (ApplicationName.APPL)
  • Elsewhere: ApplicationName.APPL, .rsrc/ApplicationName.APPL, .finf/ApplicationName.APPL (BasiliskII/Sheepshaver compatible)
  • MacBinary files (ApplicationName.bin)
  • Raw HFS disk image (ApplicationName.dsk, containing ApplicationName)
  • AppleDouble file pairs (ApplicationName.ad, %ApplicationName.ad, Executor compatible)

Look under Retro68-build/build-target/ (68K), Retro68-build/build-target-ppc/ (PowerPC Classic) and Retro68-build/build-target-carbon/ (PowerPC Carbon) for the compiled examples.

Components

Retro68 is an aggegation of various existing free software projects with a few components added.

Third Party Components:

  • binutils 2.28
  • gcc 6.3.0
  • newlib 2.10.1 (inside the gcc directory)
  • elf2flt (from the ucLinux project's CVS)
  • hfsutils 3.2.6

Retro68-Specific Components:

  • ResourceFiles library
  • Rez
  • PEFTools (MakePEF and MakeImport)
  • MakeAPPL
  • libretro
  • TestApps - a few tiny test programs
  • Sample Programs: Raytracer, HelloWorld, Launcher, Dialog

binutils

Two new target platforms:

  • m68k-apple-macos, based on the m68k-unknown-elf target
  • powerpc-apple-macos, based on the powerpc-ibm-aix target

The powerpc target has a few hacks to make weak symbols work as expected.

gcc

Various patches and hacks:

  • New target platforms m68k-apple-macos and powerpc-apple-macos.
  • support `"\pPascal String Literals"``

68K specific:

  • Changed register usage.
  • Change the way 1-byte and 2-byte parameters are passed.
  • added a pascal calling convention (pascal or __attribute__((__pascal__)))
  • added __attribute__((__raw_inline__(word1, word2, word3))) to emulate ONEWORDINLINE and friends
  • added __attribute__((regparam("..."))) to specify custom register calling conventions
  • added #pragma parameter to specify custom register calling conventions
  • added support for the = { 0x1234 } syntax for inline machine code.

PowerPC specific:

  • New flag -carbon that makes gcc link with -lCarbonLib instead of -lInterfaceLib

newlib

Standard C library. Currently unmodified. The missing platform-dependent bits haven't been added, instead they are found in 'libretro'.

elf2flt

Converts from ELF to a much simpler binary format. Minor patch: provide symbols around .init and .fini sections

hfsutils:

No changes.

ResourceFiles

A C++ Library for manipulating resource forks.

Rez

A reimplementation of Apple's Rez resource compiler. Reads .r files containing textual resource descriptions and compiles them to binary resource files.

ConvertObj

Reads a MPW 68K Object file (*.o) and converts it to input for the GNU assembler (powerpc-apple-macos-as). Well, as long as the .o file does not use global variables or non-local function calls. Used to import glue code from MPW's Interface.o library.

MakeAPPL

Reads a FLAT executable as output by elf2flt and converts it to a MacBinary file containing a classic Macintosh application. The CMake setup for the sample programs no longer uses this, but rather uses Rez to generate the appropriate resources.

PEFTools

Tools supporting the Apple's PEF format, the Preferred Executable Format for PowerPC Macs.

  • MakePEF, a tool to convert xcoff files to PEF.
  • MakeImport, a tool to create an xcoff import stub library from a PEF-format library.

prepare-headers.sh:

Apply any necessary patches to Apple's headers.

ImportLibraries

Import Libraries in XCOFF format. Based on the list of symbols in Apple's import libraries. Generated using the MakeImport tool.

libretro

Contains startup code (handles relocations on 68K) and implementations for some standard library functions.

Console

Contains a library that implements basic text console functionality.

Sample Program: Hello World

The binary is in Retro68-build/build-target/Samples/HelloWorld/.

Sample Program: Raytracer

Calculates a nice 3D image, pixel by pixel. There are two versions: raytracer.c is a straightforward plain C implementation using floating point arithmetic.

Raytracer2 makes use of C++ features; it also uses fixed point arithmetic instead of floating point (operator overloading FTW).

The binaries are in Retro68-build/build-target/Samples/Raytracer/.

Sample Program: Launcher

A utility program for using Retro68 together with the minivmac emulator. Waits for a disk(image) to be inserted, and if it contains a single application, launches it. After the application exits, the disk is ejected again. This way, you can just drag a .dsk file generated by Retro68 on a minivmac Window to run your application.

Intended for System 6 without Multifinder.

Sample Program: Dialog

Shows a simple and useless dialog box. Demonstrates how to use Rez, the resource compiler. The binary is in Retro68-build/build-target/Samples/Dialog/.

License

The original parts of Retro68 are licensed under GPL3+, as are most other parts. Some parts are licensed GPL2+ or with more liberal licenses. Check the copyright notices in the individual files.