# Host tests for main/pkt_dec.c, the decoder behind LispBM's pkt-dec.
#
#   nix-shell -p gcc gnumake --run 'cd tests/pkt_dec && make && ./test_pkt_dec'
#
# test_pkt_dec.c is bldc's tests/pkt_dec/main.c unchanged, since pkt_dec.c is
# byte-identical between the two firmwares. main/packet.c and main/crc.c are
# compiled straight from the firmware source.

CFLAGS += -O1 -g -std=gnu99 -Wall -Wextra
SAN ?= -fsanitize=address,undefined -fno-omit-frame-pointer

MAIN = ../../main

INCLUDES = -I$(MAIN)

SRCS = test_pkt_dec.c $(MAIN)/pkt_dec.c $(MAIN)/packet.c $(MAIN)/crc.c

HDRS = $(MAIN)/pkt_dec.h $(MAIN)/packet.h $(MAIN)/crc.h

all: test_pkt_dec

test_pkt_dec: $(SRCS) $(HDRS)
	$(CC) $(CFLAGS) $(SAN) $(INCLUDES) -o $@ $(SRCS)

run: test_pkt_dec
	./test_pkt_dec

clean:
	rm -f test_pkt_dec

.PHONY: all run clean
