Add FreeBSD support
Add FreeBSD to build
Add thread support for FreeBSD