原帖由 ljoolj 于 2006-3-24 14:04 发表
明白了,gcc 里面 -O2 -O0 可以同时存在
最后一个有效是这个意思吧。
那可以直接在Makefile里面改,不用在/etc/mk.conf改,这样改影响面太大了。
原帖由 congli 于 2006-3-24 15:22 发表
呵~awk还可以这样用.真有趣!
原帖由 雨丝风片 于 2006-3-24 15:46 发表
俺也是现学现用,纯属为了练习awk,
原帖由 雨丝风片 于 2006-3-24 15:16 发表
刚才看了一下讲awk的书以及我们前段时间翻译的《FreeBSD系统编程》中的make部分,找出了另外一个挺有意思的解决办法:
在你自己的Makefile文件的开头加上这样两句话:
[code]TMP_CFLAGS = $(CFLAGS)
CFLAGS != awk 'BEGIN {"echo $(TMP_CFLAGS)" | getline ; sub("-O2", "") ; print $0}'
原帖由 ljoolj 于 2006-3-24 16:14 发表
刚才测试过了,虽然多敲几个字,不过感觉巧妙一些哈:)
原帖由 gvim 于 2006-3-24 16:41 发表
pmake 有这个功能阿。在man make : variable modifiers那里
${CFLAGS:C/-O./-O0/:u}
不过不知道是不是只能pmake这样搞。
我记得gmake有替换函数。
6.3.1 Substitution References
A substitution reference substitutes the value of a variable with alterations that you specify. It has the form `$(var:a=b)' (or `${var:a=b}') and its meaning is to take the value of the variable var, replace every a at the end of a word with b in that value, and substitute the resulting string.
When we say "at the end of a word", we mean that a must appear either followed by whitespace or at the end of the value in order to be replaced; other occurrences of a in the value are unaltered. For example:
foo := a.o b.o c.o
bar := $(foo:.o=.c)
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |