[Bugfix] fix possible fd-leak
[Makefile] Make building more convenient