Here are possible approaches to modifying your make files in order to incorporate -xpch into your builds.
You can use the implicit make rules by using an auxiliary CCFLAGS variable and the KEEP_STATE facility of both make and dmake. The precompiled header is produced as a separate, independent step.
.KEEP_STATE:
CCFLAGS_AUX = -O etc
CCFLAGS = -xpch=use:shared $(CCFLAGS_AUX)
shared.Cpch: foo.cc
$(CCC) -xpch=collect:shared $(CCFLAGS_AUX) foo.cc
a.out: foo.o ping.o pong.o
$(CCC) foo.o ping.o pong.o
|
You can also define your own compilation rule instead of trying to use an auxiliary CCFLAGS.
.KEEP_STATE:
.SUFFIXES: .o .cc
%.o:%.cc shared.Cpch
$(CCC) -xpch=use:shared $(CCFLAGS) -c $<
shared.Cpch: foo.cc
$(CCC) -xpch=collect:shared $(CCFLAGS) foo.cc -xe
a.out: foo.o ping.o pong.o
$(CCC) foo.o ping.o pong.o
|
You can produce the precompiled header as a side effect of regular compilation, and without using KEEP_STATE, but this approach requires explicit compilation commands.
shared.Cpch + foo.o: foo.cc bar.h
$(CCC) -xpch=collect:shared foo.cc $(CCFLAGS) -c
ping.o: ping.cc shared.Cpch bar.h
$(CCC) -xpch=use:shared ping.cc $(CCFLAGS) -c
pong.o: pong.cc shared.Cpch bar.h
$(CCC) -xpch=use:shared pong.cc $(CCFLAGS) -c
a.out: foo.o ping.o pong.o
$(CCC) foo.o ping.o pong.o
|