Do merkle root and txid duplicates check simultaneously

Move the txid duplicates check into BuildMerkleTree, where it can be done
much more efficiently (without needing to build a full txid set to detect
duplicates).

The previous version (using the std::set<uint256> to detect duplicates) was
also slightly too weak. A block mined with actual duplicate transactions
(which is invalid, due to the inputs of the duplicated transactions being
seen as double spends) would trigger the duplicates logic, resulting in the
block not being stored on disk, and rerequested. This change fixes that by
only triggering in the case of duplicated transactions that can actually
result in an identical merkle root.
minor variable init changes in init.cpp

- explicit init of pcoinsdbview and pwalletMain (even if not needed, as
  globals are init to NULL, it seems cleaner)
- remove check if (pwalletMain) in Shutdown() as delete is valid even if
  pwalletMain is NULL
doc: Add instructions for consistent Mac OS X build names
Switch testing framework from MAIN to new UNITTEST network

UNITTEST inherites from MAIN but allows synamically changing its parameters using the ModifiableParams() interface
Suggested corrections on comments, variable names.
Also new test case testing the PoW skip in UNITTEST.
Avoid introducing a virtual into CChainParams

Treat fSkipProofOfWorkCheck the same as other parameters.
Keep symlinks when copying into .app bundle

Code signing failed for me on OSX 10.9.5 because the
Versions/Current symbolic links were being replaced
with a duplicate copy of the frameworks' code.

Releases were bigger than they needed to be, for the
same reason.
When transaction outputs exceed inputs, show the offending amounts so as to aid debugging.
Print input index when signature validation fails, to aid debugging.
travis: If the comparison-tool fails, dump the tail of the debug log

The entire debug log would be huge, and could cause issues for automated tools
like travis. Printing 200 lines is an initial guess at a reasonable number,
more may be required.
Merge pull request #5024 from gavinandresen/osx_sign_fix

Keep symlinks when copying into .app bundle
build: Fix OSX build when using Homebrew and qt5

Qt5 is bottled, so configure won't find it without some help. Use
brew to find out its prefix.

Also, qt5 added the host_bins variable to pkg-config, use it.
build: macdeploy: filter out irrelevant qt5 frameworks and dylibs
Upgrade comparison tool further
Merge pull request #4980

20a11ff minor variable init changes in init.cpp (Philip Kaufmann)
Merge pull request #4926

584a358 Do merkle root and txid duplicates check simultaneously (Pieter Wuille)
Merge pull request #5027

0f78a0a Upgrade comparison tool further (Pieter Wuille)
Merge pull request #5017

f74fc9b Print input index when signature validation fails, to aid debugging. (Mark Friedenbach)
217a5c9 When transaction outputs exceed inputs, show the offending amounts so as to aid debugging. (Mark Friedenbach)
Merge pull request #5025

5ad450a travis: If the comparison-tool fails, dump the tail of the debug log (Cory Fields)
Merge pull request #4845

4705902 Avoid introducing a virtual into CChainParams (Wladimir J. van der Laan)
5e2e7fc Suggested corrections on comments, variable names. Also new test case testing the PoW skip in UNITTEST. (SergioDemianLerner)
a25fd6b Switch testing framework from MAIN to new UNITTEST network (SergioDemianLerner)