Preliminary FreeBSD support

Warning! Breaks Linux support.
Make all BSD-specific stuff conditional