131 lines
3.6 KiB
Bash
Executable File
131 lines
3.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright (c) 2016-2026 The Hush developers
|
|
# Distributed under the GPLv3 software license, see the accompanying
|
|
# file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
|
#
|
|
# Native macOS build script.
|
|
# Requires: Xcode Command Line Tools, cmake, autoconf, automake, libtool, pkgconfig
|
|
# Optional: Homebrew GCC (brew install gcc) for better C++ compatibility
|
|
|
|
set -eu -o pipefail
|
|
|
|
# --- Detect architecture ---
|
|
ARCH=$(uname -m) # arm64 or x86_64
|
|
|
|
# --- Detect compiler ---
|
|
# Prefer Homebrew GCC if available, otherwise use system clang
|
|
if command -v brew &>/dev/null; then
|
|
# Find newest Homebrew GCC version
|
|
GCC_PATH=$(ls -d /opt/homebrew/bin/gcc-[0-9]* /usr/local/bin/gcc-[0-9]* 2>/dev/null | sort -t- -k2 -n | tail -1 || true)
|
|
GXX_PATH=$(echo "$GCC_PATH" | sed 's/gcc-/g++-/')
|
|
fi
|
|
|
|
if [ -n "${GCC_PATH:-}" ] && [ -x "$GCC_PATH" ]; then
|
|
export CC="$GCC_PATH"
|
|
export CXX="$GXX_PATH"
|
|
echo "Using Homebrew GCC: $CC / $CXX"
|
|
EXTRA_CXXFLAGS="-fwrapv -fno-strict-aliasing -Wno-builtin-declaration-mismatch -Werror -g"
|
|
else
|
|
export CC=clang
|
|
export CXX=clang++
|
|
echo "Using system clang: $CC / $CXX"
|
|
EXTRA_CXXFLAGS="-fwrapv -fno-strict-aliasing -Werror -g"
|
|
fi
|
|
|
|
export LIBTOOL=libtool
|
|
export AR=ar
|
|
export RANLIB=ranlib
|
|
export STRIP=strip
|
|
export OTOOL=otool
|
|
export NM=nm
|
|
|
|
if [ "x$*" = 'x--help' ]
|
|
then
|
|
cat <<EOF
|
|
Usage:
|
|
|
|
$0 --help
|
|
Show this help message and exit.
|
|
|
|
$0 [ --enable-lcov ] [ MAKEARGS... ]
|
|
Build Hush and most of its transitive dependencies from
|
|
source. MAKEARGS are applied to both dependencies and Hush itself. If
|
|
--enable-lcov is passed, Hush is configured to add coverage
|
|
instrumentation, thus enabling "make cov" to work.
|
|
EOF
|
|
exit 0
|
|
fi
|
|
|
|
# If --enable-lcov is the first argument, enable lcov coverage support:
|
|
LCOV_ARG=''
|
|
HARDENING_ARG='--disable-hardening'
|
|
if [ "x${1:-}" = 'x--enable-lcov' ]
|
|
then
|
|
LCOV_ARG='--enable-lcov'
|
|
HARDENING_ARG='--disable-hardening'
|
|
shift
|
|
fi
|
|
|
|
TRIPLET=`./depends/config.guess`
|
|
PREFIX="$(pwd)/depends/$TRIPLET"
|
|
|
|
make "$@" -C ./depends/ V=1 NO_QT=1
|
|
|
|
#BUILD CCLIB
|
|
WD=$PWD
|
|
cd src/cc
|
|
echo $PWD
|
|
./makecustom
|
|
cd $WD
|
|
|
|
# Build RandomX for macOS
|
|
cd src/RandomX
|
|
if [ -f "build-darwin/librandomx.a" ]
|
|
then
|
|
ls -la build-darwin/librandomx*
|
|
else
|
|
mkdir -p build-darwin && cd build-darwin
|
|
CC="${CC} -g " CXX="${CXX} -g " cmake -DARCH=native ..
|
|
make
|
|
fi
|
|
|
|
cd $WD
|
|
|
|
./autogen.sh
|
|
CPPFLAGS="-I$PREFIX/include" LDFLAGS="-L$PREFIX/lib -Wl,-undefined -Wl,dynamic_lookup" \
|
|
CXXFLAGS="${EXTRA_CXXFLAGS} -I$PREFIX/include" \
|
|
./configure --prefix="${PREFIX}" --with-gui=no "$HARDENING_ARG" "$LCOV_ARG"
|
|
|
|
make "$@" V=1 NO_GTEST=1 STATIC=1
|
|
|
|
# Package release
|
|
echo "Creating macOS release package..."
|
|
VERSION=$(grep -oP 'define\(_CLIENT_VERSION.*?,\s*\K[0-9]+' configure.ac | head -3 | tr '\n' '.' | sed 's/\.$//')
|
|
VERSION=${VERSION:-3.10.5}
|
|
RELEASE_DIR="release/${VERSION}-mac"
|
|
mkdir -p "$RELEASE_DIR"
|
|
|
|
# Strip binaries
|
|
strip src/hushd src/hush-cli src/hush-tx 2>/dev/null || true
|
|
|
|
# Copy binaries
|
|
cp src/hushd src/hush-cli src/hush-tx "$RELEASE_DIR/"
|
|
|
|
# Copy wrapper scripts
|
|
cp contrib/scripts/hush-arrakis-chain contrib/scripts/dragonxd contrib/scripts/dragonx-cli "$RELEASE_DIR/" 2>/dev/null || true
|
|
|
|
# Copy required data files
|
|
cp asmap.dat sapling-spend.params sapling-output.params "$RELEASE_DIR/" 2>/dev/null || true
|
|
|
|
# Copy bootstrap script
|
|
cp contrib/bootstrap/bootstrap-dragonx.sh "$RELEASE_DIR/" 2>/dev/null || true
|
|
|
|
# Create ZIP
|
|
rm -f "$RELEASE_DIR/${VERSION}-mac.zip"
|
|
cd "$RELEASE_DIR"
|
|
zip -9 "${VERSION}-mac.zip" *
|
|
cd ../..
|
|
|
|
echo "Release package created: $RELEASE_DIR/${VERSION}-mac.zip"
|
|
ls -lh "$RELEASE_DIR/${VERSION}-mac.zip"
|