rewrite build script as Makefile