-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (38 loc) · 936 Bytes
/
Copy pathMakefile
File metadata and controls
52 lines (38 loc) · 936 Bytes
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
BUILD ?= debug
CC := gcc
CSTD := -std=c99 -c
WARN := -Wall -Wextra -Wpedantic \
-Wshadow -Wconversion -Wsign-conversion \
-Wstrict-prototypes -Wmissing-prototypes \
-Wformat=2 -Wundef
BASE := $(CSTD) $(WARN) -fno-common -D_POSIX_C_SOURCE=200809L
ifeq ($(BUILD), debug)
CFLAGS_DEBUG := $(BASE) \
-ggdb \
-O0 -g3 \
-fsanitize=address,undefined \
-fno-omit-frame-pointer \
-DDEBUG
CLFAGS := $(CFLAGS_DEBUG)
else
CFLAGS_RELEASE := $(BASE) \
-O3 -DNDEBUG \
-flto \
-fvisibility=hidden
CFLAGS := $(CFLAGS_RELEASE)
endif
SRCS = $(shell find . -name '*.c')
OBJS = $(SRCS:.c=.o)
TARGET = test
.PHONY: check-leaks run clean
check-leaks: $(TARGET)
valgrind --track-origins=yes --leak-check=full -s ./$(TARGET)
run: $(TARGET)
./$(TARGET)
build: $(TARGET)
clean:
rm -f $(OBJS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^
%.o: %.c
gcc $(CFLAGS) -o $@ $< -I./src -lpthread