# The control loop's fixed-cutoff filters; the cutoffs are read from the
# sources, so this follows them (and fails to build without them).
TARGET = test
CC = gcc
CFLAGS = -O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Wundef \
         -std=gnu99 -I. -I../../util

.PHONY: default all clean run

default: $(TARGET)
all: default

cutoffs.h: ../../motor/foc_math.c ../../motor/mc_interface.c
	grep -h -E '^#define [A-Z_]+_CUTOFF_HZ' $^ > $@

$(TARGET): main.c cutoffs.h ../../util/ema.h
	$(CC) $(CFLAGS) main.c -fsanitize=address,undefined -lm -o $@

clean:
	rm -f $(TARGET) cutoffs.h

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