# SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (C) 2026 David (Corey) Herrera # Makefile — SR4 ternary optimizer reference library. # # Uses the same stable "hard-rule" flags as the SR4 research prototype so the # integer numerics are bit-identical to it: pure-integer stochastic rounding # is immune to -O level and -ffast-math, and these flags keep it that way. # # make build the static lib (libternary_optim.a) + the example # make lib build only the static library # make example build only the demo # make run build and run the demo # make clean remove all build artifacts CC ?= cc CFLAGS := -std=c11 -O3 -march=native -fno-fast-math -ffp-contract=off -Wall -Wextra AR := ar ARFLAGS := rcs LIB := libternary_optim.a OBJ := ternary_optim.o EXAMPLE := example .PHONY: all lib run clean all: lib $(EXAMPLE) lib: $(LIB) $(LIB): $(OBJ) $(AR) $(ARFLAGS) $@ $^ ternary_optim.o: ternary_optim.c ternary_optim.h $(CC) $(CFLAGS) -c ternary_optim.c -o $@ $(EXAMPLE): example.c $(LIB) $(CC) $(CFLAGS) example.c $(LIB) -lm -o $@ run: $(EXAMPLE) ./$(EXAMPLE) clean: rm -f $(OBJ) $(LIB) $(EXAMPLE)