Fix build script.

Bugs:
* "git checkout"  didn't work because of line ending in "git rev-parse" output.
* protobuf build not triggered even when needed.
* "git rev-parse" triggered before "git clone" is executed.

Other:
* Add --clean switch.
* Rename --skip-source to --skip-setup because it is not just downloading.
* Use fixed upstream version of protobuf.
* Remove dead code.