免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1461 | 回复: 0
打印 上一主题 下一主题

Solaris上的makefile [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-12-30 10:10 |只看该作者 |倒序浏览
(欢迎转载,转载请注明出处--chley)
Solaris上的make与其它Unix或GNU make都有所不同,特别是在定义和使用Macro时。
make(1S)
target: something to create or update
dependency: something that a target depends on.
rule: a list of commands, can be explicit or implicit(supplied by make)
调用make命令,无参数时,make会检查makefile中每个target的dependency,如果某个target
file不存在或者比dependency旧,则rebuild it。
如果一个target在makefile中没有entry,或者它的entry没有rule,make会试图使用下述方法寻找一个合适的rule:
1)模式匹配规则
2)implicit
rule:可以是用户提供的makefile定义的,也可以是标准的潜规则(/usr/share/lib/make/make.rules)。
3)SCCS retrieval
4)  rule from .DEFAULT entry.
target format:
target [:|::] [dependency] ... [;command] ...
          [command]
          ...
注:1)target可以是一个name,也可以是一列空格分开的name
       2)dependency可以是一个,也可以是多个
       3)dependency可以用;结束,后跟一个Bourn shell command.
       4)在rule中的command都必须以tab开始,并且必须是Bourn shell command. 可以用 \
转义跨越多行,但是每一行的开始都必须是TAB
%:模式匹配通配符,与shell中的*类似。
Macro:
基本格式
macro=value
=  定义一个macro
$() ${}  引用一个macro
+=   appends a string to a macro definition(两边必须有空格)
:=    条件赋值
:sh =   Define the value of a macro to be the output of  a  command
macro中的替代:
$(name:string1=string2)  $name中的string1会被string2代替。
$(name:op%os=np%ns) $name中的所有匹配op%os的字符串会被np%ns代替,例如
PROGRAM=fabricate
DEBUG= $(PROGRAM:%=tmp/%-g)  --
$(PROGRAM)中的所有字符串会被tmp/fabricate-g代替,从而DEBUG得到的就是tmp/fabricate-g
Dynamic Macros:
$*   basename of the current target
$<   name  of  a  dependency  file
$@  name of the current target
$?    The list of dependencies that are  newer  than  the target.  
$%   name of the  library  member  being  processed
Conditional Macro Definitions:
target-list := macro = value
表示在处理target
list中的target及其dependency时,macro使用这里给出的value,而不是其它地方可能已经定义的value。
target-list := macro += value
使用这种格式时,表示在处理target-list中的target时,暂时把valueappend到macro中。
Rules:
+   make总会执行这条命令,即使在命令行使用了 -n
@  在执行之前,不打印这条命令
Pattern Matching Rule:
tp%ts:dp%ds
       rule
tp is a target  prefix,ts  is a target suffix. dp is a dependency
prefix, and ds is a dependency suffix(any of which  can  be  null).
Suffix Rules:
DsTs: rule
Ts is the suffix of the target, Ds is  the  suffix  of the  dependency
file.
To refer to a shell variable, use a double-dollar-sign ($$).
命令替换:
MACRO:sh =command -- MACRO的value是command的输出,如 POUND_SIGN:sh=  echo \\043
$(MACRO:sh) -- 在sh中执行MACRO,并捕获输出,如:REAL_CC=  $(CW_CC_CMD:sh)
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/24393/showart_223506.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP