Question

I have a Makefile which takes care of downloading a few javascript files needed as a prerequisite for r.js

For each of them I've created a .url file which contains the url where the .js file can be downloaded, and set up a pattern rule like this:

static/js/lib/%.js: jslibsurls/%.url
    curl -L -s -o $@ `cat $<`

but it only downloads a .js file if it is an explicit dependency somewhere in the Makefile...

Is there any way to make the pattern rule to be executed if there's a dependency matching it even if the target is not used yet (they will be used in wildcard once they are created)?

Was it helpful?

Solution

I think I got it, I need to do a patsubst with the names of the .url files to create the .js and use the result as the dependency to a phoney rule that I can then use as dependency for the r.js step.

DOWNLOADED_LIBS+=$(patsubst jslibsurls/%.url,static/js/lib/%.js,$(wildcard jslibsurls/*.url))

download-libs: $(DOWNLOADED_LIBS)

#this downloads a .js in static/js/lib/ file for each .url file in jslibsurls/
static/js/lib/%.js: jslibsurls/%.url
    curl -L -s -o $@ `cat $<`

.PHONY: download-libs
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top