-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile_cip
57 lines (43 loc) · 1.47 KB
/
Makefile_cip
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
CC=g++
LD=g++
CCFLAGS=-isystem/usr/include -I. -c -std=c++0x
LDFLAGS=-lpng
CCDEBUGFLAGS=-g
LDDEBUGFLAGS=
CCRELEASEFLAGS=-O3 -DNDEBUG
LDRELEASEFLAGS=-O3
DEBUG_EXECUTABLE=cgrayd
RELEASE_EXECUTABLE=cgray
SRC_DIRS=core rt main
INT_DIR = build
DEBUG_INT_DIR = build/debug
RELEASE_INT_DIR = build/release
DEP_INT_DIR = build/dep
CPP_FILES := $(shell find $(SRC_DIRS) -name *.cpp)
DEBUG_OBJ_FILES := $(patsubst %.cpp,%.o,$(addprefix $(DEBUG_INT_DIR)/,$(CPP_FILES)))
RELEASE_OBJ_FILES := $(patsubst %.cpp,%.o,$(addprefix $(RELEASE_INT_DIR)/,$(CPP_FILES)))
DEP_FILES := $(patsubst %.cpp,%.d,$(addprefix $(DEP_INT_DIR)/,$(CPP_FILES)))
all: debug
debug: $(DEBUG_EXECUTABLE)
release: $(RELEASE_EXECUTABLE)
$(DEBUG_EXECUTABLE) : $(DEBUG_OBJ_FILES)
$(LD) $^ $(LDDEBUGFLAGS) $(LDFLAGS) -o $@
$(RELEASE_EXECUTABLE) : $(RELEASE_OBJ_FILES)
$(LD) $^ $(LDRELEASEFLAGS) $(LDFLAGS) -o $@
$(DEBUG_INT_DIR)/%.o : %.cpp
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) $(CCDEBUGFLAGS) $< -o $@
$(RELEASE_INT_DIR)/%.o : %.cpp
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) $(CCRELEASEFLAGS) $< -o $@
$(DEP_INT_DIR)/%.d : %.cpp
@mkdir -p $(dir $@)
@$(CC) $(CCFLAGS) -MM $< -MT $(patsubst %.cpp,%.o,$(addprefix $(DEBUG_INT_DIR)/,$<)) -MT $(patsubst %.cpp,%.o,$(addprefix $(RELEASE_INT_DIR)/,$<)) -MT $(patsubst %.cpp,%.d,$(addprefix $(DEP_INT_DIR)/,$<)) >> $@
clean:
@rm -r -f $(INT_DIR)
@rm -f $(DEBUG_EXECUTABLE)
@rm -f $(RELEASE_EXECUTABLE)
depend : $(DEP_FILES)
-include $(DEP_FILES)
.PHONY: all debug release clean
.SECONDARY: