Skip to content

Instantly share code, notes, and snippets.

@rplacd
Last active September 11, 2024 10:02
Show Gist options
  • Save rplacd/9b791ef2516fc7ae17975465b908a1d9 to your computer and use it in GitHub Desktop.
Save rplacd/9b791ef2516fc7ae17975465b908a1d9 to your computer and use it in GitHub Desktop.
Commentary on Retro68 build process for Samples/Dialog
# COMMENTARY ON RETRO68 APPLICATION BUILD PROCESS
# ===============================================
#
# About
# =====
# Retro68, the cross-compiler toolchain for the classic 68k Macintosh (e.g. System 7), uses
# cmake makefiles. I prefer to use standard makefiles. To reverse-engineer how Retro68
# builds a sample application with a custom resource file, I built the sample application
# Samples/Dialog.
#
# Build output, and project files
# ===============================
# The build process for the Dialog sample outputs a Macintosh application
# (i.e. a file in the classic Macintosh sense of type “APPL”) with the
# following resources:
#
# - two CODE resources:
# resource ID 0 loads (LoadSeg) CODE resource ID 1, a stub that loads CODE ID 1 and jumps to it;
# resource ID 1 with the actual application code (+ Retro68 support code).
# - a SIZE resource.
# r. ID -1 contains information on requested memory sizes, etc.
# - a DLOG resource
# r. ID 128 specifies the main window’s decorations, initial size and position.
# - a DITL resource
# r. ID 128 specifies all of the controls on our main DLOG.
#
# The build process essentially builds all of these resources separately (in “binary” form), and
# then combines it together (in multiple combining steps) into the file of type “APPL”.
#
# Samples/Dialog has the following source files:
# dialog.r (DITL, DLOG, SIZE resources)
# dialog.c (eventually, CODE 1 resource)
# There is another resource dependency:
# libretro/RIncludes/Retro68APPL.r (CODE 0)
#
#
# The commands run by cmake to build Dialog are printed below.
# ============================================================
# Commentary is indicated in comments (“#”).
(nix:nix-shell-m68k-apple-macos-env) Hs-Laptop-2:Dialog h$ make VERBOSE=1
# Build the sample application Sample/Dialog.
cmake -S/Users/h/Documents/GitHub/Retro68/Samples/Dialog -B/Users/h/Documents/GitHub/Retro68/Samples/Dialog --check-build-system CMakeFiles/Makefile.cmake 0
cmake -E cmake_progress_start /Users/h/Documents/GitHub/Retro68/Samples/Dialog/CMakeFiles /Users/h/Documents/GitHub/Retro68/Samples/Dialog//CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
make -f CMakeFiles/Dialog.dir/build.make CMakeFiles/Dialog.dir/depend
make[2]: Entering directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
cd /Users/h/Documents/GitHub/Retro68/Samples/Dialog && cmake -E cmake_depends "Unix Makefiles" /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog/CMakeFiles/Dialog.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
make -f CMakeFiles/Dialog.dir/build.make CMakeFiles/Dialog.dir/build
make[2]: Entering directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
[ 25%] Building C object CMakeFiles/Dialog.dir/dialog.obj
m68k-apple-macos-gcc -ffunction-sections -MD -MT CMakeFiles/Dialog.dir/dialog.obj -MF CMakeFiles/Dialog.dir/dialog.obj.d -o CMakeFiles/Dialog.dir/dialog.obj -c /Users/h/Documents/GitHub/Retro68/Samples/Dialog/dialog.c
# Compile dialog.c to dialog.obj, a gcc-internal object file.
[ 50%] Linking C executable Dialog.code.bin
cmake -E cmake_link_script CMakeFiles/Dialog.dir/link.txt --verbose=1
m68k-apple-macos-gcc -Wl,-gc-sections -Wl,--mac-single CMakeFiles/Dialog.dir/dialog.obj -o Dialog.code.bin
# Compile dialog.obj into a binary blob, later to be boxed into CODE ID 0.
make[2]: Leaving directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
[ 50%] Built target Dialog
make -f CMakeFiles/Dialog_APPL.dir/build.make CMakeFiles/Dialog_APPL.dir/depend
make[2]: Entering directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
cd /Users/h/Documents/GitHub/Retro68/Samples/Dialog && cmake -E cmake_depends "Unix Makefiles" /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog /Users/h/Documents/GitHub/Retro68/Samples/Dialog/CMakeFiles/Dialog_APPL.dir/DependInfo.cmake "--color="
make[2]: Leaving directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
make -f CMakeFiles/Dialog_APPL.dir/build.make CMakeFiles/Dialog_APPL.dir/build
make[2]: Entering directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
[ 75%] Generating dialog.r.rsrc.bin
Rez /Users/h/Documents/GitHub/Retro68/Samples/Dialog/dialog.r -o /Users/h/Documents/GitHub/Retro68/Samples/Dialog/dialog.r.rsrc.bin
# Compile the DITL, DLOG, SIZE resources specified in dialog.r into
# a partial file, dialog.r.rsrc.bin (binary form);
[100%] Generating Dialog.bin, Dialog.APPL, Dialog.dsk, Dialog.ad, %Dialog.ad
Rez /nix/store/zssqs8zdm0bgnkgc74s4mf3549d0jdq1-libretro-m68k-apple-macos/RIncludes/Retro68APPL.r --copy Dialog.code.bin -o Dialog.bin -t APPL -c ???? --cc Dialog.dsk --cc Dialog.APPL --cc %Dialog.ad /Users/h/Documents/GitHub/Retro68/Samples/Dialog/dialog.r.rsrc.bin
# What the fuck is going on with Rez's command line options here?
# What's clear: Rez is assembling a file of type APPL, using Retro68APPL.r as
# its directive file, and copying
#
# CODE ID 0 is (in Retro68APPL.r) a jump table;
# (Rez .../Retro68APPL.r)
# (brief commentary on Retro68APPL.r:
# ...RETRO68_JUMP_TABLE is predefined in Retro68.r
# ...god knows where "FLT_FILE_NAME" comes from
# but it ends up as CODE ID 1.)
#
# CODE ID 1 is a Dialog.code.bin, but it is somehow copied in ;
# (--copy Dialog.code.bin) (???)
#
# The other resources are copied in.
# (--cc %Dialog.ad .../dialog.r.rsrc.bin) (???)
make[2]: Leaving directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
[100%] Built target Dialog_APPL
make[1]: Leaving directory '/Users/h/Documents/GitHub/Retro68/Samples/Dialog'
cmake -E cmake_progress_start /Users/h/Documents/GitHub/Retro68/Samples/Dialog/CMakeFiles 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment