其实,makefile有点复杂。

文档看了又看,还是要经常翻,做个记录备忘 :)

1.  隐含命令 implicit rules

  与 implicit rule 相对应的有 pattern rules 和 suffix rules

Compiling C programs
n.o is made automatically from n.c with a recipe of the form ‘$(CC) $(CPPFLAGS) $(CFLAGS) -c’. Compiling C++ programs
n.o is made automatically from n.cc, n.cpp, or n.C with a recipe of the form ‘$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c’.
We encourage you to use the suffix ‘.cc’ for C++ source files instead of ‘.C’.
Linking a single object file
n is made automatically from n.o by running the linker (usually called ld) via the C compiler. The precise recipe
used is ‘$(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)’. This rule does the right thing for a simple program with only one source file. It will also do the right thing
if there are multiple object files (presumably coming from various other source files), one of which has a name
matching that of the executable file. Thus, x: y.o z.o
when x.c, y.c and z.c all exist will execute: cc -c x.c -o x.o
cc -c y.c -o y.o
cc -c z.c -o z.o
cc x.o y.o z.o -o x
rm -f x.o
rm -f y.o
rm -f z.o
In more complicated cases, such as when there is no object file whose name derives from the executable file name,
you must write an explicit recipe for linking.
CFLAGS
Extra flags to give to the C compiler. CXXFLAGS
Extra flags to give to the C++ compiler. CPPFLAGS
Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers). LDFLAGS
Extra flags to give to compilers when they are supposed to invoke the linker, ‘ld’, such as -L.
Libraries (-lfoo) should be added to the LDLIBS variable instead. LDLIBS
Library flags or names given to compilers when they are supposed to invoke the linker, ‘ld’.
LOADLIBES is a deprecated (but still supported) alternative to LDLIBS. Non-library linker flags,
such as -L, should go in the LDFLAGS variable.

  Canceling Implicit Rules

定义一个空的 recipe 就可以取消隐含命令:

%.o : %.s

生成 *.o 的隐式命令,就被取消了。

2. 更新所有目标文件

  以前是这样的: 先 make clean 然后 make。现在我们这样   make -B

‘-B’
‘--always-make’
Consider all targets out-of-date. GNU make proceeds to consider targets and their prerequisites using
the normal algorithms; however, all targets so considered are always remade regardless of the status
of their prerequisites. To avoid infinite recursion, if MAKE_RESTARTS (see Other Special Variables)
is set to a number greater than this option is disabled when considering whether to remake
makefiles (see How Makefiles Are Remade).

3.  使用隐含规则的时候,make,只会打印如下信息:

  由于项目工程makefile有好多自定义内容,也许此段内容有错误。

[root@okk msre_engine]# make -B
CC ee_re_util.o
CC ee_pcre.o
CC mt_rand.o
CC utils.o
CC ruledb.o

  可是,我们有时候需要看编译参数。我还不知道怎么打印,即使用--debug也不打印。

  但是,可以用dry-run来临时解决这个问题。就是只打印不执行的意思。

‘-n’
‘--just-print’
‘--dry-run’
‘--recon’
Print the recipe that would be executed, but do not execute it (except in certain circumstances). See Instead of
Executing Recipes.

[skill][makefile] makefile 常用内容记录的更多相关文章

  1. [skill][git] git 常用操作记录

    傻瓜入门: step by step : https://try.github.io/levels/1/challenges/1 一本书: https://git-scm.com/book/en/v2 ...

  2. django-xadmin常用内容记录

    自定义菜单名称: 1 修改app下的 apps.py文件 添加 class OperationConfig(AppConfig): name = 'operation' verbose_name = ...

  3. WPF DataGrid常用属性记录

    WPF DataGrid常用属性记录 组件常用方法: BeginEdit:使DataGrid进入编辑状态. CancelEdit:取消DataGrid的编辑状态. CollapseRowGroup:闭 ...

  4. Cs231n课堂内容记录-Lecture 3 最优化

    Lecture 4 最优化 课程内容记录: (上)https://zhuanlan.zhihu.com/p/21360434?refer=intelligentunit (下)https://zhua ...

  5. Cs231n课堂内容记录-Lecture2-Part2 线性分类

    Lecture 3 课程内容记录:(上)https://zhuanlan.zhihu.com/p/20918580?refer=intelligentunit (中)https://zhuanlan. ...

  6. 前端常用功能记录(二)—datatables表格(转)

    前端常用功能记录(二)—datatables表格 并不是所有的后台开发都有美工和前端工程师来配合做页面,为了显示数据并有一定的美感,jQuery的DataTables插件对于像我这样的前端菜鸟来说真是 ...

  7. MVC中验证码的实现(经常用,记录备用)

    一.目录 1.多层架构+MVC+EF+AUTOFAC+AUTOMAPPER: 2.MVC中验证码的实现(经常用,记录备用) 3.Ligerui首页的快速搭建 二 正文 Ok,我们的验证码开始,这篇文章 ...

  8. Centos下磁盘管理的常用命令记录(如查找大文件)

    Centos下磁盘管理的常用命令记录 查看系统磁盘空间占用,使用命令: df -h 结果: 查看磁盘inode使用情况,如果inode用完了,磁盘就没法写入新的内容了: df -i 结果: 如何查找磁 ...

  9. android布局常用属性记录

    android布局常用属性记录   http://blog.csdn.net/xn4545945/article/details/7717086这里有一部分别人总结的其余的: align:对齐 par ...

随机推荐

  1. 批处理命令学习笔记——Start命令

    Start 命令 启动另一个窗口运行指定的程序或命令,所有的DOS命令和命令行程序都可以由start命令来调用. 语法:START ["title"] [/Dpath] [/I] ...

  2. Node入门教程(9)第七章:NodeJs的文件处理

    Node的文件处理涉及到前面说的ptah模块,以及fs文件系统.stream流处理.Buffer缓冲器等模块.内容可能比较多,相关内容请以官网文档为主,此处主要以案例讲解为主,分享给大家一些常用的经典 ...

  3. Android开发(十七)——关闭中间activity

    参考: http://java--hhf.iteye.com/blog/1826880

  4. java框架篇---hibernate入门

    Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库. Hibernate可以应用在任何使用JDB ...

  5. 9patch图的尺寸尽量为偶数

    美工做了一张.9的背景图,宽度110*80 像素,描点如下: 放到720p的智能电视上观看,总感觉怪怪的.仔细观看可以发现,前景图总是不能完全的覆盖掉背景图.总有那么一个像素的点多余出来,如图所示: ...

  6. linux下用/proc/stat文件来计算cpu的利用率-c语言实现

    proc文件系统介绍 /proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间.它以文件系统的方式为内核与进程提供通信的接口.用户和应用程序可以通过/proc得到系统的信息,并可以改变内 ...

  7. linux 斜杠/

    inux OS: 使用”/“   例子:/home/user/XXX 特例:路径中某目录名包含空格,在命令行中使用cd等命令书写路径时,则要在空格前加”\“ 例子: 主目录(/home/student ...

  8. cocos2dx内存管理

    cocos2dx基于引用计数管理内存,所有继承自CCObject的对象都将获得引用计数的能力,可通过调用retain成员函数用于引用计数值,调用release减少引用计数值,当计数值减为0时销毁对象. ...

  9. thinkphp 无限极 评论

    郑创 今天用啦一天的时间用了各种方法终于把评论成无限极了,随便评论,有判断自己不能评论自己,下面先说前台源代码! 要实现的视图 前台源代码html模板 <div class="wen_ ...

  10. 使 用 Jquery 全选+下拉+单选+事件+挂事件

    先引用Jquery代码包 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...