forked from CMU-SAFARI/Pythia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (61 loc) · 1.48 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
app = champsim
srcExt = cc
srcDir = src branch replacement prefetcher
objDir = obj
binDir = bin
inc = inc
debug = 1
CFlags = -Wall -O3 -std=c++11 -D_DEFAULT_SOURCE -I./libbf/
LDFlags = ./libbf/build/lib/libbf.a
libs =
libDir =
#************************ DO NOT EDIT BELOW THIS LINE! ************************
ifeq ($(debug),1)
debug=-g
else
debug=
endif
inc := $(addprefix -I,$(inc))
libs := $(addprefix -l,$(libs))
libDir := $(addprefix -L,$(libDir))
CFlags += -c $(debug) $(inc) $(libDir) $(libs)
sources := $(shell find $(srcDir) -name '*.$(srcExt)')
srcDirs := $(shell find . -name '*.$(srcExt)' -exec dirname {} \; | uniq)
objects := $(patsubst %.$(srcExt),$(objDir)/%.o,$(sources))
ifeq ($(srcExt),cc)
CC = $(CXX)
else
CFlags += -std=gnu99
endif
.phony: all clean distclean
all: $(binDir)/$(app)
$(binDir)/$(app): buildrepo $(objects)
@mkdir -p `dirname $@`
@echo "Linking $@..."
@$(CC) $(objects) $(LDFlags) -o $@
$(objDir)/%.o: %.$(srcExt)
@echo "Generating dependencies for $<..."
@$(call make-depend,$<,$@,$(subst .o,.d,$@))
@echo "Compiling $<..."
@$(CC) $(CFlags) $< -o $@
clean:
$(RM) -r $(objDir)
distclean: clean
$(RM) -r $(binDir)/$(app)
buildrepo:
@$(call make-repo)
define make-repo
for dir in $(srcDirs); \
do \
mkdir -p $(objDir)/$$dir; \
done
endef
# usage: $(call make-depend,source-file,object-file,depend-file)
define make-depend
$(CC) -MM \
-MF $3 \
-MP \
-MT $2 \
$(CFlags) \
$1
endef