.SUFFIXES:

# Configuration
MIN := -0.1
MAX := 0.1
INC := 0.002
TEMPLATE := template.xta
PREFIX := template_A_

# Generate numerical values with proper decimal format
VALUES := $(shell LC_NUMERIC=C seq $(MIN) $(INC) $(MAX))

# File targets
XTA_TARGETS := $(addprefix $(PREFIX), $(addsuffix .xta, $(VALUES)))
RES_TARGETS := $(addprefix $(PREFIX), $(addsuffix .res, $(VALUES)))

.PHONY: all clean

all: $(XTA_TARGETS) $(RES_TARGETS) result.csv plot.pdf

# Pattern rule for XTA generation
$(PREFIX)%.xta: $(TEMPLATE)
	@echo "Generating $@ with amplitude $*"
	@sed "s/%ATTACK_AMPLITUDE%/$*/g" $< > $@

# Pattern rule for RES result generation
$(PREFIX)%.res: $(PREFIX)%.xta pr.q
	/opt/uppaal/lib/app/bin/verifyta $< pr.q > $@

result.csv: $(RES_TARGETS)
	python3 res_parser.py $^ > $@

plot.pdf: result.csv
	python3 plot.py $^

clean:
	@echo "Cleaning generated files"
	@rm -f $(XTA_TARGETS) $(RES_TARGETS) result.csv plot.pdf
