Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (54 loc) · 1.68 KB
/
Copy pathMakefile
File metadata and controls
70 lines (54 loc) · 1.68 KB
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
# simso - modular build
#
# make release build -> ./simso
# make debug -O0 -g, asserts
# make asan AddressSanitizer + UBSan
# make filc build with Fil-C (filcc) for full memory-safety checking
# make run build and run
# make bench build and run a 500-run parallel sweep
# make clean
CC ?= gcc
STD = -std=gnu11
WARN = -Wall -Wextra -Wshadow -Wpointer-arith -Wstrict-prototypes \
-Wmissing-prototypes -Wno-unused-parameter
OPT ?= -O2
CFLAGS += $(STD) $(WARN) $(OPT) -pthread
LDFLAGS += -pthread
LDLIBS += -lncursesw
SRC = src/sim.c src/shared.c src/ui.c src/bench.c src/main.c
OBJ = $(SRC:.c=.o)
DEP = $(OBJ:.o=.d)
BIN = simso
.PHONY: all debug asan filc run bench clean
all: $(BIN)
$(BIN): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
%.o: %.c
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
debug:
$(MAKE) clean
$(MAKE) OPT="-O0 -g3 -fno-omit-frame-pointer"
asan:
$(MAKE) clean
$(MAKE) OPT="-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer" \
LDFLAGS="-pthread -fsanitize=address,undefined"
# Fil-C builds go through build-filc.sh, which probes for filcc and for the
# ncurses variant its pizfix actually ships. Keeping that logic in one place
# rather than duplicating it here.
filc:
./build-filc.sh
run: $(BIN)
./$(BIN)
bench: $(BIN)
./$(BIN) --bench 500
clean:
rm -f $(OBJ) $(DEP) $(BIN) $(CHECK_BIN)
rm -rf build
-include $(DEP)
# ---- tests ----------------------------------------------------------
CHECK_BIN = tests/check
$(CHECK_BIN): tests/check.c src/sim.c src/sim.h src/rng.h
$(CC) $(STD) $(WARN) -O2 -Isrc -o $@ tests/check.c src/sim.c
.PHONY: check
check: $(CHECK_BIN)
./$(CHECK_BIN)