Auto-Compile Makefile, original version, support auto-Push header file dependency, create target path

Source: Internet
Author: User

#################################################################################### 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.