3 ms·
Make has no way by itself to know what headers a c file needs. It would need to parse c code to do that. C files typically compile independently and then get
by vimax 6y ago
Make has no way by itself to know what headers a c file needs. It would need to parse c code to do that. C files typically compile independently and then get linked together, so there are no dependencies between c files the make needs to know about when compiling the object files. The only dependencies make knows about are what you tell it.
Gcc does parse your c files and knows which headers are needed. It can print out a list of headers used to compile a c file to an object, and prints it out in make syntax.
You can add a short auto-dependency rule that creates and includes your header dependencies automatically.
Look up make auto-dependencies.