0

I know what the different type of variable assignments in gnu-make are and what each one does, but I can't seem to think of a situation where I would use ?= over := or use any one particular type of assignment over the other.

Could someone give me a practical example of when I might use one type of assignment over the other?

penguin99
  • 111
  • 4
  • 1
    Have you read about [flavors of variables](https://www.gnu.org/software/make/manual/html_node/Flavors.html)? As for `?=`, it's used default values for a variable if not set from the command line: `make MY_VAR=my_value` – Andreas Jun 17 '22 at 07:59
  • 1
    That's not the case. variables set on the command line will have that value regardless of what type of assignment operator you use: command line variables override values set inside makefiles. `?=` is for setting values that have not already been set, either from the environment or previously in the makefile... not the command line. But I definitely agree, the OP should read the GNU make manual. Trying to learn to use GNU make by jumping from SO question to web "tutorial" is not going to give you a good understanding. – MadScientist Jun 17 '22 at 13:19

0 Answers0