Makefile中=和:=有什么区别

来源:互联网 发布:上海网络广告公司 编辑:程序博客网 时间:2024/05/01 08:48

保存此makefile

#example a = orginal_value

b = $(a)

a = later_value

all:

    @echo $(b)

运行make

#make
later_value

#example

a = orginal_value

b := $(a)

a = later_value

all:

    @echo $(b)

#make
original_value

区别显而易见, := 定义的变量如果值内容本身就是变量,他不会延伸。如果是=,会延伸。所以在使用时,不需要延伸的时候一定要加上: ,防止不可控的情况。

原创粉丝点击