[skill][makefile] makefile 常用内容记录
其实,makefile有点复杂。
文档看了又看,还是要经常翻,做个记录备忘 :)
与 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.
定义一个空的 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 常用内容记录的更多相关文章
- [skill][git] git 常用操作记录
傻瓜入门: step by step : https://try.github.io/levels/1/challenges/1 一本书: https://git-scm.com/book/en/v2 ...
- django-xadmin常用内容记录
自定义菜单名称: 1 修改app下的 apps.py文件 添加 class OperationConfig(AppConfig): name = 'operation' verbose_name = ...
- WPF DataGrid常用属性记录
WPF DataGrid常用属性记录 组件常用方法: BeginEdit:使DataGrid进入编辑状态. CancelEdit:取消DataGrid的编辑状态. CollapseRowGroup:闭 ...
- Cs231n课堂内容记录-Lecture 3 最优化
Lecture 4 最优化 课程内容记录: (上)https://zhuanlan.zhihu.com/p/21360434?refer=intelligentunit (下)https://zhua ...
- Cs231n课堂内容记录-Lecture2-Part2 线性分类
Lecture 3 课程内容记录:(上)https://zhuanlan.zhihu.com/p/20918580?refer=intelligentunit (中)https://zhuanlan. ...
- 前端常用功能记录(二)—datatables表格(转)
前端常用功能记录(二)—datatables表格 并不是所有的后台开发都有美工和前端工程师来配合做页面,为了显示数据并有一定的美感,jQuery的DataTables插件对于像我这样的前端菜鸟来说真是 ...
- MVC中验证码的实现(经常用,记录备用)
一.目录 1.多层架构+MVC+EF+AUTOFAC+AUTOMAPPER: 2.MVC中验证码的实现(经常用,记录备用) 3.Ligerui首页的快速搭建 二 正文 Ok,我们的验证码开始,这篇文章 ...
- Centos下磁盘管理的常用命令记录(如查找大文件)
Centos下磁盘管理的常用命令记录 查看系统磁盘空间占用,使用命令: df -h 结果: 查看磁盘inode使用情况,如果inode用完了,磁盘就没法写入新的内容了: df -i 结果: 如何查找磁 ...
- android布局常用属性记录
android布局常用属性记录 http://blog.csdn.net/xn4545945/article/details/7717086这里有一部分别人总结的其余的: align:对齐 par ...
随机推荐
- vue.js开发SPA常见问题及解决方法
列表进入详情页的传参问题. 例如商品列表页面前往商品详情页面,需要传一个商品id; <router-link :to="{path: 'detail', query: {id: 1}} ...
- linux source code search
https://elixir.bootlin.com/linux/latest/source/fs/eventpoll.c#L1120
- 【Java】分布式RPC通信框架Apache Thrift 使用总结
简介 Apache Thrift是Facebook开源的跨语言的RPC通信框架,目前已经捐献给Apache基金会管理,由于其跨语言特性和出色的性能,在很多互联网公司得到应用,有能力的公司甚至会基于th ...
- MXNET:监督学习
线性回归 给定一个数据点集合 X 和对应的目标值 y,线性模型的目标就是找到一条使用向量 w 和位移 b 描述的线,来尽可能地近似每个样本X[i] 和 y[i]. 数学公式表示为\(\hat{y}=X ...
- 环回接口---loopback
尽管在网上查了不少资料,但依然未找到全面的解释,最近给县局作岗位认证培时, 忽然间想通了些问题,很多疑问迎刃而解.以下是我对环回地址及环回接口的一些认识,供大家参考交流:一.环回接口为了标识和管理网络 ...
- C语言之单元测试
在ITOO高校云平台项目实践中,我们模板的模块因为在调别人的接口时出现了问题,为了弄明白是不是接口出了问题,就必须学会单元测试. WHAT? 单元测试(unit testing),是指对软件中的最小可 ...
- Ubuntu下搜狗输入法只显示黑框,不显示输入的汉字选项
1. cd ~/.config 2.删除三个文件夹: SogouPY, SogouPY.users, sogou-qimpanel 然后重启输入法
- java.security.ProviderException: java.security.KeyException
本机部署没问题,部署到linux服务器报错: javax.net.ssl.SSLException: java.security.ProviderException: java.security.Ke ...
- c++中SetEvent和ResetEvent的使用
关于事件 事件(Event)是WIN32提供的最灵活的线程间同步方式,事件可以处于激发状态(signaled or true)或未激发状态(unsignal or false).根据状态变迁方式的不同 ...
- Inside The C++ Object Model(一)
============================================================================1-1. 关键字struct和class的一点区 ...