opengl-cpp/Makefile

39 lines
706 B
Makefile
Raw Permalink Normal View History

2025-01-12 15:53:46 +00:00
# Compiler and flags
CXX := g++
CXXFLAGS := -g #-O0 -Wall -Wextra
2025-01-11 17:48:48 +00:00
2025-01-12 15:53:46 +00:00
# Libraries
LDFLAGS := -lSDL2 -lGLEW -lGL
2025-01-11 17:48:48 +00:00
2025-01-12 15:53:46 +00:00
# Source and output directories
SRC_DIR := src
BUILD_DIR := build
TARGET := $(BUILD_DIR)/opengl
2025-01-12 15:53:46 +00:00
# Source files and object files
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJ := $(SRC:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
2025-01-12 15:53:46 +00:00
# Default target
all: $(TARGET)
2025-01-11 17:48:48 +00:00
2025-01-12 15:53:46 +00:00
# Build the target executable
$(TARGET): $(OBJ)
mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
2025-01-11 17:48:48 +00:00
2025-01-12 15:53:46 +00:00
# Build object files
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) -c $< -o $@
2025-01-12 15:53:46 +00:00
# Clean up build files
2025-01-11 17:48:48 +00:00
clean:
2025-01-12 15:53:46 +00:00
rm -rf $(BUILD_DIR)
# Run the application
run: $(TARGET)
./$(TARGET)
2025-01-11 17:48:48 +00:00
2025-01-12 15:53:46 +00:00
.PHONY: all clean run