-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
executable file
·100 lines (83 loc) · 2.41 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
TARGETS := mdriver
LOCKER=/afs/csail/proj/courses/6.172
CC := icpc
CXX := icpc
# You can add -Werr to GCC to force all warnings to turn into errors
CFLAGS := -g -Wall
CXXFLAGS := -g -Wall
LDFLAGS := -lpthread
HEADERS := \
allocator_interface.h \
config.h \
fsecs.h \
mdriver.h \
memlib.h \
validator.h
# Blank line ends list.
# If you add a new file called "filename.c", you should
# add "filename.o \" to this list.
OBJS := \
memlib.o
MDRIVER_OBJS:= \
allocator.o \
bad_allocator.o \
clock.o \
fcyc.o \
fsecs.o \
ftimer.o \
libc_allocator.o \
mdriver.o
BENCHMARKS:= cache-scratch.cpp cache-thrash.cpp larson.cpp linux-scalability.c growvector.cpp
# Blank line ends list.
OLDMODE := $(shell cat .buildmode 2> /dev/null)
ifeq ($(DEBUG),1)
CFLAGS := -DDEBUG -O0 $(CFLAGS)
CXXFLAGS := -DDEBUG -O0 $(CXXFLAGS)
ifneq ($(OLDMODE),debug)
$(shell echo debug > .buildmode)
endif
else
CFLAGS := -DNDEBUG -O3 $(CFLAGS)
CXXFLAGS := -DNDEBUG -O3 $(CXXFLAGS)
ifneq ($(OLDMODE),nodebug)
$(shell echo nodebug > .buildmode)
endif
endif
# make all targets specified
all: $(TARGETS)
.PHONY: pintool
pintool:
$(MAKE) -C pintool
mdriver: $(OBJS) $(MDRIVER_OBJS)
$(CXX) $(LDFLAGS) $(OBJS) $(MDRIVER_OBJS) -o $@
benchmark: $(OBJS) wrapper.cpp
for benchmark in $(BENCHMARKS); do \
name=$${benchmark%.*}; \
echo $(CXX) $(CFLAGS) -DMYMALLOC $(LDFLAGS) $(OBJS) benchmarks/$$benchmark -o $$name; \
$(CXX) $(CFLAGS) -DMYMALLOC $(LDFLAGS) $(OBJS) benchmarks/$$benchmark -o $$name; \
echo $(CXX) $(CFLAGS) -DMYMALLOC -DVALIDATE $(LDFLAGS) benchmarks/$$benchmark $(OBJS) -o $$name-validate; \
$(CXX) $(CFLAGS) -DMYMALLOC -DVALIDATE $(LDFLAGS) benchmarks/$$benchmark $(OBJS) -o $$name-validate; \
echo $(CXX) $(CFLAGS) $(LDFLAGS) benchmarks/$$benchmark $(OBJS) -o $$name-libc; \
$(CXX) $(CFLAGS) $(LDFLAGS) benchmarks/$$benchmark $(OBJS) -o $$name-libc; \
done
# compile objects
# pattern rule for building objects
%.o: %.cxx %.h $(HEADERS) .buildmode Makefile
$(CXX) $(CXXFLAGS) -c $< -o $@
%.o: %.c %.h $(HEADERS) .buildmode Makefile
$(CC) $(CFLAGS) -c $< -o $@
# run each of the targets
run: $(TARGETS)
for X in $(TARGETS) ; do \
echo $$X -v ; \
./$$X -v ; \
echo ; \
done
# remove targets and .o files as well as output generated by CQ
clean:
$(RM) $(TARGETS) $(OBJS) $(MDRIVER_OBJS) *.std* .buildmode
for benchmark in $(BENCHMARKS); do \
name=$${benchmark%.*}; \
$(RM) $$name $$name-libc $$name-validate; \
done
$(RM) tmp/*.out