Initial
This commit is contained in:
commit
2b329b4031
3 changed files with 169 additions and 0 deletions
59
Makefile
Normal file
59
Makefile
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
BIN := graphs
|
||||
# Compiler
|
||||
CC := gcc
|
||||
|
||||
GITHASH := $(shell git rev-parse --short HEAD)
|
||||
|
||||
# Compiler flags
|
||||
CFLAGS := -Wall -Wextra -Wpedantic -std=c2x
|
||||
|
||||
# Directories
|
||||
SRC_DIR := src
|
||||
BUILD_DIR := build
|
||||
|
||||
# Source files
|
||||
SRCS := $(wildcard $(SRC_DIR)/*.c)
|
||||
|
||||
# Header files (used for formatting)
|
||||
HEADERS := $(wildcard $(SRC_DIR)/*.h)
|
||||
|
||||
# Object files
|
||||
OBJS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
|
||||
|
||||
# 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
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@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
|
||||
Loading…
Add table
Add a link
Reference in a new issue