Add support for FreeBSD.

This is a mildly debugged first attempt: there are likely bugs.  Be aware.