fix FreeBSD build i.e. apply the patches from FreeBSD ports by Xin LI <delphij@FreeBSD.org>