-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (38 loc) · 1000 Bytes
/
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
MKDIR ?= mkdir -p
CPP ?= cpp
CC ?= cc
ASAN_FLAGS = -fsanitize=address -fno-omit-frame-pointer -Wno-format-security
CFLAGS += -std=c11 -Wall -pedantic
CPPFLAGS += -MMD -I.
LDFLAGS += -lm -lpthread -ldl
ifeq ($(DEBUG),0)
CFLAGS += -O3 -DNDEBUG
else
CFLAGS += -ggdb -O0
endif
Q ?= @
EXECUTABLE = pagerank
OBJDIR = obj
SRCDIR = src
all: $(EXECUTABLE)
SOURCES = $(wildcard $(SRCDIR)/*.c)
OBJFILES = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SOURCES))
# rebuild everything if the Makefile changes
$(OBJFILES): Makefile
# include dependency files:
-include $(OBJFILES:.o=.d)
.PHONY: all clean tests
clean:
$(Q)rm -f $(EXECUTABLE)
$(Q)rm -rf $(OBJDIR)
$(EXECUTABLE): $(OBJFILES)
$(Q)echo Linking $@
$(Q)$(CC) $(LDFLAGS) $(ASAN_FLAGS) -o $@ $^
obj/.dir:
$(Q)$(MKDIR) $(@D)
$(Q)date >$@
obj/%.o: $(SRCDIR)/%.c | obj/.dir
$(Q)echo Compiling $<
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(ASAN_FLAGS) -c -o $@ $<
tests: $(EXECUTABLE)
tests/run-tests.py $(EXECUTABLE)