-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.mk
More file actions
46 lines (32 loc) · 1.05 KB
/
common.mk
File metadata and controls
46 lines (32 loc) · 1.05 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
#最重要最核心的编译脚本,定义makefile的编译规则,依赖规则等,通用性很强的一个脚本,并且各个子目录中都用到这个脚本文件
ifeq ($(DEBUG),true)
CC = g++ -g
VERSION = debug
else
CC = g++
VERSION = release
endif
SRCS = $(wildcard *.cxx)
OBJS = $(SRCS:.cxx=.o)
DEPS = $(SRCS:.cxx=.d)
BIN := $(addprefix $(BUILD_ROOT)/,$(BIN))
LINK_OBJ_DIR = $(BUILD_ROOT)/app/link_obj
DEP_DIR = $(BUILD_ROOT)/app/dep
$(shell mkdir -p $(LINK_OBJ_DIR))
$(shell mkdir -p $(DEP_DIR))
OBJS := $(addprefix $(LINK_OBJ_DIR)/, $(OBJS))
DEPS := $(addprefix $(DEP_DIR)/, $(DEPS))
LINK_OBJ = $(wildcard $(LINK_OBJ_DIR)/*.o)
LINK_OBJ += $(OBJS)
alls:$(DEPS) $(OBJS) $(BIN)
ifneq ("$(wildcard $(DEPS))", "")
include $(DEPS)
endif
$(BIN):$(LINK_OBJ)
@echo "---------------------------------------------build $(VERSION)---------------------------------------------"
$(CC) -o $@ $^
$(LINK_OBJ_DIR)/%.o:%.cxx
$(CC) -I$(INCLUDE_PATH) -o $@ -c $(filter %.cxx, $^)
$(DEP_DIR)/%.d:%.cxx
echo -n $(LINK_OBJ_DIR)/ > $@
gcc -I$(INCLUDE_PATH) -MM $^ >> $@