Add the -MP option to emit phony targets. Since this means each header file has to be visited more than once, change the implementation to use an internal list of all the dependencies, and centralize the emission of the dependency files.