2011 2-22 Tuesday
来源:互联网 发布:psv破解重构数据库 编辑:程序博客网 时间:2024/06/05 12:24
6, makefile name: GNUmakefile makefile Makefile or
any name you could specified : make -f XXmakefile.name
7, include foo.make *.mk $(bar)
make just expend the makefile content to the position of include xx.make
search path: current directory->-I directory(in command make's argument)
-><prefix>/include (/usr/local/bin or /usr)
if you want make to ignore the makefile didn't exist, add '-' before the
include keyword like: -include
8, env: MAKEFILES, we'd better remove the env. (Strongly recommend)
9, the working step of make
a, read all makefile
b, expend the makefiles which are included
c, initialize the variables in the makefile
d, expend 隐式规则, and analyze all rules
e, build dependency chain of all targets
f, rebuild target depend the relationships
g, make the terminal target.
from a-e is the step one, f-g is the step two. In step one, the make
expend variable in "delay" method.
--------------------------------------------------------------------------------
1, rule grammar
targets : prerequisites
command
or
targets : prerequisites ; command
command
2, 规则中的通配符
共享bash的, 例如: *, ?, ~
make自身支持的, 例如: $?, $<, etc.
3, 文件搜索
如果在当前目录找不到,则到makefile中定义的变量: VPAHT 中找。
VPATH = src:../headers
指定了两个目录:./src和../headers。目录由":"分割。
vpath <pattern> <directories> #为符合模式的文件指定搜索目录
vpath <pattern> #清除符合模式的文件的搜索路径
vpath #清楚所有之前通过vpath设置的模式
<pattern>需要包含 “%”, “%”匹配另个或若干字符
e.g: %.h stand for header file. %.c stand for C source code.
vpath %.h ../headers
vpath %.c ../source
vpath % blish
vpath %.c ../bar
搜索策略是先紧着文件类型来搜,然后再搜通用的目录。如上,搜 .c 文件
就是先搜 ../source, 然后是../bar, 最后搜./blish
4, 伪目标
伪目标并不是一个文件,而是一个标签。
.PHONY : clean
不管是否有这个文件(clean),这个目标就是伪目标。
伪目标的妙用:
######start of makefile#######
all : pg1 pg2 pg3
.PHONY: all
pg1: p.o u.o
pg3: x.o u.o
pg2: y.o u.o
######end of makefile#######
#由于伪目标的特性是,总是被执行 的
######start of makefile#######
.PHONY: cleanall cleanobj cleandiff
cleanall: cleanobj cleandiff
rm pg1 pg2 pg3
cleanobj:
rm *.o
cleandiff:
rm *.diff
######end of makefile#######
<<< subst 函数 $(subst string,substitute,$(variable))
obj= x.o y.o
$(subst .o,.c,$(obj))->x.c, y.c>>>
<<< filter 函数 $(filter <pattern>,$(variable))
var = x.o y.c
$(filter %.o,$(var)) -> x.o
5, 静态模式
<targets ...>: <target-pattern>: <prereq-patterns ...>
<commands>
e.g:
objects = foo.o bar.o
all: $(objects)
#静态模式
$(objects):%.o:%.c
$(CC) -c $(CFLAGS) $< -o $@
P23
- 2011 2-22 Tuesday
- October 22th Tuesday
- September 22th Tuesday 2009
- December 22th Tuesday 2009
- 日记:2010-06-22 Tuesday
- Feb 1, 2011, Tuesday, 9
- Feb 8, 2011, Tuesday, 16
- May 22th Tuesday (五月 二十二日 火曜日)
- 2008 January 22th Tuesday (一月 二十二日 火曜日)
- 2008 April 22th Tuesday (四月 二十二日 火曜日)
- 2008 July 22th Tuesday (七月 二十二日 火曜日)
- 2008 September 2nd Tuesday (九月 二日 火曜日)
- April 2nd Tuesday (四月 二日 木曜日)
- June 2nd Tuesday (六月 二日 火曜日)
- Shrove Tuesday
- Tuesday,October 19,2004
- Tuesday , Sunny, good spirit
- August 4th Tuesday
- CSS hack,CSS简写,CSS定义应注意的几个问题
- JS 和 Java URL 的各自转码
- RHlinux开启PAE
- 下班前找个活跃的irc服务器并通信
- Makefile详解
- 2011 2-22 Tuesday
- 关于宏的理解
- 人生
- sequence parameter sets(转)
- 关于高维数组计算的一些优化
- objective-c 错误记录
- Java动态代理的应用
- 让组件随窗口的扩大而按比例扩大的方法有哪些?
- js获得url参数