SRC_DIR := src/ INC_DIR := include/ OBJ_DIR := build/ DEP_DIR := build/ EXE_DIR := build/ SRC := $(notdir $(shell ls $(SRC_DIR)*.cpp)) OBJ := $(patsub... ...
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