forked from CMU-SAFARI/MQSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (26 loc) · 769 Bytes
/
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
CC := g++
LD := g++
CC_FLAGS := -std=c++11 -O3 -g
MODULES := exec host nvm_chip nvm_chip/flash_memory sim ssd utils
SRC_DIR := $(addprefix src/,$(MODULES)) src
BUILD_DIR := $(addprefix build/,$(MODULES)) build
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
SRC := src/main.cpp $(SRC)
OBJ := $(patsubst src/%.cpp,build/%.o,$(SRC))
INCLUDES := $(addprefix -I,$(SRC_DIR))
vpath %.cpp $(SRC_DIR)
define make-goal
$1/%.o: %.cpp
$(CC) $(CC_FLAGS) $(INCLUDES) -c $$< -o $$@
endef
.PHONY: all checkdirs clean
all: checkdirs MQSim
MQSim: $(OBJ)
$(LD) $^ -o $@
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
mkdir -p $@
clean:
rm -rf $(BUILD_DIR)
rm -f MQSim
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))