Set destination order

Consider this Makefile with GNU Make (replace the spaces in front of @echothe tab):

BAR := outside

foo:
    @echo $(FOO)

foo: BAR := inside
foo: FOO := $(BAR)

.PHONY: foo

Output signal inside. If I change the order of the two targets, I get outside. This makes me think that the target variables are assigned in the order in which they are written.

Is this documented? In other words, can I rely on him? The behavior makes sense, but I cannot find mention of this in the docs.

The closest thing I can find is:

As with automatic variables, these values ​​are available only in the context of the target recipe (and in other targets). 1

, , , .

- , - 800 , , , , ( SDK ) . , , LDFLAGS , . , , .

+4
2

, , , , , , , .

..

foo: BAR := inside
foo: FOO := $(BAR)

BAR := inside
FOO := $(BAR)

, BAR foo, , foo.

+1

, - , - ,

+1

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


All Articles