casio1374633

导航

 

gcc -MM 自动生成依赖关系.

比如gcc -MM *.c.

能看到一堆输出.依赖都给你写好.真方便.示例如下:
=========================
casio$ gcc -MM *.c
2.o: 2.c a.h b.h
3.o: 3.c b.h c.h
foo.o: foo.c
import1.o: import1.c
import2.o: import2.c
import3.o: import3.c
main.o: main.c a.h


对应的一个更好的程序是makedepend, 直接添加进Makefile

====================================
patch..打补丁是很常见的事情,下面举例:

file1:
This is file one.
line 2
line 3
There is no line 4; this is line 5.
line 6

file2:
This is file two.
line 2
line 3
line 4
line 5
line 6
a new line 8

===========================
然后执行:diff file1 file2 > diffs
diffs:
1c1
< This is file one.
---
> This is file two.
4c4,5
< There is no line 4; this is line 5.
---
> line 4
> line 5
5a7
> a new line 8
========================
如果要给文件1打补丁变成文件2,则:

patch file1 diffs

这样,文件1就变成文件2一样了.

如果想让文件变回去,则:

patch -R file1 diffs

文件1就变回去了....

----------------------------------------

在处理软件的补丁时,使用 diff -c选项能产生一个基于上下文的diff,即提供每处修改的前后几行内容,这样patch命令可以在打补丁之前验证上下文是否匹配,而补丁文件本身也更容易阅读.

posted on 2013-04-28 09:41  casio1374633  阅读(337)  评论(0编辑  收藏  举报