91

Possible Duplicate:
What is the difference between the GNU Makefile variable assignments =, ?=, := and +=?

I only know very basic makefile syntax, and was reading through another project's makefile and came across := for macro declaration. Why would they use that?

In other words, is there any difference between

MYMACRO = hi i'm a macro

and

MYMACRO := hi i'm a macro

?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
Aaron Yodaiken
  • 19,163
  • 32
  • 103
  • 184
  • 3
    http://stackoverflow.com/questions/448910/makefile-variable-assignment – cnicutar Jun 08 '11 at 18:20
  • 1
    see in particular http://www.gnu.org/software/make/manual/make.html#Flavors – Alexandre C. Jun 08 '11 at 18:20
  • 1
    So there is no difference in the examples of the question, but there would be if MYMACRO used another macro and the value of the other macro could change while the makefile is being processed. – simpleuser Oct 21 '14 at 22:36
  • 1
    @cnicutar `'info' is not recognized as an internal or external command, operable program or batch file.` – BrainSlugs83 Jul 11 '19 at 01:30

1 Answers1

129

Variables defined with := in GNU make are expanded when they are defined rather than when they are used.

sverre
  • 6,768
  • 2
  • 27
  • 35