Initial commit

This commit is contained in:
Chris Gregory
2025-11-25 08:17:08 -05:00
commit c654af4c92
10 changed files with 567 additions and 0 deletions

47
Makefile Normal file
View File

@@ -0,0 +1,47 @@
debug ?= 0
NAME := yab-ssg
SRC_DIR := src
BUILD_DIR := build
INCLUDE_DIR := include
LIB_DIR := lib
BIN_DIR := bin
TESTS_DIR := tests
OBJS := $(patsubst %.c,%.o, $(wildcard $(SRC_DIR)/*.c) $(wildcard $(LIB_DIR)/**/*.c))
CC := clang
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -fsanitize=address
ifeq ($(debug), 1)
CFLAGS := $(CFLAGS) -g -O0
else
CFLAGS := $(CFLAGS) -Oz
endif
$(NAME): dir $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $(BIN_DIR)/$@ $(patsubst %, build/%, $(OBJS))
$(OBJS): dir
@mkdir -p $(BUILD_DIR)/$(@D)
@$(CC) $(CFLAGS) -o $(BUILD_DIR)/$@ -c $*.c
# Runs CUnit tests
test: dir
@$(CC) $(CFLAGS) -lcunit -o $(BIN_DIR)/$(NAME)_test $(TESTS_DIR)/*.c
@$(BIN_DIR)/$(NAME)_test
# Run valgrind memory checker on executable
check: $(NAME)
@sudo valgrind -s --leak-check=full --show-leak-kinds=all $(BIN_DIR)/$< --help
@sudo valgrind -s --leak-check=full --show-leak-kinds=all $(BIN_DIR)/$< --version
@sudo valgrind -s --leak-check=full --show-leak-kinds=all $(BIN_DIR)/$< -v
# Setup build and bin directories
dir:
@mkdir -p $(BUILD_DIR) $(BIN_DIR)
# Clean build and bin directories
clean:
@rm -rf $(BUILD_DIR) $(BIN_DIR)
.PHONY: check dir clean