-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
50 lines (39 loc) · 1.01 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
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
OUT_DIR ?= $(SRC_DIR)/output
CXX_DEBUG ?= gdb
BIN ?= nestest
ifeq ($(BIN), nestest)
ARGS ?= -ct
else ifeq ($(BIN), pputest)
ARGS ?= -cp
else ifeq ($(BIN), cputest)
ARGS ?= -cu
else ifeq ($(BIN), dk)
ARGS ?= -cr DonkeyKong.nes
else
ARGS ?= -cr $(BIN)
endif
.PHONY: binary run debug lint clean
$(OUT_DIR):
mkdir -p $@
binary: $(OUT_DIR)
cd $(OUT_DIR) && cmake \
-DCMAKE_BUILD_TYPE=Debug \
-Wall -Werror \
$(SRC_DIR)
$(MAKE) 2a03 -C $(OUT_DIR)
run: binary
cd $(OUT_DIR) && ./2a03 $(ARGS)
debug: binary
cd $(OUT_DIR) && $(CXX_DEBUG) $(GDBARGS) --args ./2a03 $(ARGS)
vg: binary
cd $(OUT_DIR) && valgrind --tool=memcheck --leak-check=full -s \
--track-origins=yes --log-file=vg.$(BIN).log \
--suppressions=../vgsuppress ./2a03 $(ARGS)
check:
$(MAKE) cppcheck -C $(OUT_DIR)
find ./src -name "*.cpp" -o -name "*.h" | xargs clang-format -i
loc:
find ./src -type f \( -name \*.cpp -o -name \*.h \) -exec wc -l {} +
clean:
rm -rf $(OUT_DIR)