next up previous
Next: Dependency rules Up: A sample makefile and Previous: Macro definitions

Special $ commands

One line of the sample makefile illustrates two special commands that make provides through the $ symbol:

OBJ = $(addsuffix .o, $(basename $(SRC)))

This particular line sets OBJ to be the same as SRC but with all the .cc suffixes replaced with .o. The part $(basename $(SRC)) strips all the .cc's off all the file names, and the $(addsuffix .o, ...) adds the .o to what's left. This is useful because you can easily add a new class to your project by adding its .cc filename to the definition of SRC. Its object file will automatically be added to OBJ. Having a list of all source and object files is quite useful, as you'll soon see.

Fri Jan 24 17:04:25 EST 1997