Use Rebar to manage and compile dependencies and optionally compile Zotonic

This is the same pull request as https://github.com/zotonic/zotonic/pull/503

but with all commits squashed and applied on top of the current master branch (for easier comparison and to avoid any conflicts).

This change adds management of Zotonic dependencies with Rebar and optionally allows to compile Zotonic with Rebar (see discussion in the other pull request).

If this pull request is to be integrated, the other one can be safely closed.