Makefile restructured to build according to dependencies.