refactoring Makefile using template