FreeBSD-specific build fixes

I fixed up the build on FreeBSD, mostly (ab)using the already-existing Mac OS X bits.