变量介绍
":","#","="," "变量的定义和使用
##变量定义
CC := gcc
TARGET := hello.out
##变量使用
$(TARGET) : func.o main.o
	$(CC) -o $(TARGET) func.o main.o
makefile 中变量的赋值方式
简单赋值(:=)
x := foo
y := $(x)b
x := new
.PHONY : test
test :
        @echo "x => $(x)"
        @echo "y => $(y)"
##执行结果
x => new
y => foob
递归赋值(=)
#code1
x = foo
y = $(x)b
x = new
.PHONY : test
test :
        @echo "x => $(x)"
        @echo "y => $(y)"
#执行结果
x => new
y => newb
#code2
a = $(b) #b还没有被定义,所以a的值为空
b = $(c) #c还没有被定义,所以b的值为空
c = hello-makefile
.PHONY : test
test :
        @echo "a => $(a)"
        @echo "b => $(b)"
        @echo "c => $(c)"
##执行结果
a => hello-makefile
b => hello-makefile
c => hello-makefile
条件赋值(?=)
x := foo
y := $(x)b
x ?= new
.PHONY : test
test :
        @echo "x => $(x)"
        @echo "y => $(y)"
##执行结果
x => foo
y => foob
追加赋值(+=)
x := foo
y := $(x)b
x += $(y)
.PHONY : test
test :
        @echo "x => $(x)"
        @echo "y => $(y)"
##执行结果
x => foo foob
y => foob
原文:https://www.cnblogs.com/bky-hbq/p/13197761.html