CXX = g++
CXXFLAGS = -std=c++17 -Wall -Wextra
TARGET = ana_parser

SRCS = main.cpp ANADecoder.cpp BMPWriterStrategy.cpp
OBJS = $(SRCS:.cpp=.o)

file ?= sample.ana

.PHONY: all clean rebuild_target test run help build

all: clean rebuild_target

build: clean rebuild_target

rebuild_target: $(OBJS)
	$(CXX) $(OBJS) -o $(TARGET)

test:
	python3 ANABuilder.py

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

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

clean:
	rm -f $(OBJS) $(TARGET)

help:
	@echo "Usage:"
	@echo "  make              - Compile all C++ files"
	@echo "  make test         - Generate test ANA file using Python builder"
	@echo "  make run          - Run with sample.ana (default)"
	@echo "  make run file=<filename>"
	@echo "  make clean        - Remove all object files and the executable"
