Graphs/Makefile

61 lines
1.2 KiB
Makefile
Raw Normal View History

2024-05-26 12:30:10 +02:00
BIN := graphs
# Compiler
2024-05-27 06:24:26 +02:00
# CC := gcc
CC := g++
2024-05-26 12:30:10 +02:00
GITHASH := $(shell git rev-parse --short HEAD)
# Compiler flags
2024-05-27 06:24:26 +02:00
CFLAGS := -Wall -Wextra -Wpedantic -std=c++23
2024-05-26 12:30:10 +02:00
# Directories
SRC_DIR := src
BUILD_DIR := build
# Source files
2024-05-27 06:24:26 +02:00
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
2024-05-26 12:30:10 +02:00
# Header files (used for formatting)
HEADERS := $(wildcard $(SRC_DIR)/*.h)
# Object files
2024-05-27 06:24:26 +02:00
OBJS := $(patsubst $(SRC_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(SRCS))
2024-05-26 12:30:10 +02:00
# Target executable
TARGET := $(BUILD_DIR)/$(BIN)
# Default target
all: $(TARGET)
# Rule to build the target executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
# Rule to build object files
2024-05-27 06:24:26 +02:00
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
2024-05-26 12:30:10 +02:00
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# Run rule
run: $(TARGET)
./$(TARGET)
fmt:
clang-format -i $(SRCS) $(HEADERS)
# Clean rule
clean:
rm -rf $(BUILD_DIR) $(TARGET)
docs:
PROJECT_NUMBER=git-$(GITHASH) doxygen Doxyfile
cppcheck:
cppcheck --enable=all --inconclusive --std=c11 --language=c --platform=unix64 --suppress=missingIncludeSystem $(SRCS)
valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(TARGET)
# Mark rules as phony
.PHONY: all run clean docs docs