# Copyright (c) 2026 Nicholas Bumgarner. Source-available: LICENSE.md (PolyForm Small Business 1.0.0 + additional permissions; educational use free).
# Makefile: builds calu (the Consensus ALU SystemC model) and runs its tests.
# Needs: g++ with C++17, libsystemc-dev (SystemC 3.0, includes TLM-2.0), libssl-dev (OpenSSL), node, python3.

CXX      ?= g++
# -O2 for simulation speed; warnings on so new code stays clean
CXXFLAGS ?= -std=c++17 -O2 -Wall -Wextra
# SystemC for the model, libcrypto for SHA-256 and PBKDF2
LDLIBS   = -lsystemc -lcrypto -lpthread
SRC      = src/kernel.cpp src/model.cpp src/main.cpp
HDR      = src/kernel.h src/model.h

# the simulator binary
calu: $(SRC) $(HDR)
	$(CXX) $(CXXFLAGS) -o $@ $(SRC) $(LDLIBS)

# full suite: fidelity against v1.3, equality with the fixed JS reference, and the fix properties
test: calu
	python3 -m unittest discover -s tests -v

clean:
	rm -f calu

.PHONY: test clean

# Summary: one binary, one test entry point. Plain make instead of CMake because the build is three files and two
# libraries; the tests rebuild nothing themselves, they depend on `calu` being current.
