65816-llvm-mos/setup.sh
2026-05-30 19:40:29 -05:00

107 lines
3.1 KiB
Bash
Executable file

#!/usr/bin/env bash
# Top-level installer for the llvm816 project. Installs everything into
# ./tools/ so the tree is self-contained and deletable.
#
# Stages (6/6):
# 1. apt dependencies
# 2. llvm-mos clone + W65816 backend apply + cmake/ninja build of
# clang/llc/llvm-mc + build link816/omfEmit + build runtime (.o)
# 3. MAME + apple2gs ROMs
# 4. Calypsi 5.16 (reference compiler — optional)
# 5. ORCA/C source (header reference — optional)
# 6. GNO/ME 2.0.6 + GS/OS 6.0.4 (shell-command runtime — optional;
# cadius + .shk archives + system disks for runInGno.sh)
#
# Usage:
# ./setup.sh # install + build everything (~30-60 min)
# ./setup.sh --skip-deps # skip apt packages
# ./setup.sh --skip-llvm # skip stage 2 (clang/runtime/link816)
# ./setup.sh --skip-mame # skip MAME + ROM fetch
# ./setup.sh --skip-calypsi # skip Calypsi
# ./setup.sh --skip-orca # skip ORCA/C reference
# ./setup.sh --skip-gno # skip GNO/ME + GS/OS 6.0.4 fetch
# ./setup.sh --skip-verify # skip the post-install verification
# ./setup.sh --verify-only # run verification only
# ./setup.sh --build-llvm # deprecated alias for the default behavior
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/scripts/common.sh"
doDeps=1
doLlvm=1
doMame=1
doCalypsi=1
doOrca=1
doGno=1
doVerify=1
buildLlvm=0
verifyOnly=0
for arg in "$@"; do
case "$arg" in
--skip-deps) doDeps=0 ;;
--skip-llvm) doLlvm=0 ;;
--skip-mame) doMame=0 ;;
--skip-calypsi) doCalypsi=0 ;;
--skip-orca) doOrca=0 ;;
--skip-gno) doGno=0 ;;
--skip-verify) doVerify=0 ;;
--build-llvm) buildLlvm=1 ;;
--verify-only) verifyOnly=1 ;;
-h|--help)
sed -n '2,25p' "$0"
exit 0
;;
*) die "unknown flag: $arg" ;;
esac
done
if [ "$verifyOnly" -eq 1 ]; then
exec "$SCRIPT_DIR/scripts/verify.sh"
fi
log "project root: $PROJECT_ROOT"
log "tools dir: $TOOLS_DIR"
if [ "$doDeps" -eq 1 ]; then
log "=== 1/6 system dependencies ==="
bash "$SCRIPT_DIR/scripts/installDeps.sh"
fi
if [ "$doLlvm" -eq 1 ]; then
log "=== 2/6 llvm-mos ==="
if [ "$buildLlvm" -eq 1 ]; then
bash "$SCRIPT_DIR/scripts/installLlvmMos.sh" --build
else
bash "$SCRIPT_DIR/scripts/installLlvmMos.sh"
fi
fi
if [ "$doMame" -eq 1 ]; then
log "=== 3/6 mame + iigs roms ==="
bash "$SCRIPT_DIR/scripts/installMame.sh"
fi
if [ "$doCalypsi" -eq 1 ]; then
log "=== 4/6 calypsi ==="
bash "$SCRIPT_DIR/scripts/installCalypsi.sh"
fi
if [ "$doOrca" -eq 1 ]; then
log "=== 5/6 orca-c reference ==="
bash "$SCRIPT_DIR/scripts/installOrcaC.sh"
fi
if [ "$doGno" -eq 1 ]; then
log "=== 6/6 gno/me + gs/os 6.0.4 ==="
bash "$SCRIPT_DIR/scripts/installGno.sh"
fi
if [ "$doVerify" -eq 1 ]; then
log "=== verify ==="
bash "$SCRIPT_DIR/scripts/verify.sh" || warn "verification reported failures; see above"
fi
log "setup complete"