Huge makefile refactoring