# Host tests for the PPM app, applications/app_ppm.c, with the input decoder
# under it (driver/servo_dec.c). The real files are compiled against the stub
# headers here and run on a simulated wire; see main.c.
#
# app_ppm_stock.c and servo_dec_stock.c are the two files as they were before
# CPPM. With a single pulse the current files -- and the same built with
# HW_NO_PKG_PPM -- must make every motor and CAN command they do, 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../../driver -I../../motor
SAN = -fsanitize=address,undefined -fno-sanitize-recover=all
LIBS = -lm -lpthread

FIRMWARE = ../../util/utils_math.c
WRAPS = wrap_new.c wrap_new_dec.c wrap_trim.c wrap_trim_dec.c wrap_stock.c wrap_stock_dec.c
SOURCES = main.c $(WRAPS) $(FIRMWARE)
DEPS = $(SOURCES) ../../applications/app_ppm.c ../../driver/servo_dec.c \
       app_ppm_stock.c servo_dec_stock.c $(wildcard *.h) \
       ../../driver/servo_dec.h \
       ../../datatypes.h

.PHONY: all run clean

all: $(TARGET)

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

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

clean:
	rm -f $(TARGET)
