What is the difference between := and += in make file?

linux, makefile, unix

Solution

:= (Simply Expanded Variable ) The value is scanned for once and for all expanding any references to other variables and functions, when variable is defined. e.g. `x:=foo` `y:=$(x) bar` `x:=later` so above is equivalent to `y:=foo bar` `x:=later`

+= is used for appending more text to variables e.g. `objects=main.o foo.o bar.o` `objects+=new.o` which will set objects to 'main.o foo.o bar.o new.o'

= is for recursively expanded variable.The value is install verbatim; if it contains reference to other variables these variables are expanded whenever this variable is substituted.And this is known as recursive expansion.

Problem

what is working difference in the below statements? ``` LDDIRS := -L$(ORACLE_LIB) LDDIRS += -L$(ORACLE_LIB) ```

Original source

Related problems