This info copied from: https://vuanhduy.wordpress.com/2014/05/02/the-variants-of-gnu-makefile-assignment-operation/
The differences in =, :=, ?= and += when assigning a macro in Makefile.
- = operation
- HELLO = world
- HELLO_WORLD = $(HELLO) world!
- # This echoes "world world!"
- echo $(HELLO_WORLD)
- HELLO = hello
- # This echoes "hello world!"
- echo $(HELLO_WORLD)
- := operation
- HELLO = world
- HELLO_WORLD := $(HELLO) world!
- # This echoes "world world!"
- echo $(HELLO_WORLD)
- HELLO = hello
- # Still echoes "world world!"
- echo $(HELLO_WORLD)
- HELLO_WORLD := $(HELLO) world!
- # This echoes "hello world!"
- echo $(HELLO_WORLD)
- += operation
- HELLO_WORLD = hello
- HELLO_WORLD += world!
- # This echoes "hello world!"
- echo $(HELLO_WORLD)
- ?= operation
- HELLO_WORLD ?= hello world!
- # This echoes "hello world!"
- echo $(HELLO_WORLD)
- HELLO_WORLD ?= hi world!
- # Still echoes "hello world!"
If the variable does not have a value, the operation assign the value to it
If the variable already had a value, it is replaced.
This value will be expanded when the variable is used.
It is similar to the = operation but the value will be expanded during the assignment.
Similar to the = operation but instead of replacing the value, the value is appended to the current one, with a space in between.
It is similar to the = operation but only if the variable doesn’t have a value.