Add macOS release build target

Add `./build.sh --macos-release`, producing a portable host-arch macOS
binary (Intel x86_64 or Apple Silicon arm64). libuv, hwloc, and OpenSSL
are linked statically from Homebrew so the result runs on stock macOS
without Homebrew at runtime.

Homebrew's static libhwloc.a is built with the libxml2 and OpenCL
topology plugins, so the link adds `-lxml2 -framework OpenCL` (both
ship with macOS). Brew prefixes are resolved via `brew --prefix`, so
the same target works on Intel (/usr/local) and Apple Silicon
(/opt/homebrew); the package is named by `uname -m`.

Also document the macOS build in README and ignore build-macos/.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-07 09:05:55 -05:00
parent ee9144ab13
commit de11995a53
3 changed files with 81 additions and 5 deletions

1
.gitignore vendored
View File

@@ -39,5 +39,6 @@ Thumbs.db
*~
release/
build-linux/
build-macos/
build-windows/
deps-windows/

View File

@@ -35,8 +35,12 @@ Based on XMRig v6.25.
```
./build.sh --linux-release # Linux x86_64 static release
./build.sh --win-release # Windows x86_64 (MinGW cross-compile)
./build.sh --macos-release # macOS release for the host arch (Intel or Apple Silicon)
```
Dependencies are built by `scripts/build_deps.sh` on first run.
Linux/Windows dependencies are built by `scripts/build_deps.sh` on first run.
The macOS build uses Homebrew dependencies — install them once with
`brew install libuv hwloc openssl@3`. libuv/hwloc/OpenSSL are linked statically,
so the resulting binary runs on stock macOS without Homebrew.
## Usage
```

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# DRG-XMRig (DragonX miner) Release Build Script
# Usage: ./build.sh [--linux-release] [--win-release]
# Usage: ./build.sh [--linux-release] [--win-release] [--macos-release]
set -e
@@ -10,24 +10,27 @@ VERSION=$(grep '#define APP_VERSION' "$ROOT_DIR/src/version.h" | sed 's/.*"\(.*\
BUILD_LINUX=false
BUILD_WIN=false
BUILD_MACOS=false
for arg in "$@"; do
case "$arg" in
--linux-release) BUILD_LINUX=true ;;
--win-release) BUILD_WIN=true ;;
--macos-release) BUILD_MACOS=true ;;
*)
echo "Usage: $0 [--linux-release] [--win-release]"
echo "Usage: $0 [--linux-release] [--win-release] [--macos-release]"
exit 1
;;
esac
done
if ! $BUILD_LINUX && ! $BUILD_WIN; then
echo "Usage: $0 [--linux-release] [--win-release]"
if ! $BUILD_LINUX && ! $BUILD_WIN && ! $BUILD_MACOS; then
echo "Usage: $0 [--linux-release] [--win-release] [--macos-release]"
echo ""
echo "Flags:"
echo " --linux-release Build Linux x86_64 release"
echo " --win-release Build Windows x86_64 release (cross-compile with MinGW)"
echo " --macos-release Build macOS release for the host architecture (uses Homebrew deps)"
exit 1
fi
@@ -113,9 +116,77 @@ build_windows() {
echo "Windows release: release/${PKG_NAME}.zip"
}
build_macos() {
echo ""
echo "========================================="
echo " Building macOS Release"
echo "========================================="
if ! command -v brew >/dev/null 2>&1; then
echo "ERROR: Homebrew is required. Install from https://brew.sh and run:"
echo " brew install libuv hwloc openssl@3"
exit 1
fi
# Resolve Homebrew dependency prefixes (works on Intel /usr/local and Apple Silicon /opt/homebrew)
local OPENSSL_PREFIX UV_PREFIX HWLOC_PREFIX
OPENSSL_PREFIX=$(brew --prefix openssl@3 2>/dev/null) || true
UV_PREFIX=$(brew --prefix libuv 2>/dev/null) || true
HWLOC_PREFIX=$(brew --prefix hwloc 2>/dev/null) || true
if [ ! -f "$OPENSSL_PREFIX/lib/libssl.a" ] || [ ! -f "$UV_PREFIX/lib/libuv.a" ] || [ ! -f "$HWLOC_PREFIX/lib/libhwloc.a" ]; then
echo "ERROR: missing static dependencies. Install them with:"
echo " brew install libuv hwloc openssl@3"
exit 1
fi
local BUILD_DIR="$ROOT_DIR/build-macos"
local ARCH; ARCH=$(uname -m) # x86_64 or arm64
local JOBS; JOBS=$(sysctl -n hw.ncpu)
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Statically link libuv/hwloc/openssl so the binary is portable (no Homebrew needed at runtime).
# Homebrew's static libhwloc.a pulls in libxml2 and the OpenCL framework, both shipped with macOS.
cmake "$ROOT_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_OPENCL=OFF \
-DWITH_CUDA=OFF \
-DWITH_HWLOC=ON \
-DWITH_TLS=ON \
-DXMRIG_DEPS="$OPENSSL_PREFIX" \
-DUV_LIBRARY="$UV_PREFIX/lib/libuv.a" \
-DUV_INCLUDE_DIR="$UV_PREFIX/include" \
-DHWLOC_LIBRARY="$HWLOC_PREFIX/lib/libhwloc.a" \
-DHWLOC_INCLUDE_DIR="$HWLOC_PREFIX/include" \
-DCMAKE_EXE_LINKER_FLAGS="-lxml2 -framework OpenCL"
make -j"$JOBS"
# Package
local PKG_NAME="drg-xmrig-${VERSION}-macos-${ARCH}"
local PKG_DIR="$RELEASE_DIR/$PKG_NAME"
rm -rf "$PKG_DIR"
mkdir -p "$PKG_DIR"
cp "$BUILD_DIR/xmrig" "$PKG_DIR/"
cp "$ROOT_DIR/src/config.example.json" "$PKG_DIR/config.json"
cp "$ROOT_DIR/README.md" "$PKG_DIR/"
cd "$RELEASE_DIR"
rm -f "${PKG_NAME}.zip"
zip -r "${PKG_NAME}.zip" "$PKG_NAME"
rm -rf "$PKG_DIR"
echo ""
echo "macOS release: release/${PKG_NAME}.zip"
}
# Run selected builds
$BUILD_LINUX && build_linux
$BUILD_WIN && build_windows
$BUILD_MACOS && build_macos
echo ""
echo "========================================="