3
votes

I'm using a couple boost libraries and using the rule below to generate automatic dependencies. I think boost headers really slow down the compilation because without the dependency includes in the Makefile, it is abour 10 times faster to compile the project. Is there a way to increase the speed with generated dependencies?

%.o: %.cc
  $(CXX) $(CFLAGS) $(INCLUDES) -MD -c $< -o $@
  @mv $*.d .deps/
  @cp .deps/$*.d .deps/$*.tmp
  @sed -e 's;#.*;;' -e 's;^[^:]*: *;;' -e 's; *\\$$;;' \
    -e '/^$$/d' -e 's;$$; :;' < .deps/$*.tmp >> .deps/$*.d
  @rm .deps/$*.tmp
1
As you are likely not going to change the boost headers, there is no reason, that you add them as dependencies. So you could look for a way to exclude the boost headers (and maybe other system headers too). - Torsten Robitzki
(Deleted my answer, as I realized that it didn't really pertain your specific question). Personally, I wrote a custom Python script that scans my src in < 1 second and writes a very plain (no * rules, or dependency generation by GCC) Makefile. - Oleg2718281828
I did the same in ruby to generate dependency files for my rake build. It simply omits all includes in <> brackets. - Torsten Robitzki

1 Answers

2
votes

As you are likely not going to change the boost headers, there is no reason, that you add them as dependencies. By using -MMD to generate the dependency files, system headers should be ignored and thus your dependency files should get smaller, this means make have to scan less of your hard drive to see if files are still up to date etc. Of course you have to include the headers with <> not "".