其实,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. 对ThreadLocal实现原理的一点思考

    前言 在<透彻理解Spring事务设计思想之手写实现>中,已经向大家揭示了Spring就是利用ThreadLocal来实现一个线程中的Connection是同一个,从而保证了事务.本篇博客 ...

  2. rand()产生随机数 及其和clock()的不同

    rand()使用 首先我们要对rand&srand有个总体的看法:srand初始化随机种子,rand产生随机数. 定义函数 : int rand(void) 函数说明 :因为rand的内部实现 ...

  3. IOS开发之Core Location

    IOS 支持三种检测当前位置的方式:手机基站.Wi-Fi.和GPS,其中GPS是经度最高的,同时也是最耗费手机电量的.一般情况下在室内是无法通过GPS获 取位置信息的,通过Wi-Fi获取位置的原理是通 ...

  4. GNU Binutils简介及基本用法

    [时间:2017-06] [状态:Open] [关键词:GNU, binutils, as, ld, ar, 基础工具,linux,链接器,汇编器] 0 简介 GNU Binary Utilities ...

  5. MobaXterm 加装cygwin软件包

    上次在<MobaXterm: SSH/X远程客户端, Xmanager的最佳免费替代品>里面介绍了MobaXterm这个Windows上的便携 多合一unix工具箱,它基于Cygwin,集 ...

  6. 前端项目微金所1 - bootstrap模板,Compatible(兼容),Viewport(视口),条件注释,第三方依赖,MediaQuery媒体查询

    前端项目微金所笔记1 基础的bootstrap模板 <!DOCTYPE html> <html lang="en"> <head> <me ...

  7. js中如何把字符串转化为对象、数组示例代码

    很明显是一个对象,但如何把文本转为对象呢.使用eval();注意一定要加括号,否则会转换失败 把文本转化为对象 var test='{ colkey: "col", colsinf ...

  8. 牛客网_Go语言相关练习_判断&选择题(4)

    题目来源于牛客网 一.判断题 成员变量或者函数的首字母表示是否对外部可见. switch后面的声明语句和表达式语句都是可以选择的.例如: //可以什么都不加 switch: break; 错误指的是可 ...

  9. Ubuntu下Apache虚拟主机+反向代理

    反向代理 就是通过一台代理服务器,让Internet用户可以访问到内部网络上的服务器 下图中192.168.0.4 可以理解带有2个网卡,一个是公网ip,一个是192.168.0.4 代理内外中的2个 ...

  10. duilib进阶教程 -- 在MFC中使用duilib (1)

    由于入门教程的反响还不错,因此Alberl就以直播的形式来写<进阶教程>啦,本教程的前提: 1.请先阅读<仿迅雷播放器教程> 2.要有一定的duilib基础,如果还没,请先阅读 ...