#################################################################################### Simple multi-Module program automatic compilation/removal Makefil E v2.0# Introduction: Automatic compilation, clean-up function, do not need to input GCC or RM instructions # Use Method: First configure Makefile in the configuration item, target name, etc., and then execute make on the terminal # #使用说明: 1. This makefile can automatically tear down the dependencies between the source program and the header file and generate the. depend file # 2. When the target directory does not exist, this makefile will call the $ (MKDIR) command to create the complete target directory tree # 3. When the make clean command is executed, all the matching pattern *~ files in the $ (SRC) directory are deleted, Author:wangqunfeng, date:2013/12/30# Modify History: # 2014-1-9: Add 2 Intermediate output files for the compilation process: preprocessing. I, compiling. s# 2015-2-27:v2.0 Auto-Toppling header file dependencies, enabling the creation of target directories ################################ #用户配置选项 ############## ####################### #TARGET = Dictobjs = cworddb.o cwordserver.o eworderror.ocxx = g++gdb = Gdbmkdir = MkdirVPATH + =./ :./includecxxflags =-G-STD=C++11SRC =./srcbin =./bin/debug####################################################### ############################# #删除路径后面的斜线 and converted to a path sequence VPATH: = $ (Patsubst%/,%,$ (subst:, $ (VPATH))) #设置包含文件搜索路径CXXFLAGS + = $ (addprefix-i,$ (VPATH)) ################################################################################### #all: Bin Depend $ (bin)/$ (target) $ (bin)/$ (target): $ (Addprefix $ (BIN)/,$ (objs ) $ (CXX) $ (Addprefix $ (BIN)/,$ (OBJS)) $ (cxxflags)-O $ (BIN)/$ (TARGET) $ (Addprefix $ (BIN)/,$ (OBJS)): $ (BIN)/%.O: $ (SRC)/ %.cpp$ (CXX) $ (cxxflags) $<-O [email protected]-include $ (BIN)/.dependdepend: $ (CXX) $ (cxxflags)-mm ${OBJS:%.O =$ (src)/%.cpp} > $ (BIN)/.dependbin:[!-D $ (BIN)] & $ (MKDIR)-P $ (BIN) Clean:rm-rf $ (SRC)/*~ $ (BIN)/$ (TARGET) $ (AD Dprefix $ (BIN)/,$ (OBJS)) $ (BIN)/.dependexec:$ (bin)/$ (target) gdb:$ (GDB) $ (BIN)/$ (target)
Original address: http://blog.csdn.net/qq759981398/article/details/38709319
Auto-Compile Makefile, original version, support auto-Push header file dependency, create target path