Build fixes from Gentoo

Hello,

I'd like to propose the attached fixes which we've been applying as part of the Gentoo package.

Alternatively, I would also say that making this use a quick and minimal autotools build system might be make it easier on packagers, and would allow, for instance, the ability to choose a system MD5 implementation instead of bringing the nth copy of it (sigh) in the authentication chain.

HTH,
Diego