Question

I'm trying to get a precompiled header to speed up my build using gmake and GCC. The .gch file is created, but for some reason it's automatically removed as soon as the build completes.

Here are the relevant rules:

cxx_pch := ./bin/analysis.h.gch

bin/%.cpp.o: src/%.cpp $(cxx_includes) $(cxx_pch)
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(cxx_include_paths) -H -c -o $@ $<

bin/%.gch: src/pch/%
    $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(cxx_include_paths) -I./src -x c++-header -o $@ $<

The last thing printed when I build is this:

rm bin/analysis.h.gch

None of my rules could possibly do this; clean only does rm -r $(output_dir).

Was it helpful?

Solution

Mark it as .PRECIOUS: or .SECONDARY: to prevent Make from cleaning it up as an intermediate target. See also http://www.gnu.org/software/make/manual/html_node/Special-Targets.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top