# CONFIDENTIAL - TRADE SECRET - Property of Joseph M. Castillo - All rights reserved
#
# Purcius Genesis — self-contained. Builds genesis-cli from the Core + the vendored Purcius
# crypto substrate in ./substrate (ed25519 + shamir + drbg/entropy). No external tree, no
# clone of anything else. Same source runs under Termux on your phone in airplane mode.

CC       = gcc
CFLAGS   = -std=c11 -O2 -Wall -Wextra -D_POSIX_C_SOURCE=200809L
LDLIBS   = -lm

ifeq ($(OS),Windows_NT)
  LDFLAGS = -ladvapi32
  EXE     = .exe
else
  LDFLAGS =
  EXE     =
endif

INCLUDES  = -Icore -Isubstrate
SUBSTRATE = substrate/crypt.c substrate/drbg.c substrate/entropy.c substrate/shamir_gf256.c
SRC       = cli/genesis_cli.c core/genesis_core.c $(SUBSTRATE)
BIN       = genesis-cli$(EXE)

.PHONY: all test clean

all: $(BIN)

$(BIN): $(SRC) core/genesis_core.h
	$(CC) $(CFLAGS) $(INCLUDES) $(SRC) $(LDFLAGS) $(LDLIBS) -o $@

# Prove the ceremony end-to-end (mint -> split -> recover -> verify anchor).
test: $(BIN)
	./$(BIN) selftest

clean:
	rm -f $(BIN)
