Add initial OpenBSD support.

Based on the work of @buzzdeee, but without conflicts with changes in master