# Makefile for Informational Tests
# These tests are not part of the main test suite
# They are for diagnostic and informational purposes only

BUILD_DIR = ../../build
SRC_DIR = ../../src

# Compiler flags
CFLAGS = -Wall -Wextra -g -ggdb3 -std=c++14
INCLUDES = -I$(SRC_DIR) \
           -isystem../../ext/tomlc17/src \
           -isystem../../ext/raylib/src \
           -isystem../../ext/raygui/src \
           -isystem../../ext/raygui/styles

# Source files (from main project that informational tests depend on)
CORE_OBJECTS = $(BUILD_DIR)/test_utilities.o \
             $(BUILD_DIR)/physics.o \
             $(BUILD_DIR)/orbital_mechanics.o \
             $(BUILD_DIR)/simulation.o \
             $(BUILD_DIR)/config_loader.o \
             $(BUILD_DIR)/config_validator.o \
             $(BUILD_DIR)/maneuver.o \
             $(BUILD_DIR)/spacecraft.o \
             $(BUILD_DIR)/tomlc17.o

# Informational test sources
INFO_TESTS = test_time_step_stability.cpp
INFO_BINS = $(patsubst %.cpp,%,$(INFO_TESTS))

# Default target - build all informational tests
all: $(INFO_BINS)
	@echo "All informational tests built successfully"
	@echo ""
	@echo "To run tests:"
	@echo "  ./test_time_step_stability"
	@echo ""
	@echo "To run specific test case:"
	@echo "  ./test_time_step_stability '[timestep][stability]'"

# Build individual test binaries
$(INFO_BINS): $(patsubst %.cpp,%.o,$(INFO_TESTS)) $(CORE_OBJECTS)
	g++ $(patsubst %.cpp,%.o,$<) $(CORE_OBJECTS) -o $@ -lCatch2Main -lCatch2 -lm
	@echo "Built $@"

# Build test object files
test_time_step_stability.o: test_time_step_stability.cpp
	g++ $(CFLAGS) $(INCLUDES) -c $< -o $@

# Build core objects if they don't exist
$(BUILD_DIR)/%.o:
	$(MAKE) -C ../../ build/$*.o

# Clean built files in informational directory
clean:
	rm -f $(INFO_BINS) *.o

# Clean all (including core build - use with caution!)
clean-all:
	$(MAKE) -C ../../ clean
	rm -f $(INFO_BINS) *.o

# Run the time step stability test (must run from project root)
run-timestep: test_time_step_stability
	@echo "Note: Tests must be run from project root directory:"
	@echo "  From project root: ./tests/informational/$@"

# Run with verbose output to see binary search progress
run-timestep-verbose: test_time_step_stability
	@echo "Note: Tests must be run from project root directory:"
	@echo "  From project root: ./tests/informational/$@ -s \"[timestep][stability]\""

.PHONY: all clean clean-all run-timestep run-timestep-verbose
