# Vericull v4.0.0 Open-Source SDK Makefile (C11/C++17 + Pure-Stdlib Python)
# SPDX-License-Identifier: MIT OR Apache-2.0
PYTHON ?= python3
PYTHON_ISO ?= python3 -I

.PHONY: all native corpus train test clean

all: native

native:
	$(MAKE) -C native all smoke

corpus: native
	$(PYTHON_ISO) tools/build_corpus.py

train: corpus
	$(PYTHON_ISO) tools/train_vericull_gbdt.py

test: native
	$(PYTHON_ISO) public/verify/vericull_verify.py public/data/forensic-dossiers.json --key 418f3ba915d9efa93729d6db323f307b65ffdf476c7228247320542a2b17e03e --bundle-hash 95794f66e1f469b48a4d5b981581f77369c9f58835c29e344743ab9bdf4b7b71
	$(PYTHON_ISO) public/releases/vericull_cli.py verify public/data/forensic-dossiers.json --key 418f3ba915d9efa93729d6db323f307b65ffdf476c7228247320542a2b17e03e --bundle-hash 95794f66e1f469b48a4d5b981581f77369c9f58835c29e344743ab9bdf4b7b71
	$(PYTHON) -m vericull verify public/data/forensic-dossiers.json --key 418f3ba915d9efa93729d6db323f307b65ffdf476c7228247320542a2b17e03e --bundle-hash 95794f66e1f469b48a4d5b981581f77369c9f58835c29e344743ab9bdf4b7b71
	$(PYTHON_ISO) public/releases/vericull_cli.py audit --preset default >/dev/null
	$(PYTHON_ISO) public/releases/vericull_cli.py arena --preset default >/dev/null
	$(PYTHON_ISO) public/releases/vericull_cli.py rtl-prove --preset RTL-01 >/dev/null
	$(PYTHON_ISO) public/releases/vericull_cli.py route-budget --preset default >/dev/null
	$(PYTHON_ISO) public/releases/vericull_cli.py memory-promote --preset default >/dev/null
	$(PYTHON_ISO) -c "import hashlib, sys; lines=[l.strip().split('  ',1) for l in open('SHA256SUMS.txt') if l.strip()]; bad=[n for h,n in lines if hashlib.sha256(open(n,'rb').read()).hexdigest()!=h]; sys.exit('FAIL  SHA256SUMS mismatch: ' + repr(bad)) if bad else print('OK    SHA256SUMS verified:', len(lines), 'files')"

clean:
	$(MAKE) -C native clean
