Openbsd build

I'm open to suggestions as to how to avoid making the #ifdef chains unbearably long here. At some point NetBSD and DragonFly and probably others will want to add to it...