TARGET = test
CC = gcc
CFLAGS = -O2 -g -Wall -Wextra -Wundef -std=gnu99 -I. -I../../comm -I../.. -DNO_STM32 \
	-fsanitize=address,undefined -fno-omit-frame-pointer

$(TARGET): main.c ../../comm/can_reply.h ../../datatypes.h
	$(CC) $(CFLAGS) main.c -o $@

# The simulation models decode_msg and commands_process_packet around the
# two decisions in can_reply.h; that is only worth something while the
# firmware makes them there.
run: $(TARGET)
	@grep -q 'can_reply_relays(' ../../comm/commands.c || { echo "FAIL commands.c no longer calls can_reply_relays"; exit 1; }
	@grep -q 'can_reply_takes_fwd(' ../../comm/commands.c || { echo "FAIL commands.c no longer calls can_reply_takes_fwd"; exit 1; }
	./$(TARGET)

clean:
	rm -f $(TARGET)

.PHONY: run clean
