内核 makefile 中 ?= 的含义是什么?

What's the meaning of ?= in a kernel makefile?

我已经开始学习构建外部 Linux 内核模块,并且在 kbuild (here) 的文档示例中,我遇到了

KDIR ?= /lib/modules/$(shell uname -r)/build

然后用于

make -C $(KDIR) M=$(PWD)

并将目录设置为内核源代码。现在,那个 ?= 运算符的含义是什么? Google 什么都没给我!那是条件分配吗?有点像,"define variable as follows unless it already exists in the environment"?

谢谢!

在 makefile 中,仅当 KDIR 还没有时才设置值。

来自GNU make documentation on "How to Use Variables"

This is called a conditional variable assignment operator