对 makefile 中 二次扩展的一点理解

看例子:

.SECONDEXPANSION:

ONE=onefile
TWO=twofile

myfile: $(ONE)  $$(TWO)
    echo "myfile"

onefile:
    echo "onefile"

twofile:
    echo "twofile"

执行结果:

onefile

twofile

myfile

如果把 .SECONDEXPANSION: 一行去掉:

#.SECONDEXPANSION:

ONE=onefile
TWO=twofile

myfile: $(ONE)  $$(TWO)
    echo "myfile"

onefile:
    echo "onefile"

twofile:
    echo "twofile"

运行时显示:

make: *** No rule to make target '$(TWO)', needed by 'myfile'. Stop.

这基本说明了 .SECONDEXPANSION: 的作用。

posted @ 2012-09-17 12:45  健哥的数据花园  阅读(1290)  评论(0编辑  收藏  举报