I'm working on using a Makefile to help perform build steps for my JS in my application. The goal is to use Make's ability to only deal with modified files to prevent extraneous copying and such.
To build the JS you need to
- copy the original .js files from the main dev directory to a build directory
- minimize the copied file and create a -min.js version of the file
- generate a meta.js which has the information on the YUI modules in the built JS files for the combo loader.
So I've been working on the Makefile working backwards. meta.js depends on -min.js which depends on $builddir/b/*.js which is copied from %origdir/*.js
In looking through things it seems I should be able to use %.js in order to catch any matching files, but when I try this out I get:
make: *** No rule to make target `bookie/static/js/build/b/%-min.js', needed by `bookie/static/js/build/b/meta.js'. Stop.
This is what I'm working with, anyone know what I'm doing wrong? I want that when I make js it copies over the changed .js files, minifies them, and then regenerates the meta.js.
# Makefile to help automate tasks in bookie
WD := $(shell pwd)
PY := bin/python
BOOKIE_JS = bookie/static/js/bookie
JS_BUILD_PATH = bookie/static/js/build
JS_META_SCRIPT = $(PY) scripts/js/generate_meta.py
EXTENSION = $(WD)/extensions
CHROME_BUILD = $(EXTENSION)/chrome_ext/lib
# JAVASCRIPT
#
# Javascript tools for building out combo loader build directory, out meta.js,
# and syncing things over to the chrome extension directory.
.PHONY: js
js: $(JS_BUILD_PATH)/b/meta.js
$(JS_BUILD_PATH)/b/meta.js: $(JS_BUILD_PATH)/b/%-min.js
echo "META"
$(JS_META_SCRIPT) -n YUI_MODULES -s $(JS_BUILD_PATH)/b/ \
-o $(JS_BUILD_PATH)/b/meta.js \
-x -min.js$
$(JS_BUILD_PATH)/b/%-min.js: $(JS_BUILD_PATH)/b/$*.js
echo "MIN"
rm $(JS_BUILD_PATH)/b/meta.js || true
scripts/js/jsmin_all.py $(JS_BUILD_PATH)/b
$(JS_BUILD_PATH)/b/%.js: $(BOOKIE_JS)/$*.js
echo "Initial"
cp $? $(JS_BUILD_PATH)/b/
cp $? $(CHROME_BUILD)/
.PHONY: clean_js
clean_js:
rm -rf $(JS_BUILD_PATH)/* || true
$*only works within recipes, not within dependencies, use%there – reinierpost Apr 3 '12 at 8:44$doing there in-min.js$? – reinierpost Apr 3 '12 at 8:46