Improve build system

This PR works on the build system and fixes #273.

Comments are welcome!

regards,
niosHD