[skill][makefile] makefile 常用内容记录

其实,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 的隐式命令,就被取消了。

时间: 2024-08-30 00:23:41

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

django-xadmin常用内容记录

自定义菜单名称: 1 修改app下的 apps.py文件 添加 class OperationConfig(AppConfig): name = 'operation' verbose_name = '用户操作' 2 修改app下的 __init__.py文件 添加 default_app_config = "operation.apps.OperationConfig" 添加自定义主题: 任选app 在adminx.py 中添加: from xadmin import views c

linux中Makefile文件相关内容

第一章.概述什么是makefile?或许很多Winodws的程序员都不知道这个东西,因为那些Windows的IDE都为你做了这个工作,但我觉得要作一个好的和professional(专业)的程序员,makefile还是要懂.这就好像现在有这么多的HTML的编辑器,但如果你想成为一个专业人士,你还是要了解HTML的标识的含义.特别在Unix下的软件编译,你就不能不自己写makefile了,会不会写makefile,从一个侧面说明了一个人是否具备完成大型工程的能力.因为,makefile关系到了整个

makefile、gdb使用记录

makefile的模板 all: rover server station rover: rover.c tcputil.o gcc rover.c tcputil.o -o rover -lpthread server: server.c tcputil.o gcc server.c tcputil.o -o server -lpthread station:station.c tcputil.o gcc station.c tcputil.o -o station -lpthread tcp

Perl常用语法记录

Perl常用语法记录 ##包的切换和调用其它包的方式 #package A; #my $a=10; #package B; #print $A::a; #print $a;     ##local局部标识符的使用 #$aa=20; #{ # local $aa; # $aa=10; # print "$aa \n"; # #} #print $aa; ##别名的使用 =comment $b=10; $a=1; $c=200; { local *b; *b=*a; $b=20; prin

WPF DataGrid常用属性记录

WPF DataGrid常用属性记录 组件常用方法: BeginEdit:使DataGrid进入编辑状态. CancelEdit:取消DataGrid的编辑状态. CollapseRowGroup:闭合DataGrid的行分组. CommitEdit:确认DataGrid的编辑完成. ExpandRowGroup:展开DataGrid的行分组. GetGroupFromItem:从具体Item中得到分组. ScrollIntoView:滚动DataGrid视图. 组件常用属性: Alternat

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

前端常用功能记录(二)—datatables表格 并不是所有的后台开发都有美工和前端工程师来配合做页面,为了显示数据并有一定的美感,jQuery的DataTables插件对于像我这样的前端菜鸟来说真是雪中送炭,当然对于专业的前端开发者来说它更是锦上添花!DataTables提供了针对表格的排序.浏览器分页.服务器分页.筛选.格式化.统计等强大功能. 工作中对程序员的学习模式才深有体会,不是从入门到精通,而是从会用到了解.对于我来说,基本都是拿到一个知识先做个东西出来,再来细细品味个中的细节,然后

Cs231n课堂内容记录-Lecture3

Lecture 3 课程内容记录:(上)https://zhuanlan.zhihu.com/p/20918580?refer=intelligentunit (中)https://zhuanlan.zhihu.com/p/20945670?refer=intelligentunit (下)https://zhuanlan.zhihu.com/p/21102293?refer=intelligentunit 1.线性分类器(linear classifer): 我们总是希望得到一个函数f(x,w

AIX LVM 常用命令记录

针对物理卷的操作指令 lsdev--列出ODM中的设备 chdev--修改一个AIX设备的属性 mkdev--创建一个AIX设备 chpv--修改物理卷的状态和属性 lspv--查看AIX中物理卷的相关信息 migratepv--将一个物理卷中的物理分区(数据)迁移到另一个物理卷   针对卷组的操作指令 mkvg--创建新卷组 extendvg--扩展vg reducevg--缩小vg chvg--修改卷组的属性 lsvg--查看卷组的相关信息 importvg--导入vg到AIX系统中 exp

android布局常用属性记录

android布局常用属性记录 27. 三 / android基础 / 没有评论 http://blog.csdn.net/xn4545945/article/details/7717086这里有一部分别人总结的其余的: align:对齐 parent:容器 bottom:底部 alignparentbottom:是否显示在容器底部. 值为true 或者 false android:layout_alignParentBottom=”true” android:gravity=”top” htt