2024-03-27 05:08:39 +01:00
|
|
|
# Compiler
|
|
|
|
CC := gcc
|
|
|
|
|
|
|
|
# Compiler flags
|
2024-03-27 10:02:32 +01:00
|
|
|
CFLAGS := -Wall -Wextra -Wpedantic -std=c2x
|
2024-03-27 05:08:39 +01:00
|
|
|
|
|
|
|
# Directories
|
|
|
|
SRC_DIR := src
|
|
|
|
BUILD_DIR := build
|
|
|
|
|
|
|
|
# Source files
|
|
|
|
SRCS := $(wildcard $(SRC_DIR)/*.c)
|
|
|
|
|
2024-03-27 06:39:47 +01:00
|
|
|
# Header files (used for formatting)
|
|
|
|
HEADERS := $(wildcard $(SRC_DIR)/*.h)
|
|
|
|
|
2024-03-27 05:08:39 +01:00
|
|
|
# Object files
|
|
|
|
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
|
|
|
|
|
|
|
|
# Target executable
|
2024-03-27 06:34:08 +01:00
|
|
|
TARGET := $(BUILD_DIR)/CTree
|
2024-03-27 05:08:39 +01:00
|
|
|
|
|
|
|
# Default target
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
# Rule to build the target executable
|
|
|
|
$(TARGET): $(OBJS)
|
|
|
|
$(CC) $(CFLAGS) $^ -o $@
|
|
|
|
|
|
|
|
# Rule to build object files
|
|
|
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
|
|
|
@mkdir -p $(BUILD_DIR)
|
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
|
|
|
|
# Run rule
|
|
|
|
run: $(TARGET)
|
|
|
|
./$(TARGET)
|
|
|
|
|
2024-03-27 06:39:47 +01:00
|
|
|
fmt:
|
|
|
|
clang-format -i $(SRCS) $(HEADERS)
|
|
|
|
|
2024-03-27 05:08:39 +01:00
|
|
|
# Clean rule
|
|
|
|
clean:
|
|
|
|
rm -rf $(BUILD_DIR) $(TARGET)
|
|
|
|
|
2024-04-24 01:34:33 +02:00
|
|
|
docs:
|
|
|
|
doxygen Doxyfile
|
|
|
|
|
2024-05-02 02:16:24 +02:00
|
|
|
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)
|
|
|
|
|
2024-03-27 05:08:39 +01:00
|
|
|
# Mark rules as phony
|
2024-04-24 12:43:01 +02:00
|
|
|
.PHONY: all run clean docs docs
|