build: quit abusing LIBS for Windows builds.

Similar to the INCLUDES changes in 6b099402b40, split out LIBS into individual
entries for more fine-grained control.

Also add MINIUPNPC_LIBS which was missing before, and hook it up to
executables.
build: fix libtool's refusal to link static libs into a dll
rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo`

This fixes an iterator leak resulting in

    bitcoind: db/version_set.cc:789: leveldb::VersionSet::~VersionSet(): Assertion `dummy_versions_.next_ == &dummy_versions_' failed."

exception on shutdown.

Also make sure to flush pcoinsTip before calling GetStats() to make
sure we apply them to the current height.
boost: split stream classes out of serialize.h

serialization now has no dependencies.
Update license in pull-tester and rpc-tests

Add missing copyright/license header where necessary
Make CBlockIndex* returned by GetDepthInMainChain const.

Make the CBlockIndex* (optionally) returned by GetDepthInMainChain
const.  This prevents accidental modification.  The result is for
reading its properties rather than modifying it.
getblockhash: throw JSONRPCError (not runtime_error)
Start with tidier cache directories

Remove more files from the cached, 200-block-chain data directories.
Update comments in chain to be doxygen compatible
Update comments in chainparams to be doxygen compatible
Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2)
Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4)

Also use the new flag as a standard rule, and replace the IsCanonicalPush
standardness check with it (as it is more complete).
Improve CScriptNum() comment

Edited-by: Pieter Wuille <pieter.wuille@gmail.com>
Ensure MINIMALDATA invalid tests can only fail one way

Removes the need for the 'negated' versions of the tests, and ensures
other failures don't mask what we're trying to test.
Test every numeric-accepting opcode for correct handling of the numeric minimal encoding rule
Clearly separate PUSHDATA and numeric argument MINIMALDATA tests
Add valid invert of invalid every numeric opcode tests
Merge pull request #5134

6261e6e getblockhash: throw JSONRPCError (not runtime_error) (dexX7)
Enable customising node policy for datacarrier data size with a -datacarriersize option
Merge pull request #5115

33dfbf5 rpc: Fix leveldb iterator leak, and flush before `gettxoutsetinfo` (Wladimir J. van der Laan)