On Fri May 30 02:58:17 2014, invalid.nore...@gnu.org (Brent Baccala) wrote: > Follow-up Comment #15, bug #30381 (project make): > > I support this feature. > > I just tried to write a makefile that implicitly generates output files from > XML control files, that contain references to other files in the XML. What I > wanted was this: > > > define futurebases > $(shell xmllint --xpath "print(//futurebase/@filename)" $(1)) > endef > > .SECONDEXPANSION: > > %.htb: %.xml $$(call futurebases, %.xml) > $(HOFFMAN) -g $< > > > It doesn't work.
I don't think this is related. My -M patch supports using the same rule multiple times on a path when traversing the dependency graph. It takes the graph for granted, it just traverses more paths in it. What you need to do is determine the dependency graph dynamically. The problem is not how to traverse it, but how to construct it. This happens before the graph is traversed. My patch won't help you. Apparently, you have a command that, given an *.xml file, lists the dependencies of a corresponding *.htb file. You are trying to list these dependencies in the rule for making the *.htb file, so you can use them in the recipe. I think your basic approach is correct: with .SECONDEXPANSION, you *can* expand a list of dependencies on a per-target basis. However, some problems remain in the code above: 1) Your recipe uses $<, that is, the first dependency only. Is your list always 1 long? If not, use $+ instead. Besides, $< is the *.xml file; I don't think you want to use that to create the *.htb file. 2) The %.xml argument to your call will just be %.xml. I've never used .SECONDEXPANSION, but judging by the manual http://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html I think you need to use $< here instead. I'm not sure if you have the right escapes to make everything expand at the right time. Specifically, you need a way to ensure the xmllint command is only invoked during the secondary expansion. This is above my head but it should be possible in principle. However you still end up with rules that contain *.xml dependencies that really aren't dependencies of the targets, but of the command used to list the dependencies. I think I'd take a different approach: generate the rules as a first phase. There are two basic approaches to doing this: A) Using $(eval): write a macro that generates a whole rule, then $(eval) a $(call) of that maccro for each of your *,xml files. B) Write a rule that generates a 1-rule makefile from a *.xml file using a regular recipe. That 1 rule creates the *.htb file from its dependencies. Then in your regular makefile either include all of those rules or invoke them with $(MAKE) -f. > Reply to this item at: > > <http://savannah.gnu.org/bugs/?30381> > > _______________________________________________ > Message sent via/by Savannah > http://savannah.gnu.org/ -- Reinier Post TU Eindhoven _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make