Add --disable-wallet option to build system

These changes make it possible to build bitcoind as a node only. If built with --disable-wallet, there is no dependency on BDB.

The commits should be self-explanatory.

No functional changes: only code movements, build system changes and added #ifdefs.

(Depends on #3320)