Reputation: 31206
There is an existing question with a similar sounding title. However, it is not quite what I am asking.
I find the following to be a typical use case:
items=Excelsior Shibboleth AbraCadabra
ceremony@%:
foo bar biz baz $*
ritual@%:
ding ring bing bong $*
ceremonies: $(foreach item,$(items),ceremony@$(item))
rituals: $(foreach item,$(items),ritual@$(item))
all: ceremonies | rituals
However, many of the ceremonies
and rituals
are time consuming and may be undesirable. Also, make
is most likely to be adopted and used when commands autocomplete and the file is not large.
What I want to do is dynamically define all the ritual and ceremony commands for the pre-defined items:
# pseudo code -- doesn't work in GNU Make 3.82 (my lowest version compatibility req)
$(foreach item,$(items),$(item)@ritual: ritual@$(item))
So that when you trigger tab completion, the itemized commands appear. And it will keep the makefile from getting too bulky.
Is this possible?
And the dual or "Y" problem is: if I have a wildcard rule, is it possible to generate some relevant matched rule results for display during tab completion in zsh/bash?
Upvotes: 0
Views: 55
Reputation: 100836
You can make the code work using the eval
function. Change this:
$(foreach item,$(items),$(item)@ritual: ritual@$(item))
to this:
$(foreach item,$(items),$(eval $(item)@ritual: ritual@$(item)))
Without that, the result of this foreach
expansion will be:
Excelsior@ritual: ritual@Excelsior Shibboleth@ritual ritual@Shibboleth AbraCadabra@ritual: ritual@AbraCadabra
which is clearly not a legal make statement.
Just to note, there is no such release as GNU make "3.8". I don't know what release you might have.
Upvotes: 1