makefile generation with gcc

Dima Sorkin
Sun Jan 1 11:39:00 GMT 2006

 This change of gcc4 vs gcc3 makes some problems for me:
  gcc3: with -MM -MP: missing header files are ignored.
  gcc4: with -MM -MP:  if some header file not found - it results in error.
           with -MM -MP -MG: all names of missing headers are written as is.

  I want to auto-generate dependencies between my header-files.
Some of my header files include headers from external libraries of huge size
(for example "BOOST C++ lib").

gcc4 -MM -MP:
1)  If I give to gcc4 only the paths to my headers' locations (with -I option),
it does not find headers from external libs, which results in error.

 I tried the "gcc4 -MM -MP -MG", but there is another problem:
2) gcc4 adds phony targets for missing headers too. When running "make",
"make" does not find these targets (as they are also not on it's path),
so it decides to update them (by empty rule). This, on each "make" invocation,
results in recompilation of the whole project, as "missing" headers become
more "updated" then all real targets in makefile.

3) If I give to gcc4 also the paths to external libs headers, everything
works just fine. But it results into huge dependency lists - tens of kilobytes
and more per ".o" target, as it writes amounts of "external" headers into the

Is there a way to cause gcc4 ignore missing headers like the gcc3 did?
Or other solution ?

Thank you,

More information about the Gcc-help mailing list