# Compiler and flags CXX = g++ CXXFLAGS = -std=c++17 -Wall -Wextra -I./include LDFLAGS = # Directories SRC_DIR = src BUILD_DIR = build INCLUDE_DIR = include # Target executable TARGET = $(BUILD_DIR)/main # Source files SRCS = $(wildcard $(SRC_DIR)/*.cpp) OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS)) # Default target all: $(TARGET) # Link object files to create executable $(TARGET): $(OBJS) $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) # Compile source files to object files $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR) $(CXX) $(CXXFLAGS) -c $< -o $@ # Create build directory if it doesn't exist $(BUILD_DIR): mkdir -p $(BUILD_DIR) # Clean build artifacts clean: rm -rf $(BUILD_DIR)/* # Run the program run: $(TARGET) ./$(TARGET) # Phony targets .PHONY: all clean run