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
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.
Merge pull request #5024 from gavinandresen/osx_sign_fix

Keep symlinks when copying into .app bundle
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)
convert CBufferedFile into a non-refcounted RAII wrapper

- it now takes over the passed file descriptor and calls fclose() in the
  destructor
- this fixes a leak in LoadExternalBlockFile(), where an exception could
  cause the file to not getting closed
- also disallow copies (like recently added for CAutoFile)
update CAutoFile destructor to match CBufferdFile destructor

- also remove 2 explicit CAutoFile::fclose() calls in net.cpp
CBufferedFile: make nType and nVersion private
CAutoFile: make nType, nVersion and file private
(re)add explicit close function to CAutoFile and CBufferedFile