Sun WorkShop TeamWare 2.1 User's Guide

Restricting Parallelism

Sometimes file collisions cannot be avoided in a makefile. An example is xstr(1), which extracts strings from a C program to implement shared strings. The xstr command writes the modified C program to the fixed file x.c and appends the strings to the fixed file strings. Since xstr must be run over each C file, the following new .c.o rule is commonly defined:


.c.o:
	$(CC) $(CPPFLAGS) -E $*.c | xstr -c - 
	$(CC) $(CFLAGS) $(TARGET_ARCH) -c x.c
	mv x.o $*.o

The dmake utility cannot concurrently build targets using this rule since the build of each target writes to the same x.c and strings files. Nor is it possible to change the files used. You can use the special target .NO_PARALLEL: to tell dmake not to build these targets concurrently. For example, if the objects being built using the .c.o rule were defined by the OBJECTS macro, the following entry would force dmake to build those targets serially:

.NO_PARALLEL: $(OBJECTS) 

If most of the objects must be built serially, it is easier and safer to force all objects to default to serial processing by including the .NO_PARALLEL: target without any dependents. Any targets that can be built in parallel can be listed as dependencies of the .PARALLEL: target:


.NO_PARALLEL:
.PARALLEL: $(LIB_OBJECT)