Files
dark-lord/scripts/mkp224o-build.sh
2026-04-26 22:28:40 -07:00

60 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build cathugger/mkp224o (Tor v3 vanity .onion key generator) into vendor/mkp224o/mkp224o.
# Requires: git, make, gcc or clang, autoconf, pkg-config, libsodium-dev (Debian: libsodium-dev)
#
# bash scripts/mkp224o-build.sh
#
set -euo pipefail
REPO="$(cd "$(dirname "$0")/.." && pwd)"
VEND="${REPO}/vendor/mkp224o"
BIN="${VEND}/mkp224o"
if [[ -x "${BIN}" ]]; then
echo "Already built: ${BIN}"
exit 0
fi
if ! command -v git >/dev/null 2>&1; then
echo "Install git and retry."
exit 1
fi
mkdir -p "${REPO}/vendor"
if [[ ! -d "${VEND}/.git" ]]; then
echo "[*] Cloning mkp224o..."
git clone --depth 1 https://github.com/cathugger/mkp224o.git "${VEND}"
fi
cd "${VEND}"
if [[ ! -f "./configure" ]]; then
if [[ -f "./autogen.sh" ]]; then
echo "[*] autogen.sh..."
./autogen.sh
else
echo "No configure/autogen in ${VEND}"
exit 1
fi
fi
if [[ ! -f "./Makefile" ]]; then
echo "[*] configure..."
# Prefer AMD64 fast curve implementation when available
if ./configure --help 2>/dev/null | grep -q 'enable-amd64-64-24k'; then
./configure --enable-amd64-64-24k
else
./configure
fi
fi
echo "[*] make -j \$(nproc)..."
make -j"$(nproc)"
if [[ ! -x "${BIN}" ]]; then
echo "Build failed: ${BIN} not executable"
exit 1
fi
echo "Built: ${BIN}"
echo "Mine a prefix: bash ${REPO}/scripts/vanity-onion-mine.sh <prefix>"