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/cmake/macosx-legacy.cmake b/cmake/macosx-legacy.cmake new file mode 100644 index 0000000..ab54095 --- /dev/null +++ b/cmake/macosx-legacy.cmake @@ -0,0 +1,99 @@ +# CMake toolchain file for Mac OS X 10.4 (Tiger) and later, on 32-bit +# PowerPC or 32-bit Intel. It builds the Windows app (winport/) over the +# Mac OS X 10.0-10.5 port of clang-retro MFC, on Linux. +# +# cmake -S . -B build/ppc -DCMAKE_TOOLCHAIN_FILE=cmake/macosx-legacy.cmake \ +# -DMACOSX_LEGACY_ARCH=powerpc -DMACOSX_LEGACY_LLVM=/opt/llvm \ +# -DMACOSX_LEGACY_SYSROOT=/opt/clang-dos/macosx10.4 \ +# -DMACOSX_LEGACY_CCTOOLS=/opt/cctools-ppc \ +# -DCLANG_RETRO_MFC=/path/to/mfc -DDMODEM_GUI_WINPORT=ON +# +# You need these: +# MACOSX_LEGACY_ARCH powerpc or i386 +# MACOSX_LEGACY_LLVM clang of clang-retro/llvm (the llvm-prebuilt +# release), with emulated TLS for Mac OS X 10.4 +# MACOSX_LEGACY_SYSROOT the macosx10.4 sysroot of clang-retro/dos-sdk +# (packaging/get-toolchain.sh -s macosx10.4): libc++, +# and MacOSX10.4u.sdk in it +# MACOSX_LEGACY_CCTOOLS Apple's ld64 and ar for PowerPC +# (dos-sdk's scripts/build-cctools-ppc.sh) +# The environment variables of the same names also set them. +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_VERSION 8.0) + +foreach(_v ARCH LLVM SYSROOT CCTOOLS) + if(NOT MACOSX_LEGACY_${_v} AND DEFINED ENV{MACOSX_LEGACY_${_v}}) + set(MACOSX_LEGACY_${_v} "$ENV{MACOSX_LEGACY_${_v}}") + endif() + if(NOT MACOSX_LEGACY_${_v}) + message(FATAL_ERROR "Set MACOSX_LEGACY_${_v} (cmake/macosx-legacy.cmake)") + endif() + set(MACOSX_LEGACY_${_v} "${MACOSX_LEGACY_${_v}}" CACHE STRING "" FORCE) + # (the builds that D-Modem configures with this file see them too) + set(ENV{MACOSX_LEGACY_${_v}} "${MACOSX_LEGACY_${_v}}") +endforeach() +# (try_compile projects see these) +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + MACOSX_LEGACY_ARCH MACOSX_LEGACY_LLVM MACOSX_LEGACY_SYSROOT MACOSX_LEGACY_CCTOOLS) + +set(CMAKE_SYSTEM_PROCESSOR ${MACOSX_LEGACY_ARCH}) +set(MACOSX_LEGACY_TARGET "${MACOSX_LEGACY_ARCH}-apple-macosx10.4") +set(MACOSX_LEGACY_SDK "${MACOSX_LEGACY_SYSROOT}/MacOSX10.4u.sdk") +set(_cct "${MACOSX_LEGACY_CCTOOLS}/bin/powerpc-apple-darwin8-") + +set(CMAKE_OSX_SYSROOT "${MACOSX_LEGACY_SDK}") +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.4) +set(CMAKE_OSX_ARCHITECTURES "") +# ld64 cannot read the symbol table that llvm-ar writes for PowerPC +set(CMAKE_AR "${_cct}ar") +set(CMAKE_RANLIB "${_cct}ranlib") +set(CMAKE_LIPO "${_cct}lipo") +set(CMAKE_INSTALL_NAME_TOOL "${_cct}install_name_tool") + +# The C library functions that Mac OS X 10.4 does not have, such as +# clock_gettime: port/compat/macosx of clang-retro MFC (CLANG_RETRO_MFC), +# and cmake/macosx-legacy (the fixes of headers of the 10.4 SDK). +# libwinport.a has their code. _DARWIN_C_SOURCE: gmtime_r and the other +# POSIX functions also with -std=c99. And libc++ of the sysroot, with +# threads. +if(NOT CLANG_RETRO_MFC AND DEFINED ENV{CLANG_RETRO_MFC}) + set(CLANG_RETRO_MFC "$ENV{CLANG_RETRO_MFC}") +endif() +if(NOT CLANG_RETRO_MFC) + message(FATAL_ERROR "Set CLANG_RETRO_MFC (cmake/macosx-legacy.cmake)") +endif() +set(ENV{CLANG_RETRO_MFC} "${CLANG_RETRO_MFC}") +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CLANG_RETRO_MFC) +# These are mandatory arguments of the compilers, with the target, not +# flags: a -DCMAKE_C_FLAGS of a project or an ExternalProject keeps them. +set(_compat -isystem ${CMAKE_CURRENT_LIST_DIR}/macosx-legacy + -isystem ${CLANG_RETRO_MFC}/port/compat/macosx + -DWINPORT_MACOSX_COMPAT -D_DARWIN_C_SOURCE) +set(_cxx -nostdinc++ -isystem ${MACOSX_LEGACY_SYSROOT}/include/c++/v1 + -D__STDC_FORMAT_MACROS) +set(CMAKE_C_COMPILER "${MACOSX_LEGACY_LLVM}/bin/clang" + "--target=${MACOSX_LEGACY_TARGET}" ${_compat}) +set(CMAKE_CXX_COMPILER "${MACOSX_LEGACY_LLVM}/bin/clang++" + "--target=${MACOSX_LEGACY_TARGET}" ${_cxx} ${_compat}) +set(CMAKE_OBJCXX_COMPILER ${CMAKE_CXX_COMPILER}) +# The builtins of the sysroot have emulated TLS and the atomic library +# functions (__atomic_fetch_add_8 and others), which libc++ and libre need +if(MACOSX_LEGACY_ARCH STREQUAL "powerpc") + set(_rt "${MACOSX_LEGACY_SYSROOT}/lib/darwin/libclang_rt.ppc_osx.a") +else() + set(_rt "${MACOSX_LEGACY_SYSROOT}/lib/darwin/libclang_rt.osx.a") +endif() +set(_ld "-fuse-ld=${_cct}ld -nostdlib++ -L${MACOSX_LEGACY_SYSROOT}/lib -lc++ -lc++abi -lunwind ${_rt}") +# (a program exports no symbols of libc++: on i386, ld64 stops at a +# pointer difference to a global weak symbol, such as std::to_string's +# to __itoa::__pow10_32 in the libc++ of the sysroot, when another object +# also has that symbol) +set(CMAKE_EXE_LINKER_FLAGS_INIT "${_ld} -Wl,-unexported_symbol,__ZNSt3__1*") +set(CMAKE_SHARED_LINKER_FLAGS_INIT "${_ld}") +set(CMAKE_MODULE_LINKER_FLAGS_INIT "${_ld}") + +list(APPEND CMAKE_FIND_ROOT_PATH "${MACOSX_LEGACY_SDK}" "${MACOSX_LEGACY_SYSROOT}") +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) diff --git a/cmake/macosx-legacy/net/if.h b/cmake/macosx-legacy/net/if.h new file mode 100644 index 0000000..2fca827 --- /dev/null +++ b/cmake/macosx-legacy/net/if.h @@ -0,0 +1,16 @@ +/* + * net/if.h for Mac OS X 10.4 (cmake/macosx-legacy.cmake): sys/socket.h, + * then the net/if.h of the SDK. + * + * The net/if.h of the 10.4 SDK uses struct sockaddr and does not include + * sys/socket.h. POSIX lets a program include net/if.h first, and libssh + * does. + */ +#ifndef DMODEM_MACOSX_LEGACY_NET_IF_H +#define DMODEM_MACOSX_LEGACY_NET_IF_H + +#include +#include +#include_next + +#endif diff --git a/cmake/macosx-legacy/signal.h b/cmake/macosx-legacy/signal.h new file mode 100644 index 0000000..b8b20c3 --- /dev/null +++ b/cmake/macosx-legacy/signal.h @@ -0,0 +1,24 @@ +/* + * signal.h for Mac OS X 10.4 (cmake/macosx-legacy.cmake): the signal.h + * of the SDK, with SIG_DFL, SIG_IGN, SIG_HOLD and SIG_ERR as pointers to + * a function with a prototype. + * + * Without _POSIX_C_SOURCE, the 10.4 SDK gives them as pointers to a + * function with no prototype. libssh compiles with + * -Werror=strict-prototypes, which stops at these. + */ +#ifndef DMODEM_MACOSX_LEGACY_SIGNAL_H +#define DMODEM_MACOSX_LEGACY_SIGNAL_H + +#include_next + +#undef SIG_DFL +#undef SIG_IGN +#undef SIG_HOLD +#undef SIG_ERR +#define SIG_DFL ((void (*)(int))0) +#define SIG_IGN ((void (*)(int))1) +#define SIG_HOLD ((void (*)(int))5) +#define SIG_ERR ((void (*)(int))-1) + +#endif diff --git a/cmake/macosx-legacy/time.h b/cmake/macosx-legacy/time.h new file mode 100644 index 0000000..41fbb2a --- /dev/null +++ b/cmake/macosx-legacy/time.h @@ -0,0 +1,33 @@ +/* + * time.h for Mac OS X 10.4 (cmake/macosx-legacy.cmake): the time.h of + * clang-retro MFC (port/compat/macosx) and of the SDK, and the + * reentrant functions of POSIX. + * + * The time.h of the 10.4 SDK does not declare gmtime_r, localtime_r, + * asctime_r and ctime_r when _POSIX_C_SOURCE is set. These functions are + * POSIX functions, and libSystem of 10.4 has them. Mbed TLS sets + * _POSIX_C_SOURCE and calls gmtime_r. + */ +#ifndef DMODEM_MACOSX_LEGACY_TIME_H +#define DMODEM_MACOSX_LEGACY_TIME_H + +#include_next + +#if defined(_POSIX_C_SOURCE) && !defined(_ANSI_SOURCE) +#ifdef __cplusplus +extern "C" { +#endif +/* Converts a time to UTC in the given structure. */ +struct tm *gmtime_r(const time_t *, struct tm *); +/* Converts a time to local time in the given structure. */ +struct tm *localtime_r(const time_t *, struct tm *); +/* Writes a time structure as text into the given buffer. */ +char *asctime_r(const struct tm *, char *); +/* Writes a time as text into the given buffer. */ +char *ctime_r(const time_t *, char *); +#ifdef __cplusplus +} +#endif +#endif + +#endif 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 c9ed9ee..c3ef883 160000 --- a/external/D-Modem +++ b/external/D-Modem @@ -1 +1 @@ -Subproject commit c9ed9ee584b0fe04e8591895fd5e9420df2cead8 +Subproject commit c3ef8833f7adbacdd03184f4e82fe020a1b5f4c0 diff --git a/ssh/cmake/BundledLibssh.cmake b/ssh/cmake/BundledLibssh.cmake index 144991e..3f1e97d 100644 --- a/ssh/cmake/BundledLibssh.cmake +++ b/ssh/cmake/BundledLibssh.cmake @@ -28,6 +28,13 @@ endif() if(CLANG_DOS) list(APPEND _args -DCLANG_DOS=${CLANG_DOS} -DCLANG_RETRO_CONFIG=${CLANG_RETRO_CONFIG}) endif() +# (cmake/macosx-legacy.cmake) +if(MACOSX_LEGACY_TARGET) + foreach(_v MACOSX_LEGACY_ARCH MACOSX_LEGACY_LLVM MACOSX_LEGACY_SYSROOT + MACOSX_LEGACY_CCTOOLS CLANG_RETRO_MFC) + list(APPEND _args -D${_v}=${${_v}}) + endforeach() +endif() if(CMAKE_SYSTEM_NAME STREQUAL "iOS") list(APPEND _args -DCMAKE_SYSTEM_NAME=iOS) endif() diff --git a/winport/CMakeLists.txt b/winport/CMakeLists.txt index 20567a6..ea2613b 100644 --- a/winport/CMakeLists.txt +++ b/winport/CMakeLists.txt @@ -14,7 +14,10 @@ endif() find_package(Python3 REQUIRED COMPONENTS Interpreter) # (Homebrew's LLVM has llvm-rc; Xcode does not) find_program(DMODEM_LLVM_RC NAMES llvm-rc llvm-rc-20 llvm-rc-19 llvm-rc-18 - HINTS /opt/homebrew/opt/llvm/bin /usr/local/opt/llvm/bin REQUIRED) + HINTS ${MACOSX_LEGACY_LLVM}/bin /opt/homebrew/opt/llvm/bin /usr/local/opt/llvm/bin REQUIRED) +# The compiler alone, with no arguments (cmake/macosx-legacy.cmake gives +# the target as an argument of the compiler) +list(GET CMAKE_CXX_COMPILER 0 _winport_cxx) # The target triple of the layer's Makefile. On macOS, the # architecture is CMAKE_OSX_ARCHITECTURES when it is set, else the @@ -37,7 +40,10 @@ else() set(_arch_linux x86_64) set(_arch_apple x86_64) endif() -if(APPLE) +if(MACOSX_LEGACY_TARGET) + # Mac OS X 10.4 and later (cmake/macosx-legacy.cmake) + set(WINPORT_TARGET "${MACOSX_LEGACY_TARGET}") +elseif(APPLE) set(WINPORT_TARGET "${_arch_apple}-apple-macos11") else() set(WINPORT_TARGET "${_arch_linux}-linux-gnu") @@ -53,10 +59,21 @@ ProcessorCount(_ncpu) if(_ncpu EQUAL 0) set(_ncpu 1) endif() +if(MACOSX_LEGACY_TARGET) + # (the Makefile sets the flags of the 10.4 SDK and libc++ itself. + # winhelp_file.cpp uses std::abs with no : the libc++ of the + # sysroot does not give it through .) + set(_winport_make_args BIN=${MACOSX_LEGACY_LLVM}/bin + SDK=${MACOSX_LEGACY_SDK} LIBCXX=${MACOSX_LEGACY_SYSROOT} + CCTOOLS=${MACOSX_LEGACY_CCTOOLS}/bin/powerpc-apple-darwin8- + "CXXFLAGS=-O2 -include cstdlib") +else() + set(_winport_make_args STDLIB= CXX=${_winport_cxx} AR=${CMAKE_AR}) +endif() add_custom_command(OUTPUT "${WINPORT_LIB}" COMMAND make -C "${CLANG_RETRO_MFC}" -j${_ncpu} - TARGET=${WINPORT_TARGET} STDLIB= OUT=${WINPORT_OUT} - CXX=${CMAKE_CXX_COMPILER} AR=${CMAKE_AR} "${WINPORT_LIB}" + TARGET=${WINPORT_TARGET} OUT=${WINPORT_OUT} + ${_winport_make_args} "${WINPORT_LIB}" DEPENDS ${_winport_deps} COMMENT "Building libwinport.a (${WINPORT_TARGET})" VERBATIM) @@ -69,7 +86,7 @@ add_dependencies(winport winport_lib) set(_win "${PROJECT_SOURCE_DIR}/windows") set(APP_RES_CPP "${CMAKE_CURRENT_BINARY_DIR}/app-res.cpp") add_custom_command(OUTPUT "${APP_RES_CPP}" - COMMAND ${CMAKE_COMMAND} -E env RC=${DMODEM_LLVM_RC} CXX=${CMAKE_CXX_COMPILER} + COMMAND ${CMAKE_COMMAND} -E env RC=${DMODEM_LLVM_RC} CXX=${_winport_cxx} ${Python3_EXECUTABLE} "${CLANG_RETRO_MFC}/port/tools/res2cpp.py" -I "${_win}/src" -I "${_win}/res" "${_win}/res/app.rc" -o "${APP_RES_CPP}" DEPENDS "${_win}/res/app.rc" "${_win}/res/app.manifest" "${_win}/res/dmodem.ico" @@ -97,7 +114,11 @@ if(DMODEM_GUI_EMBED AND TARGET dmodem_embed) target_link_libraries(dmodem-win32 PRIVATE dmodem_embed) target_compile_definitions(dmodem-win32 PRIVATE DMODEM_GUI_EMBED) endif() -if(APPLE) +if(MACOSX_LEGACY_TARGET) + # (cmake/macosx-legacy.cmake adds port/compat/macosx, the C library + # functions that 10.4 does not have) + target_link_libraries(dmodem-win32 PRIVATE "-framework Cocoa" "-framework OpenGL" pthread) +elseif(APPLE) target_link_libraries(dmodem-win32 PRIVATE "-framework Cocoa" pthread) else() target_link_libraries(dmodem-win32 PRIVATE dl pthread)