-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (52 loc) · 1.97 KB
/
Copy pathMakefile
File metadata and controls
63 lines (52 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ************************************************************************** #
# Copyright © 2024 <hi@allali.me> __ __ #
# /\ \/\ \ #
# File : Makefile \_\ \ \ \____ #
# Project : DB.c /'_` \ \ '__`\ #
# License : Apache 2.0 with Commons Clause. /\ \L\ \ \ \L\ \ #
# \ \___,_\ \_,__/ #
# Created : 2024/12/13 13:37:42 by aallali \/__,_ /\/___/.c #
# Updated : 2026/01/20 01:06:44 by aallali #
# ************************************************************************** #
# Compiler and flags
CC = gcc
CFLAGS = -Wall -Wextra -Werror -g -Iincludes
VALGRING_FLAGS = --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
-s
TFLAGS = -DUNIT_TEST
# Files and target
SRCS = $(filter-out src/main.c, $(wildcard src/*.c))
OBJS = $(SRCS:.c=.o)
MAIN = src/main.c
TEST_SRCS = $(wildcard tests/test_*.c)
TARGET = db.bin
TARGET_TEST = ./build/test.bin
# Build target
all: $(TARGET)
$(TARGET): $(OBJS) $(MAIN:.c=.o)
$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(MAIN:.c=.o)
@rm -f $(OBJS) src/main.o
run: $(TARGET)
./$(TARGET) $(ARGS)
run-unsafe:
$(MAKE) CFLAGS="-g -Iincludes" all
./$(TARGET) $(ARGS)
format:
clang-format -i $$(find src includes tests -name '*.c' -o -name '*.h') --style=file
test: $(OBJS)
@mkdir -p build
$(CC) $(CFLAGS) $(TEST_SRCS) $(OBJS) -o $(TARGET_TEST) $(TFLAGS)
@rm src/*.o
valgrind $(VALGRING_FLAGS) $(TARGET_TEST) --unittest
test-single: $(OBJS)
@mkdir -p build
@$(CC) $(CFLAGS) tests/test_main.c $(FILE) $(OBJS) -o $(TARGET_TEST) $(TFLAGS)
@rm src/*.o
valgrind $(VALGRING_FLAGS) $(TARGET_TEST) --unittest
leak: $(TARGET)
valgrind $(VALGRING_FLAGS) ./$(TARGET) $(ARGS)
clean:
rm -f $(OBJS) $(TARGET) src/main.o
rm -rf build