其实,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. 基于mindwave脑电波进行疲劳检测算法的设计(4)

    上一次的实验做到可以从pc端读取到MindWave传输过来的脑电波原始数据了. 我是先定义一个结构体,该结构体对应保存所有能从硬件中取到的原始数据. struct FD_DATA { int batt ...

  2. Nginx-rtmp 直播媒体实时流实现

    0. 前言 这段时间在搭建一个IPCamera项目服务器.视频点对点通话,客户端会查看设备端的音视频实时流.为了省流量,是通过P2P进行穿透.但是由于NAT设备的原因和IPV4的枯竭.有些设备是无法进 ...

  3. 【ARM】arm系列知识框架

    [ARM编程模型] 硬件: 电路原理图 软件: 体系结构, 指令集, 寄存器组 [ARM编程技术] 汇编/C语言 编译, 链接, 烧写和调试 windows: MDK linux  : gcc [AR ...

  4. java框架篇---hibernate之session状态

    Session接口是Hibernate向程序提供操纵数据库的最主要接口,是单线程对象,它提供了基本的保存.更新.删除和查询方法.它有一个缓存,保存了持久化对象,当清理缓存时,按照这些持久化对象同步更新 ...

  5. [工具类] 读取解析json文件

    读取json文件并转换为字符串 /** * 通过本地文件访问json并读取 * * @param path:json文件路径 * @return:json文件的内容 */ public static ...

  6. Linux磁盘概念及其管理工具fdisk

    Linux磁盘概念及其管理工具fdisk [日期:2016-08-27] 来源:Linux社区  作者:chawan [字体:大 中 小]   引言:冯诺依曼体系中的数据存储器就是我们常说的磁盘或硬盘 ...

  7. C语言的标准库和系统调用

    http://blog.csdn.net/yusiguyuan/article/details/23181327 Linux系统调用这部分经常出现两个词:libc库和封装函数,不知道你是否清楚它们的含 ...

  8. Docker - Docker中搭建MySQL主从

    1.pull完centos7纯净版的镜像后,创建容器,然后将宿主机上下载的MySQL文件 (MySQL下载地址:http://mysql.mirror.kangaroot.net/Downloads/ ...

  9. linux log

    adb shell logcat GOODIX:v *:s cat /proc/kmsg | grep "<<" ./cbootimg.sh adb shell get ...

  10. [Linux] 修改系统默认编码

    locale 命令 locale 命令用以设置程序运行的语言环境. locale 设置语言环境的命名规则为 Language_area.charset,例如 en_US.utf8 表示语言为英语,地区 ...