refactor and simplify Makefile