refactor makefile into scripts