# Host tests for the ADC app, applications/app_adc.c, and its gesture cruise
# control, applications/adc_cruise.c. The real files are compiled against the
# stub headers here and the app's thread is run sample by sample; see main.c.
#
# app_adc_stock.c is app_adc.c as it was before gesture cruise control. With
# the setting off, both are run on the same inputs and every motor and CAN
# command they make must match exactly.

TARGET = test
CC = gcc
CFLAGS = -O1 -g -Wall -Wextra -Wundef -Wno-unused-function -Wno-unused-parameter \
         -std=gnu99 -DNO_STM32 -DHW_SOURCE=\"hw.h\" -DHW_HEADER=\"hw.h\" \
         -I. -I../.. -I../../util -I../../applications -I../../motor
SAN = -fsanitize=address,undefined -fno-sanitize-recover=all
LIBS = -lm

FIRMWARE = ../../util/buffer.c ../../applications/adc_cruise.c ../../applications/throttle_guard.c ../../util/utils_math.c
SOURCES = main.c wrap_new.c wrap_stock.c wrap_left_out.c $(FIRMWARE)
DEPS = $(SOURCES) ../../applications/app_adc.c app_adc_stock.c $(wildcard *.h) \
       ../../applications/adc_cruise.h ../../datatypes.h

.PHONY: all run clean

all: $(TARGET)

$(TARGET): $(DEPS)
	$(CC) $(CFLAGS) $(SAN) $(SOURCES) $(LIBS) -o $@

run: $(TARGET)
	./$(TARGET)

clean:
	rm -f $(TARGET)
