LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   about immediate and deferred variable assignment in GNU make (https://www.linuxquestions.org/questions/programming-9/about-immediate-and-deferred-variable-assignment-in-gnu-make-438310/)

George2 04-24-2006 09:04 AM

about immediate and deferred variable assignment in GNU make
 
Hello everyone,


I have a question about immediate and deferred variable assignment in GNU make. In GNU make manual, it is said,

http://www.gnu.org/software/make/manual/make.html

--------------------
It's important to understand this two-phase approach because it has a direct impact on how variable and function expansion happens; this is often a source of some confusion when writing makefiles. Here we will present a summary of the phases in which expansion happens for different constructs within the makefile. We say that expansion is immediate if it happens during the first phase: in this case make will expand any variables or functions in that section of a construct as the makefile is parsed. We say that expansion is deferred if expansion is not performed immediately. Expansion of deferred construct is not performed until either the construct appears later in an immediate context, or until the second phase.

You may not be familiar with some of these constructs yet. You can reference this section as you become familiar with them, in later chapters.

Variable Assignment
Variable definitions are parsed as follows:

immediate = deferred
immediate ?= deferred
immediate := immediate
immediate += deferred or immediate

define immediate
deferred
endef
--------------------

After reading the above statement several times, I am still confused about what mean immediate assignment and what means deferred assignment. Could anyone show me an example please?

What are the advantages (dis-advantages) of immediate (deferred) assignment?


thanks in advance,
George

ccabanne 07-22-2011 06:55 PM

make immediate vs deferred variable assignment
 
I came here with the same question. An example or pointer to how to get a feel for how make assignment works, would be very helpful.

This was the most useful thread that I could find: http://stackoverflow.com/questions/4...ble-assignment

It seems that evaluating the value right hand side can be done at parse time, or at execution time.


All times are GMT -5. The time now is 12:31 AM.