Refactor auto Makefiles