Rewrite the Makefile to support automatic dependencies