标签:++ type .PHONY out util -o -- cli lte
.PHONY: all clean OBJ = obj BIN = bin LIB = lib SRC = src GCC = g++ FLAGS = -Wall -g DEFINES = -DLINUX # 头文件目录 INCLUDES = $(patsubst %,-I%, /usr/include /szmetro/download/p2p-c++/p2p-ice/src) # 库文件目录 SYSLIBDIR = /usr/local/lib P2PLIB = /szmetro/download/p2p-c++/p2p-ice/bin LIBDIRS = $(patsubst %,-L%, $(LIB) $(SYSLIBDIR) $(P2PLIB)) # 库文件 ICELIB = Ice IceUtil p2p-ice LIBS = $(patsubst %,-l%, $(ICELIB)) # 默认递归3级目录, 不编译的文件请添加到DISCARD DISCARD = $(wildcard $(SRC)/test/*.cpp) OBJS = $(patsubst $(SRC)/%.cpp,$(OBJ)/%.o, $(filter-out $(DISCARD), $(shell find $(SRC)/* -maxdepth 3 -type f -regex ".*\.cpp"))) OBJDIRS = $(sort $(patsubst $(SRC)/%,$(OBJ)/%, $(dir $(OBJS)))) # 可执行文件名 EXEC = $(BIN)/p2p-client all: MKDIR $(EXEC) MKDIR: mkdir $(OBJDIRS) -p $(EXEC): $(OBJS) $(GCC) $(OBJS) -o $@ $(LIBDIRS) $(LIBS) # Makefile默认目标 $(OBJ)/%.o: $(SRC)/%.cpp $(GCC) $(INCLUDES) $(DEFINES) $(FLAGS) -c $^ -o $@ clean: rm -fr $(OBJ)/* rm -f $(EXEC)
目录结构如:
. |-- bin |-- lib |-- Makefile |-- obj `-- src
标签:++ type .PHONY out util -o -- cli lte
原文地址:https://www.cnblogs.com/itpoorman/p/10747807.html