# Compiler and flags CXX = g++ CXXFLAGS = -Wall -Wextra -std=c++11 -I./src -isystem./ext/raylib/src LDFLAGS = -L./ext/raylib/src -lraylib -lm -lpthread -ldl -lrt -lX11 # Directories SRC_DIR = src BUILD_DIR = build RAYLIB_DIR = ext/raylib/src TARGET = orbit_sim # Source files SOURCES = $(SRC_DIR)/main.cpp \ $(SRC_DIR)/physics.cpp \ $(SRC_DIR)/bodies.cpp \ $(SRC_DIR)/config_loader.cpp \ $(SRC_DIR)/renderer.cpp # Object files OBJECTS = $(SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o) # Default target all: raylib $(BUILD_DIR) $(TARGET) # Build raylib raylib: @if [ ! -f $(RAYLIB_DIR)/libraylib.a ]; then \ echo "Building raylib..."; \ cd $(RAYLIB_DIR) && $(MAKE) PLATFORM=PLATFORM_DESKTOP; \ fi # Create build directory $(BUILD_DIR): mkdir -p $(BUILD_DIR) # Link the executable $(TARGET): $(OBJECTS) raylib $(CXX) $(OBJECTS) -o $(TARGET) $(LDFLAGS) # Compile source files $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ # Clean build files clean: rm -rf $(BUILD_DIR) $(TARGET) # Clean everything including raylib clean-all: clean cd $(RAYLIB_DIR) && $(MAKE) clean # Rebuild rebuild: clean all # Run the simulation run: $(TARGET) ./$(TARGET) # Run test configuration test: $(TARGET) ./$(TARGET) configs/test_simple.txt --headless --readable --days 365 .PHONY: all clean clean-all rebuild run test raylib