Creating targets from computed variables in make

Here's an example that doesn't work

say-hello := greeting
say-bye := farewell

greeting:
    @echo "Hello"

farewell:
    @echo "Bye"

.SECONDEXPANSION:
%-guvnah: $$(say-$*)
    @echo "Target was: $(say-$*)"

      

Command

make hello-guvnah

      

Should issue

hello
Target was: greeting

      

But only shows

Target was: greeting

      

+3


source to share


1 answer


And this happens if you double-escape $*

the pre-order so that it expands during secondary expansion instead of the first pass:



.SECONDEXPANSION:
%-guvnah: $$(say-$$*)
    @echo "Target was: $(say-$*)"

      

+2


source







All Articles