Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile: difference between := and ::= assignment operators

Gnu Makefile shows two symbols for immediate expansion, as follows:

immediate := immediate
immediate ::= immediate

Is there a difference between these two?

reference: gnu makefile manual section 3.7

like image 225
Lavya Avatar asked Aug 18 '15 00:08

Lavya


People also ask

What does := mean in a makefile?

":=" is for defining simply expanded variable, which is expanded once and for all.

What is the difference between the and := operator?

= operator assigns a value either as a part of the SET statement or as a part of the SET clause in an UPDATE statement, in any other case = operator is interpreted as a comparison operator. On the other hand, := operator assigns a value and it is never interpreted as a comparison operator.

Whats the difference between := and in go?

In Go, := is for declaration + assignment, whereas = is for assignment only. For example, var foo int = 10 is the same as foo := 10 .


1 Answers

From section 6.2:

Simply expanded variables are defined by lines using ‘:=’ or ‘::=’ (see Setting Variables). Both forms are equivalent in GNU make; however only the ‘::=’ form is described by the POSIX standard (support for ‘::=’ was added to the POSIX standard in 2012, so older versions of make won’t accept this form either).

like image 60
Beta Avatar answered Nov 29 '22 19:11

Beta