4 ms·
It's surprising not to see more examples of implicit rules and dependency resolution in this document. Here's a simple example extracted from http://canonical.
by kragen 7y ago
It's surprising not to see more examples of implicit rules and dependency resolution in this document. Here's a simple example extracted from http://canonical.org/~kragen/naturaleza/Makefile http://canonical.org/~kragen/naturaleza/Makefile:
frames=1-80x160.pgm 2-80x160.pgm 3-80x160.pgm 4-80x160.pgm 5-80x160.pgm 6-80x160.pgm 7-80x160.pgm 8-80x160.pgm 9-80x160.pgm
intercalated.pgm: $(frames)
./intercalate.py $(frames) > $@
%.pgm: %.jpg
convert $< $@
%-80x160.jpg: %.jpg
convert -geometry 80x160 -colorspace Gray $< $@
This uses ImageMagick commands to massage the various image files into the desired form without me having to manually invoke the commands image by image. Admittedly, on looking at it, I don't think I got a great deal of dependency-tracking mileage out of make in this case, because the source images weren't actually changing—only the build process was changing, and make doesn't track that (although redo, for example, does.) But in cases where you're dynamically adding new input files, make is super helpful for generating thumbnails or whatever from them. As long as the filenames don't have spaces.
My most immediate work task for the morning is helping a colleague figure out why SCons is failing to build the JNI binding for our project, although the old makefile builds it fine. Sigh.