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.
Merge pull request #5134

6261e6e getblockhash: throw JSONRPCError (not runtime_error) (dexX7)
Merge pull request #5115

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

fa73619 boost: split stream classes out of serialize.h (Cory Fields)
Merge pull request #5086

1723862 build: fix libtool's refusal to link static libs into a dll (Cory Fields)
28d412f build: quit abusing LIBS for Windows builds. (Cory Fields)
Build util and common before building server
Merge pull request #5112

071473c Build util and common before building server (jtimon)
Merge pull request #5121

214091d Update license in pull-tester and rpc-tests (Michael Ford)
MOVEONLY: Move CFeeRate and Amount constants to amount.o
MOVEONLY: Separate CTransaction and dependencies from core
MOVEONLY: separate CTxUndo out of core
MOVEONLY: Move script/compressor out of script and put CTxOutCompressor (from
core) with it
MOVEONLY: core.o -> core/block.o