Makefile: syntax? =

I have an Intel makefile that has "? =" In it. how

COMPILER ?= $(GCC_PATH)g++ 

But

 EXECUTABLE = run 

What's the difference between? = and = and when do I need to use the first, and not the second?

Many thanks.

+4
source share
2 answers

Quoth excellent documentation :

If you want a variable to be set to a value only if it is not already set, can you use the shorthand operator '? = instead of '=.

+6
source

?= is for conditional assignment, i.e. if it is not yet defined, then only assign the value else to leave it. In your example, if you give make COMPILER=arm-none-gcc , then arm-none-gcc used as a compiler than g ++ by default if you just type make and g ++ as an option for COMPILER. If = used, then COMPILER will be assigned a value when and where assignments are encountered. for more information on files that you can reference Understanding makefile for beginners

0
source

Source: https://habr.com/ru/post/1412566/


All Articles