0

I've started learning about building external Linux kernel modules, and in the documentation examples of kbuild (here) I've come across the line

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

which is then used in

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

and sets the directory to the kernel source. Now, what's the meaing of that ?= operator? Google gives me nothing! Is that a conditional assignment? Sort of, "define variable as follows unless it already exists in the environment"?

Thanks!

jstrange
  • 23
  • 2

1 Answers1

1

In a makefile, this sets the value of KDIR only if it doesn't yet have one.

From the GNU make documentation on "How to Use Variables":

This is called a conditional variable assignment operator

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758