Reputation: 739
I would love to use template dependency of the following form
data/%/ld.data :: data/%/%LD.jsn
Now, only the first percent sign in dependency data/%/%LD.jsn
is replaced by the directory from the target, as specified in the GNUmake manual
Is there any simple way to get the desired functionality, that is to specify that all files of the form data/Folder/ld.data depend on the corresponding file data/Folder/FolderLD.data.
I can build rules with loop but this requires specifying all the relevant folders in advance and editing makefile when new folder is added (or finding them dynamically at makefile start)
Upvotes: 1
Views: 96
Reputation: 100956
Yes, there is a much simpler way; use automatic variables during second expansion (this is really what second expansion was originally created to allow):
.SECONDEXPANSION:
data/%/ld.data : data/$$*/$$*LD.jsn
actions
Upvotes: 4
Reputation: 739
One solution I have adapted from http://bitofahack.com/post/1406231094 goes like this
.SECONDEXPANSION:
data/%/ld.data: LANGNAME=$(notdir $(patsubst %/,%,$(dir $@)))
data/%/ld.data: LDFILE=data/$(LANGNAME)/$(LANGNAME)LD.jsn
data/%/ld.data: $$(LDFILE)
actions
But this looks cumbersome, to say nothing about the crazy way $(notdir ...)
and $(dir ...)
cannot work together
Upvotes: 0