How does Makefile know that a file changed and then recompile it?

makefile, programming-languages

Solution

It looks at the file time-stamp - simple as that. If a dependency is newer that the target, the target is rebuilt.

Problem

Just out of curiosity, how does Makefile know that a file changed (and then recompile it)? Is it up to `make`? Is it up to the compiler? If so, is it language dependent?

Original source