From 41aaff8ac2f9b77b218e7dc9056ed95e5bcbd345 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 12:57:25 +0000 Subject: [PATCH] Build the Windows app for Mac OS X 10.4 and later (PowerPC and i386) cmake/macosx-legacy.cmake builds the app on Linux over the Mac OS X 10.0-10.5 port of clang-retro MFC, with clang of clang-retro/llvm, the macosx10.4 sysroot of dos-sdk and its cctools. cmake/macosx-legacy/ fixes headers of the 10.4 SDK. winport/CMakeLists.txt builds libwinport for the target, and BundledLibssh.cmake gives the toolchain's settings to the libssh and mbedTLS builds. The new CI job joins the PowerPC and i386 programs into one fat program, and the nightly release adds dmodem-win32-macosx10.4.tar.gz. D-Modem: its changes for 10.4 to 10.6. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01B82eRVR36R8PgTTMQiuWkQ --- .github/workflows/build.yml | 86 +++++++++++++++++++++++++++++++++++ .github/workflows/nightly.yml | 2 + README.md | 2 +- docs/building.md | 34 ++++++++++++++ docs/design.md | 2 +- docs/download.md | 9 ++++ docs/embedded-modem.md | 1 + docs/index.md | 2 +- external/D-Modem | 2 +- 9 files changed, 136 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bc8602c..6f4aceb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -249,3 +249,89 @@ jobs: with: name: ${{ matrix.artifact }} path: dmodem-win32-macos-${{ matrix.arch }}.tar.gz + + # The app for Mac OS X 10.4 (Tiger) and later, PowerPC and Intel + # (i386), as one fat program, over the Mac OS X 10.0-10.5 port of + # clang-retro MFC (cmake/macosx-legacy.cmake). All of it builds on + # Linux: clang of clang-retro/llvm (its llvm-prebuilt release, which + # has emulated TLS for 10.4), the macosx10.4 sysroot of dos-sdk (libc++ + # and Apple's MacOSX10.4u.sdk, under Apple's license), and Apple's ld64 + # and ar for PowerPC (dos-sdk's scripts/build-cctools-ppc.sh, kept in + # the cache). + winport-macosx-legacy: + name: Windows app on Mac OS X 10.4 and later (PowerPC and i386), the modem built in + runs-on: ubuntu-24.04 + env: + GH_TOKEN: ${{ github.token }} + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: actions/checkout@v4 + with: + repository: clang-retro/mfc + path: mfc + submodules: recursive + - uses: actions/checkout@v4 + with: + repository: clang-retro/dos-sdk + path: dos-sdk + - name: Packages + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + cmake ninja-build clang automake autoconf libtool uuid-dev libssl-dev zstd + - name: clang (clang-retro/llvm, llvm-prebuilt) + run: | + asset=$(gh api repos/clang-retro/llvm/releases/tags/llvm-prebuilt --jq \ + '[.assets[] | select(.name | startswith("llvm-linux-"))] | sort_by(.created_at) | last | .name') + echo "Using $asset" + gh release download llvm-prebuilt -R clang-retro/llvm -p "$asset" -O llvm.tar.zst + mkdir -p "$RUNNER_TEMP/llvm" + tar --zstd -xf llvm.tar.zst -C "$RUNNER_TEMP/llvm" + rm llvm.tar.zst + "$RUNNER_TEMP/llvm/bin/clang" --version | head -1 + echo "MACOSX_LEGACY_LLVM=$RUNNER_TEMP/llvm" >> "$GITHUB_ENV" + - name: The macosx10.4 sysroot (libc++ and MacOSX10.4u.sdk) + run: | + sh dos-sdk/packaging/get-toolchain.sh -s macosx10.4 "$RUNNER_TEMP/sysroots" + echo "MACOSX_LEGACY_SYSROOT=$RUNNER_TEMP/sysroots/macosx10.4" >> "$GITHUB_ENV" + - uses: actions/cache@v4 + id: cctools + with: + path: ${{ runner.temp }}/cctools-ppc + key: cctools-ppc-${{ hashFiles('dos-sdk/scripts/build-cctools-ppc.sh', 'dos-sdk/scripts/cctools-ppc-old-objects.patch') }} + - name: cctools (ld64 and ar for PowerPC) + if: steps.cctools.outputs.cache-hit != 'true' + run: | + PREFIX="$RUNNER_TEMP/cctools-ppc" SRC="$RUNNER_TEMP/cctools-port" \ + sh dos-sdk/scripts/build-cctools-ppc.sh > cctools.log 2>&1 || { tail -50 cctools.log; exit 1; } + - name: Build (PowerPC and i386) + run: | + export MACOSX_LEGACY_CCTOOLS="$RUNNER_TEMP/cctools-ppc" + for arch in powerpc i386; do + cmake -S . -B build/$arch -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE="$PWD/cmake/macosx-legacy.cmake" \ + -DMACOSX_LEGACY_ARCH=$arch -DCLANG_RETRO_MFC="$PWD/mfc" \ + -DDMODEM_GUI_WINPORT=ON + cmake --build build/$arch --target dmodem-win32 + done + - name: The fat program, with the built-in modem for each processor + run: | + cct="$RUNNER_TEMP/cctools-ppc/bin/powerpc-apple-darwin8-" + mkdir -p out + "${cct}lipo" -create build/powerpc/winport/dmodem-win32 build/i386/winport/dmodem-win32 \ + -output out/dmodem-win32 + "${cct}lipo" -info out/dmodem-win32 + for arch in ppc i386; do + "${cct}lipo" out/dmodem-win32 -verify_arch $arch + "${cct}nm" -arch $arch out/dmodem-win32 | grep -q dmodem_embed_start + done + # (each part is for Mac OS X 10.4) + "${cct}otool" -arch all -l out/dmodem-win32 | grep -A2 LC_VERSION_MIN_MACOSX | grep -c "version 10.4" | grep -qx 2 + - name: Package + run: tar -C out -czf dmodem-win32-macosx10.4.tar.gz dmodem-win32 + - uses: actions/upload-artifact@v4 + with: + name: dmodem-win32-macosx-legacy + path: dmodem-win32-macosx10.4.tar.gz diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4197193..412696d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -75,6 +75,7 @@ jobs: take dmodem-win32-linux dmodem-win32-linux-x86_64.tar.gz take dmodem-win32-macos dmodem-win32-macos-arm64.tar.gz take dmodem-win32-macos-x86_64 dmodem-win32-macos-x86_64.tar.gz + take dmodem-win32-macosx-legacy dmodem-win32-macosx10.4.tar.gz (cd out && sha256sum * > SHA256SUMS) ls -l out { @@ -89,6 +90,7 @@ jobs: echo "| \`dmodem-win32-linux-x86_64.tar.gz\` | The app on Linux (X11) with the modem built in, x86_64 |" echo "| \`dmodem-win32-macos-arm64.tar.gz\` | The app on macOS with the modem built in, arm64 (Apple silicon) |" echo "| \`dmodem-win32-macos-x86_64.tar.gz\` | The app on macOS with the modem built in, x86_64 (Intel Mac) |" + echo "| \`dmodem-win32-macosx10.4.tar.gz\` | The app on Mac OS X 10.4 (Tiger) and later with the modem built in, one program for PowerPC and Intel (i386). Not tested on a Mac yet |" echo "| \`SHA256SUMS\` | The SHA-256 of each file |" if [ -f missing ]; then echo diff --git a/README.md b/README.md index deb849f..155583c 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ thin Win32 shell over one small C library, libdmodemctl. | --- | --- | --- | --- | | Toolkit | Win32, C++ | Win32, over the Cocoa layer of [clang-retro MFC](https://github.com/clang-retro/mfc) | Win32, over the X11 and Wayland layer of clang-retro MFC | | Built with | [clang-retro](https://clang-retro.github.io/), MinGW or MSVC | clang | clang | -| Runs on | Windows 95 and later | arm64 (Apple silicon) and x86_64 (Intel Mac) | x86_64 | +| Runs on | Windows 95 and later | arm64 (Apple silicon) and x86_64 (Intel Mac). Also Mac OS X 10.4 and later on PowerPC and i386 | x86_64 | The source code of the app is the same on each system. Refer to "The Windows app on Linux and macOS" in [Design](docs/design.md). diff --git a/docs/building.md b/docs/building.md index be3f5a5..7f59cba 100644 --- a/docs/building.md +++ b/docs/building.md @@ -52,6 +52,40 @@ for an Intel Mac on a Mac with Apple silicon, add `-DCMAKE_OSX_ARCHITECTURES=x86_64` to the first command. Set one architecture only. The app cannot be a universal binary. +## Mac OS X 10.4 and later (PowerPC and Intel) + +The app for Mac OS X 10.4 (Tiger) and later builds on Linux. It uses the +Mac OS X 10.0-10.5 port of clang-retro MFC and the toolchain file +`cmake/macosx-legacy.cmake`. You need these items: + +- clang of [clang-retro/llvm](https://github.com/clang-retro/llvm) (its + `llvm-prebuilt` release). The clang of the clang-dos package can be too + old: it must have emulated TLS for Mac OS X 10.4. +- The `macosx10.4` sysroot of [clang-retro/dos-sdk](https://github.com/clang-retro/dos-sdk): + `sh packaging/get-toolchain.sh -s macosx10.4 DIR`. It has libc++ and + the builtins, and the script also gets Apple's `MacOSX10.4u.sdk`. + Apple's license applies to the SDK. +- Apple's `ld64` and `ar` for PowerPC: `PREFIX=DIR sh scripts/build-cctools-ppc.sh` + in dos-sdk. This `ld64` also links for i386. + +Build the app one time for each processor (`powerpc` and `i386`): + + export MACOSX_LEGACY_LLVM=/path/to/llvm MACOSX_LEGACY_SYSROOT=/path/to/macosx10.4 \ + MACOSX_LEGACY_CCTOOLS=/path/to/cctools-ppc + cmake -S . -B build/powerpc -G Ninja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=$PWD/cmake/macosx-legacy.cmake \ + -DMACOSX_LEGACY_ARCH=powerpc -DCLANG_RETRO_MFC=/path/to/mfc -DDMODEM_GUI_WINPORT=ON + cmake --build build/powerpc --target dmodem-win32 + +Then join the two programs into one fat program: + + $MACOSX_LEGACY_CCTOOLS/bin/powerpc-apple-darwin8-lipo -create \ + build/powerpc/winport/dmodem-win32 build/i386/winport/dmodem-win32 -output dmodem-win32 + +`cmake/macosx-legacy/` has the fixes for headers of the 10.4 SDK +(`time.h`, `signal.h` and `net/if.h`). The built-in modem needs D-Modem +with the changes for 10.4 to 10.6 (`docs/macos-details.md` in D-Modem). + ## The library only With no `DMODEM_GUI_WINPORT`, a build on Linux or macOS makes only diff --git a/docs/design.md b/docs/design.md index 6831146..624270a 100644 --- a/docs/design.md +++ b/docs/design.md @@ -570,7 +570,7 @@ code is the same as on Windows. alphabetical order, with no Bluetooth devices). To use another device, set the environment variable `WINPORT_COMn`. For example, with `WINPORT_COM5=/dev/ttyUSB0`, `COM5` is `/dev/ttyUSB0`. -- CI builds the app on Linux, and on macOS for arm64 and x86_64. On Linux, `winport/test/smoke.sh` +- CI builds the app on Linux, on macOS for arm64 and x86_64, and on Linux for Mac OS X 10.4 (PowerPC and i386, `cmake/macosx-legacy.cmake`). On Linux, `winport/test/smoke.sh` starts the app in Xvfb three times: with a TCP line, with a dmodemd that the app starts (`winport/test/dmodemd`, a test dmodemd), and with the built-in modem on a SIP line with no account. For the first two, diff --git a/docs/download.md b/docs/download.md index 75b1185..009a9ea 100644 --- a/docs/download.md +++ b/docs/download.md @@ -19,6 +19,7 @@ When `main` has no new commits, the release does not change. | Linux, x86_64 (X11) | [`dmodem-win32-linux-x86_64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-linux-x86_64.tar.gz) | The app on Linux, with the built-in modem. | | macOS, arm64 (Apple silicon) | [`dmodem-win32-macos-arm64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macos-arm64.tar.gz) | The app on macOS, with the built-in modem. | | macOS, x86_64 (Intel Mac) | [`dmodem-win32-macos-x86_64.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macos-x86_64.tar.gz) | The app on macOS, with the built-in modem. | +| Mac OS X 10.4 and later, PowerPC and Intel | [`dmodem-win32-macosx10.4.tar.gz`](https://github.com/D-Modem/gui/releases/download/nightly/dmodem-win32-macosx10.4.tar.gz) | The app with the built-in modem. One program for PowerPC (G3, G4, G5) and Intel (i386). It is not tested on a Mac yet. | | All | [`SHA256SUMS`](https://github.com/D-Modem/gui/releases/download/nightly/SHA256SUMS) | The SHA-256 of each file. | If a file is not in the release, the newest build did not make it. The @@ -50,6 +51,14 @@ The result for the file must be `OK`. `xattr -d com.apple.quarantine dmodem-win32`. The app is not notarized. 4. Start the app. Type `./dmodem-win32`. +## Install on Mac OS X 10.4 to 10.6 + +1. Download `dmodem-win32-macosx10.4.tar.gz`. The file is for PowerPC + Macs and for Intel Macs. +2. Extract the file. In Terminal, type + `tar -xzf dmodem-win32-macosx10.4.tar.gz`. +3. Start the app. Type `./dmodem-win32`. + ## Install on Linux 1. Install the libraries. On Ubuntu 24.04, type diff --git a/docs/embedded-modem.md b/docs/embedded-modem.md index 44463ee..c55309c 100644 --- a/docs/embedded-modem.md +++ b/docs/embedded-modem.md @@ -79,6 +79,7 @@ Windows and macOS, the build links libusb (LGPL-2.1) statically, as | Windows 95, NT 4.0 and later | Done (`win32-picolibc` build). It builds, and its imports agree with Windows 95 and NT 4.0. It is not tested on Windows or Wine yet. Refer to "Windows 95" below. | | Linux | Done. CI builds it, checks that the library is in the app, and starts the built-in modem in Xvfb (`winport/test/smoke.sh`). | | macOS | Done (arm64 and x86_64). CI builds it for each architecture, and checks that the library is in the app. It is not tested on a Mac yet. | +| Mac OS X 10.4 and later | Done (PowerPC and i386, one fat program). CI builds it on Linux, and checks that the library is in each part of the program. It is not tested on a Mac yet. | ### Windows 95 diff --git a/docs/index.md b/docs/index.md index c85027f..57b9635 100644 --- a/docs/index.md +++ b/docs/index.md @@ -92,7 +92,7 @@ same way on each system. | | Windows | macOS | Linux | | --- | --- | --- | --- | | Toolkit | Win32, C++ | Win32, over the Cocoa layer of clang-retro MFC | Win32, over the X11 and Wayland layer of clang-retro MFC | -| Runs on | Windows 95 and later | arm64 (Apple silicon) and x86_64 (Intel Mac) | x86_64 | +| Runs on | Windows 95 and later | arm64 (Apple silicon) and x86_64 (Intel Mac). Also Mac OS X 10.4 and later on PowerPC and i386 | x86_64 | | Built-in modem | Yes | Yes | Yes | Refer to [Design](design.md). diff --git a/external/D-Modem b/external/D-Modem index ac711ce..828f261 160000 --- a/external/D-Modem +++ b/external/D-Modem @@ -1 +1 @@ -Subproject commit ac711ce6e6456df60fe6a48e0666746750e52d5b +Subproject commit 828f261856f7316006b01295ec8159027b61d872