读书时间 2011/12/28

来源:互联网 发布:阿里云视频直播教程 编辑:程序博客网 时间:2024/05/24 16:16


《Linux C Programming》华清


Chap 5, Make

* 参数

-n:模拟执行(或者make --just-print)

-s:执行,但不显示命令(silent? YES!,相当于make --silent)

-v:版本

-p:显示所有var及内部rule


* make文件主要内容

显式规则

隐式规则:推导

变量定义

文件指示

    #include

   #ifdef

   多行命令

注释


* 多目标

例:

bigoutput littleoutput: text.g

generate text.g -$(subst output,,$@) >; $@

等于

bigoutput:text.g

generate text.g -big >; bigoutput

                                    ^ what's this ?

littleoutput:text.g

generate text.g -little >; littleoutput


* 自动依赖关系生成

gcc -MM *.c

Q:why not working ?

[root@frank chap5]# gcc -MM hello-make.c
hello-make.o: hello-make.c
[root@frank chap5]# gcc -M hello-make.c
hello-make.c:2:16: 错误:my.h:没有那个文件或目录
[root@frank chap5]# gcc -MM hello-make.c
hello-make.o: hello-make.c
[root@frank chap5]#

Q:How to use it in big project ?


* 忽略合令错误

a) exec:

     - cd /home/test         #进入/home/test目录,忽略错误

    pwd

b) make -i 或 mkae --ignore-errors

c) make -k或 make --keep-going


* 一些比较独特的key words

override ???

define 


* 函数

$(<function> <arguments>)

${<function> <arguments>}


* 常用函数

subst

findstring

sort

dir/notdir

suffix/basename

join

foreach

    $(foreach <var>, <list>, <text>

    例:

    name := a b c d

    files := $(foreach n, $(name), $(n).o)

    结果:

    $(files) = a.o b.o c.o d.o

ifXXX

call  ??? How to use it ???


原创粉丝点击