Fixed makefile issues

Added automatic generation of obj and bin directories.

This commit also fixes an issue where makefiles would refer to a
library that did no longer exist.