Refine makefile generation