What is ?= in Makefile

前端 未结 2 1224
梦毁少年i
梦毁少年i 2021-02-02 05:10
KDIR ?= $(shell uname -r)

What is the meaning of ?=?

I have understood the difference between :=, += and

2条回答
  •  有刺的猬
    2021-02-02 05:39

    ?= indicates to set the KDIR variable only if it's not set/doesn't have a value.

    For example:

    KDIR ?= "foo"
    KDIR ?= "bar"
    
    test:
        echo $(KDIR)
    

    Would print "foo"

    GNU manual: http://www.gnu.org/software/make/manual/html_node/Setting.html

提交回复
热议问题