Clean up configure.ac

Move things around to make more sense order-wise
Make postgres and sqlite support less dodgy
Enable some checks that were disabled for testing
Hopefully solve the dependency issues on cross/chroot builds