-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (43 loc) · 1.34 KB
/
Makefile
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
CC := gcc
CFLAGS := -std=c99
CFLAGS += -Wpedantic -pedantic-errors
CFLAGS += -Wall -Wextra
CFLAGS += -Werror=main
CFLAGS += -Werror=write-strings
CFLAGS += -Werror=strict-prototypes
CFLAGS += -Werror=missing-prototypes
CFLAGS += -Werror=missing-declarations
CFLAGS += -Werror=implicit-int -Werror=implicit-function-declaration
CFLAGS += -Werror=format-security
ifneq ($(OS), 'Windows_NT')
CFLAGS += -D_POSIX_C_SOURCE
endif
LIBS := -lpthread -lm
LDFLAGS :=
SANITIZERFLAGS := -fsanitize=address -fsanitize=undefined
SRCDIR := src
OBJDIR := obj
BINDIR := bin
INCDIR := include
DEPDIR := deps
TARGET := chronos
SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SOURCES))
debug: CFLAGS += -Og -g3 -fno-omit-frame-pointer $(SANITIZERFLAGS)
debug: LDFLAGS += $(SANITIZERFLAGS)
debug: $(BINDIR)/$(TARGET)
release: CFLAGS += -O3 -g0 -DNDEBUG
release: $(BINDIR)/$(TARGET)
$(BINDIR)/$(TARGET): $(OBJECTS) | $(BINDIR)
@$(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR) $(DEPDIR)
@$(CC) -I$(INCDIR) -c $(CFLAGS) -o $@ \
-MT $@ -MMD -MP \
-MF $(patsubst $(OBJDIR)/%.o, $(DEPDIR)/%.d, $@) \
$<
$(BINDIR) $(OBJDIR) $(DEPDIR):
@mkdir -p $@
clean:
@rm -rf $(OBJDIR) $(DEPDIR) $(BINDIR)/$(TARGET)
.PHONY: debug release clean
-include $(patsubst $(SRCDIR)/%.c, $(DEPDIR)/%.d, $(SOURCES))