DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Managing file interactions with make

Output translations

The values of macros are replaced when evaluated. The general form, where brackets indicate that the enclosed sequence is optional, is as follows:

   $(macro[:string1=[string2]])
The parentheses are optional if there is no substitution specification and the macro name is a single character. If a substitution sequence is present, the value of the macro is considered to be a sequence of ``words'' separated by sequences of blanks, tabs, and new-line characters. Then, for each such word that ends with string1, string1 is replaced with string2 (or no characters if string2 is not present).

This particular substitution capability was chosen because make usually concerns itself with suffixes. The usefulness of this type of translation occurs when maintaining archive libraries. Now, all that is necessary is to accumulate the out-of-date members and write a shell script that can handle all the C language programs (that is, files ending in .c). Thus, the following fragment optimizes the executions of make for maintaining an archive library:

   $(LIB): $(LIB)(a.o) $(LIB)(b.o) $(LIB)(c.o)
           $(CC) -c $(CFLAGS) $(?:.o=.c)
           $(AR) $(ARFLAGS) $(LIB) $?
           rm $?

A dependency of the preceding form is necessary for each of the different types of source files (suffixes) that define the archive library. These translations are added in an effort to make more general use of the wealth of information that make generates.


Next topic: Recursive makefiles
Previous topic: Extensions of $*, $@, and $<

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004