模板如下
.PHONY: all clean
all:project_a
BUILD_DIR = tmp
ARGS:= -std=c++11 -g -DXNT -MMD -MP
INC_DIR:= -I./
LIB_DIR:= -L./lib
LIBS:= -lslog -lpthread
SRCS = $(wildcard ./*.cpp ./*.c)
OBJS = $(patsubst %.cpp,$(BUILD_DIR)/%.o,$(SRCS))
DEPS = $(wildcard $(BUILD_DIR)/*.d)
project_a:$(OBJS)
g++ $^ -o $@ $(LIB_DIR) $(LIBS)
$(BUILD_DIR)/%.o:%.cpp
if [ ! -d $(BUILD_DIR) ]; then mkdir -p $(BUILD_DIR); fi; g++ -g -c $< $(INC_DIR) $(ARGS) -o $@
-include $(DEPS)
clean:
@# 清理生成的内容
rm -rf ./project_a $(BUILD_DIR)
makefile的简单模板