gcc -M -MM -MQ -MF -MT -MD

静态模式规则对一个较大工程的管理非常有用。它可以对整个工程的同一类文件的重建规则进行一次定义,而实现对整个工程中此类文件指定相同的重建规则。比如,可
以用来描述整个工程中所有的.o 文件的依赖规则和编译命令。通常的做法是将生成同一类目标的模式定义在一个 make.rules 的文件中。在工程各个模块的 Makefile 中包含
此文件。

gcc

-M: output a rule suitable for make describing the dependencies of the main source file.The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

Unless specified explicitly (with -MT or -MQ), the object file name consists of the name of the source file with any suffix replaced
with object file suffix and with any leading directory parts removed. If there are many included files then the rule is split into
several lines using \-newline. The rule has no commands.

-MM: Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or
indirectly, from such a header.

This implies that the choice of angle brackets or double quotes in an #include directive does not in itself determine whether that
header will appear in -MM dependency output. This is a slight change in semantics from GCC versions 3.0 and earlier.

-MF file
When used with -M or -MM, specifies a file to write the dependencies to. If no -MF switch is given the preprocessor sends the rules to
the same place it would have sent preprocessed output.

When used with the driver options -MD or -MMD, -MF overrides the default dependency output file.

-MT target
Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletes any
directory components and any file suffix such as .c, and appends the platform‘s usual object suffix. The result is the target.

An -MT option will set the target to be exactly the string you specify. If you want multiple targets, you can specify them as a single
argument to -MT, or use multiple -MT options.

For example, -MT ‘$(objpfx)foo.o‘ might give

    $(objpfx)foo.o: foo.c

-MQ target
Same as -MT, but it quotes any characters which are special to Make. -MQ ‘$(objpfx)foo.o‘ gives

  $$(objpfx)foo.o: foo.c

The default target is automatically quoted, as if it were given with -MQ.

-MD -MD is equivalent to -M -MF file, except that -E is not implied. The driver determines file based on whether an -o option is given.
If it is, the driver uses its argument but with a suffix of .d, otherwise it takes the name of the input file, removes any directory
components and suffix, and applies a .d suffix.

If -MD is used in conjunction with -E, any -o switch is understood to specify the dependency output file, but if used without -E, each
-o is understood to specify a target object file.

Since -E is not implied, -MD can be used to generate a dependency output file as a side-effect of the compilation process.

时间: 2024-10-10 08:24:20

gcc -M -MM -MQ -MF -MT -MD的相关文章

/MT /MD /ML /MTd /MDd /MLd 的区别

Multithreaded Libraries Performance The single-threaded CRT is no longer ( in vs2005 ) available. This topic discusses how to get the maximum performance from the multithreaded libraries. The performance of the multithreaded libraries has been improv

GCC使用

GCC的选项 如何指定GCC的默认头 文件路径 Linux系统的头文件 和库文件搜索路径 头文件 库文件 运行时动态库的搜索路径 GCC的选项 -c 只生成目标文件(.o),不连接. % gcc -c main.c% g++ -c reciprocal.cpp -I 可以指定头文件的目录 % g++ -c -I ../include reciprocal.cpp -D 设置宏定义 % g++ -c -D NDEBUG reciprocal.cpp% g++ -c -D NDEBUG=3 reci

如何指定GCC的默认头文件路径

如何指定GCC的默认头文件路径 网上偶搜得之,以之为宝:)原地址:http://blog.chinaunix.net/u/28781/showart.php?id=401631=============================================================================== 在交叉编译的时候我们需要用到其他的库,在config时候可以通过“-l”来指定目录,但是每次都需要设置的话难免有些麻烦,找到一个简单的方法.看下文的红色部分. 有大

GCC 环境变量 & eclipse CDT 头文件配置

转:http://blog.csdn.net/statdm/article/details/7751000 GCC 环境变量 & eclipse CDT 头文件配置 在unix 下使用eclipse 进行c/c++开发时,默认是使用系统的头文件路径,如果你自己新安装了编译器,比如最新版 gcc 4.7.1,这个时候你要将头文件 路径指向你的gcc安装路径,配置如下图: 菜单 window-->preferences 添加变量 CPP_INCLUDE_PATH 重启后,Include中的c++

整理Linux下gcc编译中关于头文件与库文件搜索路径相关问题

分类: MakeFile/Make/GCC/LD2010-11-20 23:15 535人阅读 评论(0) 收藏 举报 转者的话: 本文详细介绍了gcc 编译时 搜索头文件的路径以及方式, 编译时寻找lib库的方式, 以及运行时加载库的寻找方式!!!非常之经典啊!以后有新的知识都汇总到这里来了! 在交叉编译的时候我们需要用到其他的库,在config时候可以通过“-I”来指定头文件目录,但是每次都需要设置的话难免有些麻烦,找到一个简单的方法. 看下文的红色部分. 有大量的环境变量可供设置以影响 G

GCC、头文件查找顺序总结

GCC笔记 The History of GCC -------------------------------------------------------------------------------- 1984年,Richard Stallman发起了自由软件运动,GNU (Gnu's Not Unix)项目应运而生,3年后,最初版 的GCC横空出世,成为第一款可移植.可优化.支持ANSI C的开源C编译器. GCC最初的全名是GNU C Compiler,之后,随着GCC支持的语言越

使用-MM生成include指令和依赖生成(make include directive and dependency generation with -MM)

I want a build rule to be triggered by an include directive if the target of the include is out of date or doesn't exist. Currently the makefile looks like this: program_NAME := wget++ program_H_SRCS := $(wildcard *.h) program_CXX_SRCS := $(wildcard

Autotools Mythbuster

Preface Diego Elio?"Flameeyes"?Pettenò Author and Publisher?<[email protected]> SRC=https://autotools.io/index.html David J.?"user99"?Cozatt Miscellaneous Editing?<[email protected]> Copyright ? 2009-2013 Diego Elio Pettenò

【Linux技术】autotools制作makefile过程详解【转】

转自:http://www.cnblogs.com/lcw/p/3159461.htmlPreface Makefile固然可以帮助make完成它的使命,但要承认的是,编写Makefile确实不是一件轻松的事,尤其对于一个较大的项目而言更是如此.那么,有没有一种轻松的手段生成Makefile而同时又能让我们享受make的优越性呢?autotools系列工具正是为此而设的,它只需用户输入简单的目标文件.依赖文件.文件目录等就可以轻松地生成Makefile了,这无疑是广大用户的所希望的.另外,这些工