This commit is contained in:
Imbus 2024-12-28 21:48:32 +01:00
parent 6d885040f3
commit 5a02d6537d
2 changed files with 81 additions and 8 deletions

View file

@ -1,10 +1,10 @@
# Compiler
CC := gcc
GITHASH := $(shell git rev-parse --short HEAD)
CC ?= gcc
# GITHASH := $(shell git rev-parse --short HEAD | echo "")
#
# Compiler flags
CFLAGS := -Wall -Wextra -Wpedantic -std=c2x
CFLAGS := -Wall -Wextra -Wpedantic -Wunused -std=c99 -Isrc
# Directories
SRC_DIR := src
@ -25,6 +25,14 @@ TARGET := $(BUILD_DIR)/CTree
# Default target
all: $(TARGET)
test/test.o: test/test.c
test/test.elf: test/test.o src/tree.o
$(CC) $(CFLAGS) $^ -o $@
test: test/test.elf
./test/test.elf
# Rule to build the target executable
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $^ -o $@
@ -41,18 +49,17 @@ run: $(TARGET)
fmt:
clang-format -i $(SRCS) $(HEADERS)
# Clean rule
clean:
rm -rf $(BUILD_DIR) $(TARGET)
rm -rf $(BUILD_DIR) $(TARGET) test/test.o tester docs
docs:
PROJECT_NUMBER=git-$(GITHASH) doxygen Doxyfile
cppcheck:
cppcheck --enable=all --inconclusive --std=c11 --language=c --platform=unix64 --suppress=missingIncludeSystem $(SRCS)
cppcheck --enable=all --inconclusive --std=c99 --language=c --platform=unix64 --suppress=missingIncludeSystem $(SRCS) test/test.c
valgrind: $(TARGET)
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./$(TARGET)
# Mark rules as phony
.PHONY: all run clean docs docs
.PHONY: all run clean docs docs test