This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
133 lines (99 loc) · 3.82 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
include .config/make/config.mk
#==== RULES ====================================================================
#---- RELEASE ------------------------------------------------------------------
$(BIN)_release: $(OPT_OBJS)
$(Q)$(MKDIR) $(BIN_DIR)
$(Q)echo -e "====> LD $@"
$(Q)$(CC) $(RELEASE) $+ -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.opt.o: %.c
$(Q)echo "====> CC $@"
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(RELEASE) $(CFLAGS) -c $< -o $@
release: $(BIN)_release
#---- DEBUGGING ----------------------------------------------------------------
$(BIN)_debugging: $(DBG_OBJS)
$(Q)$(MKDIR) $(BIN_DIR)
$(Q)echo -e "====> LD $@"
$(Q)$(CC) $(DEBUGGING) $+ -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.dbg.o: %.c
$(Q)echo "====> CC $@"
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(DEBUGGING) $(CFLAGS) -c $< -o $@
debugging: $(BIN)_debugging
#---- SANITIZED ----------------------------------------------------------------
$(BIN)_sanitized: $(SAN_OBJS)
$(Q)$(MKDIR) $(BIN_DIR)
$(Q)echo -e "====> LD $@"
$(Q)$(CC) $(SANITIZED) $+ -o $@ $(LDFLAGS)
$(BUILD_DIR)/%.san.o: %.c
$(Q)echo "====> CC $@"
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(SANITIZED) $(CFLAGS) -c $< -o $@
sanitized: $(BIN)_sanitized
#---- PROFILING ----------------------------------------------------------------
$(BIN)_profiling: $(PROF_OBJS)
$(Q)$(MKDIR) $(BIN_DIR)
$(Q)echo -e "====> LD $@"
$(Q)$(CC) $(PROFILING) $+ -o $@ $(LDFLAGS) -pg
$(BUILD_DIR)/%.prof.o: %.c
$(Q)echo "====> CC $@"
$(Q)mkdir -p $(dir $@)
$(Q)$(CC) $(PROFILING) $(CFLAGS) -c $< -o $@
profiling: $(BIN)_profiling
#---- CLEANING -----------------------------------------------------------------
clean:
$(Q)echo "====> Cleaning..."
$(Q)$(RM) --recursive --force $(BUILD_DIR)/$(SRC_DIR)
#---- DOCUMENTATION ------------------------------------------------------------
docs:
$(Q)echo "====> Creating the documentation..."
$(Q)doxygen
#---- STYLE --------------------------------------------------------------------
style:
$(Q)echo "====> Formatting..."
$(Q)find $(SRC_DIR) -iname *.h -o -iname *.c | xargs clang-format -i $(CLANG_FMT_CONFIG)
#---- ANALYSIS -----------------------------------------------------------------
analyze:
$(Q)$(MKDIR) logs
$(Q)echo "====> Running scan-build..."
$(Q)scan-build make all
$(Q)echo "====> Running cppcheck..."
$(Q)cppcheck src/ $(CPPCHECK) 2> logs/cppcheck.log
$(Q)echo "====> Running clang-tidy..."
$(Q)compiledb make all
$(Q)clang-tidy.py $(PROJ_SRCS) $(CLANG_TIDY_CONFIG) || true
$(Q)yq 'del(.Diagnostics[] | select(.DiagnosticMessage.FilePath | test("deps")))' tidy.log > logs/tidy.log
$(Q)$(RM) tidy.log
memcheck: debugging
$(Q)echo "====> Running valgrind..."
$(Q)valgrind ${VALGRIND} --tool=memcheck $(BIN)_debugging
callgrind: debugging
$(Q)echo "====> Running valgrind..."
$(Q)valgrind --tool=callgrind $(BIN)_debugging
#---- TESTING ------------------------------------------------------------------
tests: sanitized
$(Q)for test in $(TESTS); do \
echo "====> Running $$test..."; \
$(BIN)_release --filename=$$test; \
done
#---- INSTALLING ---------------------------------------------------------------
install: release
$(Q)echo "====> Installing the binary..."
$(Q)cp $(BIN)_release $(PREFIX)/bin/$(NAME)
$(Q)echo "====> Installing the library..."
$(Q)$(MKDIR) $(PREFIX)/lib/lispy
$(Q)cp $(LIB)/stdlib.lspy $(PREFIX)/lib/lispy/
$(Q)echo "====> Finished!"
uninstall:
$(Q)echo "====> Removing the binary..."
$(Q)$(RM) $(PREFIX)/bin/$(NAME)
$(Q)echo "====> Removing the library..."
$(Q)$(RM) $(PREFIX)/lib/lispy/stdlib.lspy
$(Q)rmdir $(PREFIX)/lib/lispy/
$(Q)echo "====> Finished!"
#==== EPILOGUE =================================================================
all: style release debugging sanitized profiling tests docs
$(Q)echo "====> Finished!"
# Include the .d makefiles
-include $(DEPS)
.PHONY: all release debugging memcheck style install uninstall tests profiling docs