FreeBSD support

This is enough to build and test on FreeBSD.

NetBSD should be the same but untested.