# Host build of the engine and the vector checker. No SDK.
#   make test        build and check against ../../test/vectors
#   make sanitize    same, with ASan + UBSan
CC      ?= cc
CFLAGS  ?= -std=c99 -O2 -Wall -Wextra -Wpedantic -Wshadow -Wconversion -Wno-sign-conversion -Werror
SRC      = check_vectors.c json.c ../engine/engine.c
HDR      = json.h ../engine/engine.h
VECTORS  = ../../test/vectors

check_vectors: $(SRC) $(HDR)
	$(CC) $(CFLAGS) -o $@ $(SRC)

check_vectors_san: $(SRC) $(HDR)
	$(CC) $(CFLAGS) -O1 -g -fsanitize=address,undefined -fno-sanitize-recover=all -o $@ $(SRC)

test: check_vectors
	./check_vectors $(VECTORS)

sanitize: check_vectors_san
	./check_vectors_san $(VECTORS)

clean:
	rm -f check_vectors check_vectors_san

.PHONY: test sanitize clean
