refactor Makefiles (closes #3536)