标签:dir shell c++11 makefile path .exe lag div pre
SRC_DIR := src/
INC_DIR := include/
OBJ_DIR := build/
DEP_DIR := build/
EXE_DIR := build/
SRC := $(notdir $(shell ls $(SRC_DIR)*.cpp))
OBJ := $(patsubst %.cpp,$(OBJ_DIR)%.o,$(notdir $(SRC)))
DEP := $(patsubst %.cpp,$(DEP_DIR)%.d,$(notdir $(SRC)))
LIBFLAGS :=
CXXFLAGS := -Wall -std=c++11 -DWIN32
INCFLAGS := -I$(INC_DIR)
EXE := $(EXE_DIR)main.exe
vpath %.cpp $(SRC_DIR)
.PHONY: run clean
$(EXE): $(OBJ)
$(CXX) -o $(EXE) $(OBJ) $(LIBFLAGS)
run:
./$(EXE)
clean:
rm -f $(OBJ_DIR)*.o $(DEP_DIR)*.d $(EXE)
$(OBJ_DIR)%.o: %.cpp
$(CXX) -c $< -o $@ $(INCFLAGS) $(CXXFLAGS)
$(DEP_DIR)%.d: %.cpp
@$(CXX) $< -MP -MM -MF$@ -MT$@ -MT$(patsubst %.d,$(OBJ_DIR)%.o,$(notdir $@)) $(INCFLAGS) $(CXXFLAGS)
ifneq ($(MAKECMDGOALS),clean)
include $(DEP)
endif
标签:dir shell c++11 makefile path .exe lag div pre
原文地址:http://www.cnblogs.com/howld/p/5686240.html