refactoring Makefile using template
handle special condition