Cleanups and robustness for autotooling

This series cleans up autogen.sh and adds support for running autogen.sh from out of tree.  Out-of-tree configure works as well, but unfortunately out-of-tree builds don't because leveldb doesn't support them yet.

This also makes configure's test for miniupnpc more robust (working around a bug observed on my system when trying to build), and simplifies leveldb's clean target a bit.