Files
Syphon_Filter_3/Makefile
T
Christopher Williams f0237f1549 phase5: add the tracked matching harness and ordered-layout gate
P5-T4: tools/sf3_match provides range/plan/build/gate. It compiles a C candidate
with the identified toolchain (egcs-2.91.66 psx, -O2 -G0 -mno-split-addresses),
compares the exact instruction range byte-for-byte against the original, and
builds the address-ordered executable from the tracked registry config/regions.tsv
(header 0x800 + data gaps + C regions, LMA 0x800, metadata discarded).

Promotes the Phase 4 ordered workflow from an ignored experiment to tracked
tooling. Verified: make gate with an empty registry and with one real C region
both reproduce SHA-1 e173426c...; the Phase 3 baseline is unchanged and green;
the synthetic suite is now 50 tests including deliberate-corruption failures and
safe refusal of an existing destination. No ROM-derived material is tracked.
2026-09-23 20:32:11 -04:00

89 lines
2.7 KiB
Makefile

# Phase 3 all-assembly baseline orchestration.
# All original and generated ROM-derived inputs/outputs remain ignored.
SHELL := /usr/bin/bash
EXE := extracted/SCUS_946.40;1
MANIFEST := extracted/MANIFEST.tsv
SPLAT := tools/splat/.venv/bin/splat
AS := tools/mipsel-none-elf-binutils/prefix/usr/bin/mipsel-none-elf-as
LD := tools/mipsel-none-elf-binutils/prefix/usr/bin/mipsel-none-elf-ld
OBJCOPY := tools/mipsel-none-elf-binutils/prefix/usr/bin/mipsel-none-elf-objcopy
ASM_ROOT := asm
SPLAT_CONFIG := $(ASM_ROOT)/scus_946_40.yaml
SPLAT_OUTPUT := $(ASM_ROOT)/generated
LINKER_SCRIPT := $(ASM_ROOT)/scus_946_40.ld
BUILD := build
ELF := $(BUILD)/scus_946_40.elf
REBUILT := $(BUILD)/scus_946_40.rebuilt
INPUT_REPORT := .run/p3-exe-info.tsv
# Phase 5 ordered code build: C regions listed in the tracked registry are
# compiled with the identified toolchain and linked in address order between
# data fallbacks taken from the original executable. An empty registry
# reproduces the all-payload data baseline exactly.
REGIONS := config/regions.tsv
MATCH := tools/sf3_match
CODE_OUT := build/code
EXPECTED_SHA1 := e173426c157384ebf1b6caf8c6fea18a85a14af9
.PHONY: all validate split assemble link binary code gate clean
all: binary
validate:
@test -f "$(EXE)"
@test -f "$(MANIFEST)"
@mkdir -p .run
@./tools/sf3_extract psx-exe-info "$(EXE)" "$(MANIFEST)" > "$(INPUT_REPORT)"
split: validate
@test -f "$(SPLAT)"
@test -f "$(SPLAT_CONFIG)"
@cd "$(ASM_ROOT)" && ../"$(SPLAT)" split "$$(basename "$(SPLAT_CONFIG)")" --disassemble-all
assemble: split
@test -d "$(SPLAT_OUTPUT)" && test ! -L "$(SPLAT_OUTPUT)"
@test -f "$(AS)"
@test ! -L "$(BUILD)"
@mkdir -p "$(BUILD)"
@while IFS= read -r source; do \
rel="$${source#$(ASM_ROOT)/}"; \
object="$(BUILD)/$${rel}.o"; \
mkdir -p "$$(dirname "$$object")"; \
"$(AS)" -march=r3000 -G0 -I "$(ASM_ROOT)/include" -o "$$object" "$$source"; \
done < <(find "$(SPLAT_OUTPUT)" -type f -name '*.s' -print | sort)
link: assemble
@test -f "$(LINKER_SCRIPT)"
@test -f "$(LD)"
@rm -f "$(ELF)"
@"$(LD)" -T "$(LINKER_SCRIPT)" -o "$(ELF)"
binary: link
@test -f "$(OBJCOPY)"
@rm -f "$(REBUILT)"
@"$(OBJCOPY)" -O binary "$(ELF)" "$(REBUILT)"
# Ordered code build and full-binary gate (Phase 5). `code` builds only;
# `gate` builds and then requires the whole executable to be byte-identical.
code: validate
@test -f "$(MATCH)"
@test -f "$(REGIONS)"
@rm -rf "$(CODE_OUT)"
@"$(MATCH)" build --exe "$(EXE)" --regions "$(REGIONS)" --out "$(CODE_OUT)"
gate: validate
@test -f "$(MATCH)"
@test -f "$(REGIONS)"
@rm -rf "$(CODE_OUT)"
@"$(MATCH)" gate --exe "$(EXE)" --regions "$(REGIONS)" --out "$(CODE_OUT)" \
--expect-sha1 "$(EXPECTED_SHA1)"
clean:
@if test -e "$(BUILD)"; then \
test -d "$(BUILD)" && test ! -L "$(BUILD)"; \
rm -rf "$(BUILD)"; \
fi