Misc build cleanups

Needed on Ubuntu Trusty 14.04.1

There are also a couple of tweaks to prevent the build log from containing nonzero return codes when testing if a library exists.