The compiler generates dependency information for precompiled-header files when you specify -xpch=collect. You need to create the appropriate rules in your make files to take advantage of these dependencies. Consider this sample make file:
%.o : %.c shared.cpch $(CC) -xpch=use:shared -xpchstop=foo.h -c $< default : a.out foo.o + shared.cpch : foo.c $(CC) -xpch=collect:shared -xpchstop=foo.h foo.c -c a.out : foo.o bar.o foobar.o $(CC) foo.o bar.o foobar.o clean : rm -f *.o shared.cpch .make.state a.out |
These make rules, along with the dependencies generated by the compiler, force a manually created precompiled- header file to be recreated if any source file you used with -xpch=collect, or any of the headers that are part of the precompiled-header file, have changed. This prevents the use of an out of date precompiled-header file.
You do not have to create any additional make rules in your makefiles for -xpch=auto or -xpch=autofirst.