Jeff Saremi
Jeff Saremi

Reputation: 3024

make: The scope of SECONDEXPANSION

What is the scope of secondary expansion in a makefile?

If i type:

.SECONDEXPANSION:

Where does this change stop? Does it apply to the all targets from that point onward? or only up until the next target?

Upvotes: 2

Views: 199

Answers (1)

Beta
Beta

Reputation: 99144

It applies to all targets from then on. From the docs:

...All the prerequisites of the targets defined after the special target are expanded a second time.

And if you doubt the documentation, you can try it. Modifying an examples from the docs:

.SECONDEXPANSION:
main_OBJS := main.o try.o test.o
lib_OBJS := lib.o api.o

main: $$($$@_OBJS)
    @echo prerequisites are $^

lib: $$($$@_OBJS)
    @echo prerequisites are $^

Upvotes: 3

Related Questions