From 17792beb5eb597e70aed0540e46d66acd23e6bea Mon Sep 17 00:00:00 2001 From: deryk Date: Wed, 25 Nov 2026 18:32:07 +0800 Subject: [PATCH] Docs: align toolchain NDK and Makefile template docs with ApolloCrossDev PR #38 --- toolchain/index.md | 16 +++-- toolchain/project-makefile.md | 116 ++++++++++++++++++++++----------- toolchain/target-os-headers.md | 63 +++++++++++++----- 3 files changed, 133 insertions(+), 62 deletions(-) diff --git a/toolchain/index.md b/toolchain/index.md index d2d7bcd..2897195 100644 --- a/toolchain/index.md +++ b/toolchain/index.md @@ -19,6 +19,7 @@ related: sources: - "github.com/WDrijver/ApolloCrossDev README.md" - "github.com/WDrijver/ApolloCrossDev GCC-6.50-Dev-Linux.sh" + - "github.com/WDrijver/ApolloCrossDev pull request #38 (commit c1fba26 / 57cb85c, 2026-11-25) and issue #32" - "WDrijver (ApolloCrossDev maintainer), 2026-11-02" --- @@ -55,12 +56,15 @@ C and C++: `-O2 -m68080 -m68881 -ffast-math -fomit-frame-pointer`. Details in ### What else is installed -- Amiga NDKs 1.3, 3.9 and 3.2 (3.2 is the default), see - `toolchain/target-os-headers.md` -- C runtimes libnix (default) and clib2 -- Libraries and headers: MUI 5, SDL (base, mixer, ttf, image), Vorbis, Ogg, - GL, FreeType, Timidity, zlib, minizip, Lua, MPEGA, P96 headers -- DevPac includes for assembly, in `/m68k-amigaos/DevPac` +- Amiga NDK 3.2 in `/m68k-amigaos/ndk-include` (default) and NDK 1.3 + in `/m68k-amigaos/ndk13-include`; ApolloCrossDev does not install + `ndk39-include`, see `toolchain/target-os-headers.md` +- C runtime `libnix` (`-noixemul`, default); ApolloCrossDev does not install + `clib2/include` +- Libraries and headers: MUI 5 (`include/mui`), SDL (base, mixer, ttf, image), + Vorbis, Ogg, GL, FreeType, Timidity, zlib, minizip, Lua, MPEGA, P96 headers +- DevPac includes and libraries for assembly, in + `/m68k-amigaos/DevPac` (`Include` and `Lib`) - ApolloExplorer (`acp`) to upload files to an Apollo V4 over the network - bgdbserver, a GDB server that runs on the Apollo V4 for remote debugging - ApolloLib in `Projects/ApolloLib`: sound, picture, PIP, pointer, input, diff --git a/toolchain/project-makefile.md b/toolchain/project-makefile.md index fc2ffe3..94833e7 100644 --- a/toolchain/project-makefile.md +++ b/toolchain/project-makefile.md @@ -12,18 +12,25 @@ tags: [makefile, build, upload, debug, apolloexplorer, bgdbserver] related: - toolchain/c-compiler-options.md - toolchain/vasm-assembler.md + - toolchain/target-os-headers.md sources: - - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (template v1.0, 2025-11-28; v1.2, pull request #22, commit d636629, 2026-11-05)" + - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (template v1.0 at 6db8ff8, 2025-11-28)" + - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (earlier v1.2, pull request #22, commit d636629, 2026-11-05)" + - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (later local-only v1.2, commit d571781, 2026-11-08)" + - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (include and path fixes, pull request #38, commit c1fba26 / 57cb85c, 2026-11-25)" - "github.com/WDrijver/ApolloCrossDev README.md" --- ## Summary New ApolloCrossDev projects copy `Projects/_makefiles/Makefile`. It compiles -all `.c` and `.s` files in the project folder and ApolloLib's sources, -links them into one executable, and uploads it to the Apollo V4 with -ApolloExplorer. From template v1.2 (2026-11-05) a project can live anywhere, -and `make compile` builds without uploading. +all `.c` and `.s` files in the project folder and ApolloLib's sources, and +links them into one executable. Which Make targets exist, and whether any of +them upload to the Apollo V4, depends on the exact template revision: the +header comment `v1.2` alone does not distinguish the earlier upload-capable +v1.2 template from the later local-build-only v1.2 template. + +Inspect the project's actual Makefile before running any Make target. ## Details @@ -35,51 +42,79 @@ and `make compile` builds without uploading. 3. Set `PROJECT_NAME` in the Makefile. 4. Add sources: `.c` for C, `.s` for assembly. For C++, see the Do / Don't section. -5. Run `make compile` (build only) or `make` (build and upload) in the - project folder. - -The template finds ApolloCrossDev through `ACD_ROOT`: the environment -variable `APOLLOCROSSDEV` when it is set, otherwise `../..`. A project -outside `Projects/` therefore needs `APOLLOCROSSDEV` set to the -ApolloCrossDev folder, for example `export APOLLOCROSSDEV="$HOME/ApolloCrossDev"` -in `~/.bashrc` or `~/.zshrc`, next to `AMIGAHOST`. The compiler is then -`$(ACD_ROOT)/Compilers/GCC-6.50-Dev` (`PREFIX`). Template v1.0 had no -`ACD_ROOT` and only worked two levels below the ApolloCrossDev root. +5. Inspect the targets defined in that Makefile, then run only a target + whose actual recipes match your intent (local build vs hardware upload). + +From template v1.2 (pull request #22, `d636629`, 2026-11-05), a project can +live anywhere. The template finds ApolloCrossDev through `ACD_ROOT`: the +environment variable `APOLLOCROSSDEV` when it is set, otherwise `../..`. A +project outside `Projects/` therefore needs `APOLLOCROSSDEV` set to the +ApolloCrossDev folder, for example +`export APOLLOCROSSDEV="$HOME/ApolloCrossDev"` in `~/.bashrc` or +`~/.zshrc`. The compiler is then `$(ACD_ROOT)/Compilers/GCC-6.50-Dev` +(`PREFIX`). Template v1.0 (`6db8ff8`) had no `ACD_ROOT` and only worked two +levels below the ApolloCrossDev root. ### Main variables -| Variable | Default | Purpose | +| Variable | Default (PR #38, `c1fba26`) | Purpose | |---|---|---| | `ACD_ROOT` | `$APOLLOCROSSDEV`, else `../..` | The ApolloCrossDev folder (v1.2) | | `C_COMPILER` | `m68k-amigaos-gcc` | Switch to `m68k-amigaos-g++` for C++ | -| `C_LIB` | `-noixemul` | C runtime (libnix); alternative `-mcrt=clib2` | -| `C_INCL_NDK` | NDK 3.2 | NDK headers, see `toolchain/target-os-headers.md` | +| `C_LIB` | `-noixemul` | C runtime (libnix); commented `-mcrt=clib2` / `clib2/include` is not installed by ApolloCrossDev | +| `C_INCL_NDK` | `$(PREFIX)/$(TARGET)/ndk-include` | Installed NDK 3.2 headers; `ndk13-include` is installed; `ndk39-include` is not installed (`toolchain/target-os-headers.md`) | +| `C_INCL_MUI` | off (`$(PREFIX)/$(TARGET)/include/mui`) | Optional MUI headers (lowercase `mui`, fixed in PR #38 for case-sensitive filesystems) | | `C_OPTIONS` | `-O2 -m68080 -m68881 -ffast-math -fomit-frame-pointer -DREGPARM=4` | Compiler options. Ignore `-DREGPARM=4`. | | `C_DEBUG` | `-g` | Debug information | -| `S_FLAGS` | `-Fhunk -m68080 -m68881 -opt-speed -linedebug -kick1hunks -I` | Assembler options | +| `S_FLAGS` | `-Fhunk -m68080 -m68881 -opt-speed -linedebug -kick1hunks -I` | Assembler options (`S_INCLUDE` is `DevPac/Include`; unused `S_LIBS` is `DevPac/Lib` from PR #38) | | `APOLLOLIB` | `$(ACD_ROOT)/Projects/ApolloLib` | ApolloLib, compiled into the program; put `#` before it to build without | | `C_LIBS_SDL`, `C_LIBS_MUI`, `C_LIBS_MATH` | off | Extra libraries, enable by removing `#` | +Pull request #38 (`c1fba26`, 2026-11-25) also fixed these Makefile paths +across the template and project Makefiles: + +- Switched `C_INCL_NDK` from nonexistent `ndk32-include/Include_H` to + installed `ndk-include`, and marked commented `ndk39-include` and + `clib2/include` as not installed by ApolloCrossDev. +- Removed the undefined `-I$(C_INCL)` token from `C_INCL_ALL` (which + previously expanded to `-I -I.../sys-include` and caused GCC to treat + `-I.../sys-include` as a directory name). +- Changed `S_LIBS` from `DevPac/Libs` to `DevPac/Lib`. +- Changed `C_INCL_MUI` from `include/MUI` to `include/mui`. + The template only collects `.c` and `.s` files (`C_FILES`, `S_FILES`). From -v1.2 it compiles ApolloLib's `.c` and `.s` files with the project's flags -into the project's `.apollolib/` folder, and adds `-I$(APOLLOLIB)` (see -[apollolib/index.md](apollolib/index.md)). Template v1.0 linked ready-made -`.o` files from `Projects/ApolloLib` instead. +v1.2 (`d636629`) it compiles ApolloLib's `.c` and `.s` files with the +project's flags into the project's `.apollolib/` folder, and adds +`-I$(APOLLOLIB)` (see [apollolib/index.md](apollolib/index.md)). Template +v1.0 (`6db8ff8`) linked ready-made `.o` files from `Projects/ApolloLib` +instead. -### Targets +### Targets by revision -| Command | What it does | -|---|---| -| `make compile` | Compile and link only, no upload (v1.2) | -| `make` | Compile, link, upload executable and icon to `RAM Disk:` on the Apollo V4, clean up | -| `make debug` | As `make`, and also uploads bgdbserver and a `_Debug` script that starts the program under bgdbserver | +Both upload-capable and local-build-only templates carry the +`# ApolloCrossDev Makefile Template v1.2` header. Identify behaviour from +the actual Makefile targets and recipes, not from the `v1.2` label alone: -Upload uses ApolloExplorer's `acp` to `"${AMIGAHOST}:Ram Disk/"`. Set -`AMIGAHOST` to the Apollo V4's IP address. +| Revision | Local compile and link | Upload / remote debug | +|---|---|---| +| v1.0 (`6db8ff8`, 2025-11-28) | `make cleanbefore build` (no `compile` target) | Default `make` (`all`) and `make debug` upload to `"${AMIGAHOST}:Ram Disk/"` via ApolloExplorer `acp` | +| Earlier v1.2 (PR #22, `d636629`, 2026-11-05) | `make compile` (no upload) | Default `make` and `make debug` still upload via `acp` | +| Later v1.2 (`d571781`, 2026-11-08) and PR #38 (`c1fba26`, 2026-11-25) | Default `make` (`all: init cleanbefore build cleanafter exit`); no `compile` target | No `upload_*` or `debug` targets in the template; copy the executable to the V4 separately | + +Never run `make`, `make compile`, `make debug`, or any other Make target +without first inspecting the project's Makefile to confirm its actual +effects. On revisions that still include upload targets, upload uses +ApolloExplorer's `acp` to `"${AMIGAHOST}:Ram Disk/"` (requiring `AMIGAHOST` +to be set to the Apollo V4's IP address). ### Remote debugging -1. Run `make debug`. +`make debug` (uploading `bgdbserver` and a `_Debug` script to +`RAM Disk:`) was present in template v1.0 (`6db8ff8`) and earlier v1.2 +(`d636629`), and was removed in later v1.2 (`d571781`). When working with a +Makefile that still defines `make debug`: + +1. Confirm `make debug` is defined in the project's Makefile, then run it. 2. Set breakpoints in VS Code on the host. 3. Start debugging in VS Code (F5) and select the project. 4. On the Apollo V4, double-click the program's `_Debug` icon in `RAM Disk:`. @@ -87,15 +122,20 @@ Upload uses ApolloExplorer's `acp` to `"${AMIGAHOST}:Ram Disk/"`. Set ## Differences from AmigaOS / AROS / 68060 - The build runs on the host (Linux or macOS), not on the Amiga. The Apollo - V4 only receives the executable. -- Template v1.0 started with `clear`, which stops the build when there is no - terminal (`TERM environment variable not set`), as in IDE tasks and AI - agents. v1.2 ignores that error. + V4 only receives the executable when an upload target is present and run, + or when you copy the executable manually. +- Template v1.0 (`6db8ff8`) started with `clear`, which stops the build when + there is no terminal (`TERM environment variable not set`), as in IDE + tasks and AI agents. Template v1.2 (`d636629` onward) ignores that error. ## Do / Don't -- DO start new projects from the Makefile template (v1.2 or later). -- DO build with `make compile` when you don't want to upload to the V4. +- DO start new projects from a current ApolloCrossDev Makefile template + (pull request #38, `c1fba26`, or later). +- DO inspect a project's actual Makefile targets and recipes before running + Make, rather than assuming behaviour from the `v1.2` header alone. - DO add `.cpp` files to the template's file lists yourself when using C++. The template does not collect them. +- DON'T run an arbitrary Make target without checking whether its recipe or + prerequisites upload to hardware. - DON'T remove `-m68080` from `C_OPTIONS` or `S_FLAGS`. diff --git a/toolchain/target-os-headers.md b/toolchain/target-os-headers.md index a271cf0..fd7a1fe 100644 --- a/toolchain/target-os-headers.md +++ b/toolchain/target-os-headers.md @@ -11,53 +11,80 @@ applies_to: tags: [ndk, headers, target-os] related: - toolchain/c-compiler-options.md + - toolchain/project-makefile.md - os/apolloos-and-amigaos-on-v4.md sources: - - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile" + - "github.com/WDrijver/ApolloCrossDev Projects/_makefiles/Makefile (pull request #38, commit c1fba26 / 57cb85c, 2026-11-25)" - "github.com/WDrijver/ApolloCrossDev GCC-6.50-Dev-Linux.sh" + - "github.com/WDrijver/ApolloCrossDev issue #32 (WDrijver decision, 2026-11-25)" - "WDrijver (ApolloCrossDev maintainer), 2026-11-02" --- ## Summary -ApolloCrossDev installs the Amiga NDK headers for versions 1.3, 3.9 and 3.2. -NDK 3.2 is the default. Choose the NDK that matches the oldest target OS of -the project. +ApolloCrossDev installs the Amiga NDK 3.2 headers at `ndk-include` (default) +and the NDK 1.3 headers at `ndk13-include`. It does **not** install +`ndk39-include` or `clib2/include`. Assess any project's need for +AmigaOS 3.9-specific headers separately before configuring `C_INCL_NDK`. ## Details ### Installed NDKs -| NDK | Include path | Target OS | -|---|---|---| -| 3.2 (default) | `/m68k-amigaos/ndk32-include/Include_H` | `amigaos-3.2`, `apolloos-r10` | -| 3.9 | `/m68k-amigaos/ndk39-include` | `amigaos-3.9` | -| 1.3 | `/m68k-amigaos/ndk13-include` | none of the supported targets | +From ApolloCrossDev pull request #38 (`c1fba26`, 2026-11-25), the project +Makefile template and project Makefiles match the `amiga-gcc` layout that +the GCC-6.50 install scripts produce (`make all NDK=3.2`): + +| NDK | Include path | Installed by ApolloCrossDev | Target OS | +|---|---|---|---| +| 3.2 (default) | `/m68k-amigaos/ndk-include` | yes | `amigaos-3.2`, `apolloos-r10` (and general APIs on `amigaos-3.9`) | +| 1.3 | `/m68k-amigaos/ndk13-include` | yes | none of the supported V4 targets | +| 3.9 | `/m68k-amigaos/ndk39-include` | no | optional, if a project supplies NDK 3.9 headers itself | + +Earlier ApolloCrossDev Makefiles named `ndk32-include/Include_H` as the +default `C_INCL_NDK`. The GCC-6.50 install scripts never created that +directory; builds succeeded only because GCC's built-in include search path +already contains `m68k-amigaos/ndk-include` and GCC silently ignores `-I` +directories that do not exist. Pull request #38 switched `C_INCL_NDK` to +`$(PREFIX)/$(TARGET)/ndk-include` and marked `ndk39-include` (and +`clib2/include`) as `# NOT installed by ApolloCrossDev`. ApolloCrossDev builds its runtime libraries against NDK 3.2 (`make all NDK=3.2`). ### Which NDK for which target -- Targets `amigaos-3.2` and/or `apolloos-r10`: NDK 3.2. ApolloOS R10 aims to - be compatible with AmigaOS 3.2.x. -- Target includes `amigaos-3.9`: NDK 3.9, so functions that AmigaOS 3.9 does - not have are not declared, and calling them gives a compiler warning or - error instead of a crash at run time. +- Targets `amigaos-3.2` and/or `apolloos-r10`: use the installed NDK 3.2 at + `/m68k-amigaos/ndk-include`. ApolloOS R10 aims to be compatible + with AmigaOS 3.2.x. +- Target includes `amigaos-3.9`: assess the project's header needs + separately. ApolloCrossDev does not install NDK 3.9; its scripts install + NDK 3.2, which covers AmigaOS 3.9 and later but also declares functions + added in AmigaOS 3.2. If a project requires strict compile-time + enforcement against AmigaOS 3.2-only APIs, obtain and install NDK 3.9 + headers separately and point `C_INCL_NDK` at that directory. ### Why it matters The NDK 3.2 headers declare functions added in AmigaOS 3.2. A program built against them for AmigaOS 3.9 compiles and links without errors, but fails at -run time when it calls a function that 3.9 does not have. +run time when it calls a function that 3.9 does not have. Because GCC +silently skips nonexistent `-I` directories, uncommenting an uninstalled +`ndk39-include` line in a Makefile does not switch headers — GCC quietly +falls back to its built-in `ndk-include` (NDK 3.2). ## Differences from AmigaOS / AROS / 68060 -- DON'T use the AROS SDK headers for Apollo V4 programs. Use the NDK that - matches the target OS. +- DON'T use the AROS SDK headers for Apollo V4 programs. Use the Amiga NDK + headers that match the project's target OS policy. ## Do / Don't -- DO pick the NDK from the project's target OS list. +- DO use `/m68k-amigaos/ndk-include` for NDK 3.2 on current + ApolloCrossDev installs. +- DO verify that any custom `C_INCL_NDK` directory (such as a user-supplied + NDK 3.9 tree) actually exists before relying on it for compile-time API + checks. +- DON'T assume ApolloCrossDev installs `ndk39-include` or `clib2/include`. - DON'T call a function that is missing in one of the project's target operating systems.