Rewrite makefile to be efficient