Better Makefile.

Now it is able to decide which files are need to be rebuilt.