tags:

views:

320

answers:

1

I would like a rule something like:

build/%.ext: src/%.ext
    action

I have one directory of files in a folder that I want to optimize and then output to a different folder. However, the files have the same name in the input and output folders. I have tried various iterations of the rule above, but make will either always or never rebuild depending how I tweak the above. Suggestions?

EDIT: I ended up with the following solution, which works great!

JS = \
  src/js/script2.js \
  src/js/script1.js

JS_OPT = $(patsubst src/js/%.js,web/js/%.js, $(JS))

all: $(JS_OPT)

$(JS_OPT): web/js/%.js: src/js/%.js
  cat $@ | ./bin/jsmin > $<
+1  A: 

Try somethink like this:

INPUT_FILES = \
  src/a.txt   \
  src/b.txt   \

OPTIMIZED_FILES=$(patsubst src/%.ext,build/%.ext,$(INPUT_FILES))

$(OPTIMIZED_FILES): build/%.ext: src/%.txt
     optimize_command $@ $<
dimba
Make looks at modification times to decide if optimized file should be rebuild.So look at the mod. time of src file and corresponding optimized file time to understand if make should really rebuild the optimized file.Use "stat <file name>" to see modification time in seconds resolution.
dimba
I understand how make works. I haven't modified the source files in hours, and they're still being rebuilt.
Michael Mior
You had it right on. I just made a couple typos. Thanks!
Michael Mior