#MinGW 5.1.6
.PHONY:clean depend all tidy rebuild
CC = C:\MinGW\bin\g++.exe
RM = del /f
FLAGS = -g -Wall -O3 #-save-temps #-fdump-class-hierarchy #-dump_class_hierarchy
LIBPATHS = -L"C:\MingW\lib"
LIBS = #-lopengl32 #-mwindows
SRC += $(wildcard *.cpp)
SRC += $(wildcard */*.cpp)
SRC += $(wildcard */*/*.cpp)
SRC += $(wildcard */*/*/*.cpp)
SRC += $(wildcard */*/*/*/*.cpp)
SRC += $(wildcard */*/*/*/*/*.cpp)
SRC += $(wildcard */*/*/*/*/*/*.cpp)
SRC += $(wildcard */*/*/*/*/*/*/*.cpp)
SRC += $(wildcard */*/*/*/*/*/*/*/*.cpp)
OBJ = $(patsubst %.cpp,%.o,$(SRC))
DEP = $(patsubst %.cpp,%.d,$(SRC))
BIN = $(notdir $(CURDIR).exe)
all:$(BIN)
rebuild: all tidy
$(BIN):$(OBJ)
[TAB]$(CC) $(FLAGS) $^ $(LIBPATHS) $(LIBS) -o $@
-include $(DEP)
clean:
[TAB]-$(RM) $(subst /,\,$(BIN)) $(subst /,\,$(OBJ)) $(subst /,\,$(DEP))
tidy:
[TAB]-$(RM) $(subst /,\,$(OBJ)) $(subst /,\,$(DEP))
$(DEP):%.d:%.cpp
[TAB]${CC} -MM -MT $(patsubst %.cpp,%.o,$(^)) $(^) > $@
[TAB]@echo $$(CC) $$(FLAGS) -c -o $$@ $$(filter %%.cpp,$$^^) >> $@
?
注意:自己将[TAB]替换为Tab字符