对 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: 的作用。

原文地址:https://www.cnblogs.com/gaojian/p/2688535.html