I am trying to parse some Makefile files to read some configs them them and I encountered a wide range of expressions like:
AAA := Some, text
BBB_NAME := @AAA@ (c)
CCC = value
DDD = Some other $(CCC) xxx
I would like to know if all of these are valid and what if there is any difference between them (so I can properly parse them).
They are all valid, as you can tell by putting them in a Makefile and running it. If you want to know what values they actually take, you can try
(Note that the only real problem is with the
(c)inBBB_NAME, it can cause problems if you pass it into other functions.)The one tricky part is the difference between
=and:=(and other assignment operators). Full details are in the manual, but basically:=evaluates the right-hand side at once, while=holds off until the left-hand side is evaluated somewhere. ConsiderThe value of
DDDis nowSome other value xxx, while the value of EEE isSome other $(CCC) xxx. If you use them somewhere:Make expands
$(DDD)and$(EEE)to the same thing and you seeBut there are differences: