-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathroutine.makefile
61 lines (50 loc) · 1.4 KB
/
routine.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
#==============================================================================
# ■ routine.makefile
#------------------------------------------------------------------------------
# Sometimes it's just too amazing.
#==============================================================================
# 又被include的cwd坑了一把
# Useful variables.
ifeq "$(SOURCES)" ""
ifeq "$(PLATFORM)" "msw"
SOURCES = $(subst $(shell cd)\,,$(shell dir /b /s *.cpp))
else ifeq "$(PLATFORM)" "gnu"
SOURCES = $(shell find . -name "*.cpp")
else ifeq "$(PLATFORM)" "mac"
SOURCES = $(shell find . -name "*.cpp")
endif
endif
ifdef DEBUG
OBJECTS = $(SOURCES:%.cpp=%.debug.o)
else
OBJECTS = $(SOURCES:%.cpp=%.o)
endif
ONE_FILE = one.cxx
all: $(TARGET)
one:
ifeq "$(PLATFORM)" "msw"
type nul > $(ONE_FILE) \
& for %%i in ($(SOURCES)) do echo #include "%%i" >> $(ONE_FILE)
else
echo $(SOURCES) | sed 's/ /\n/g' | sed 's/^/#include "/;s/$/"/' > $(ONE_FILE)
endif
$(CXX) $(ONE_FILE) -o VMDE.one.dll $(CXXFLAGS) $(LDLIBS) $(LDFLAGS)
%.o %.debug.o: %.cpp
$(call ECHO_BANNER_BOLD,编译C++文件,$^)
$(CXX) -c $^ -o $@ $(CXXFLAGS)
$(TARGET): $(OBJECTS)
$(call ECHO_BANNER,链接最终二进制)
$(CCLD) $^ -o $@ $(LDLIBS) $(LDFLAGS)
clean:
ifeq "$(PLATFORM)" "msw"
else
$(RM) $(TARGET) $(OBJECTS)mcpu
endif
run: all
$(call ECHO_BANNER,运行)
ifeq "$(PLATFORM)" "msw"
$(TARGET)
else
./$(TARGET)
endif
.PHONY: all one clean