next up previous
Next: Special $ commands Up: A sample makefile and Previous: Comments

Macro definitions

In a makefile, it is very easy to define a macro, or text-substitution:

BASEDIR = /afs/

Whenever you type $(BASEDIR) in the makefile, make will substitute in the text contained in the macro BASEDIR. One really useful thing about macros is that they can reference other macros:

TLIB = $(BASEDIR)/libtapestry.a

The trick is that make doesn't substitute for BASEDIR immediately when you define TLIB. Instead, when you reference TLIB, it expands into $(BASEDIR)/libtapestry.a which, since it still has a $ in it, expands into /afs/ Therefore, you can define macros in any order, as long as they are defined before they are actually expanded.

Fri Jan 24 17:04:25 EST 1997