--- Makefile.orig	2016-06-20 12:38:29 UTC
+++ Makefile
@@ -0,0 +1,4 @@
+
+SUBDIR= lib apps
+
+.include <bsd.subdir.mk>
--- apps/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/Makefile
@@ -0,0 +1,6 @@
+
+SUBDIR= atodtst counter coupler fish gethumd memutil mweather shaapp \
+	swtsngl temp tstfind
+
+.include <bsd.subdir.mk>
+
--- apps/atodtst/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/atodtst/Makefile
@@ -0,0 +1,15 @@
+PROG=		atodtst
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/counter/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/counter/Makefile
@@ -0,0 +1,15 @@
+PROG=		counter
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/coupler/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/coupler/Makefile
@@ -0,0 +1,15 @@
+PROG=		coupler
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/fish/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/fish/Makefile
@@ -0,0 +1,15 @@
+PROG=		fish
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/gethumd/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/gethumd/Makefile
@@ -0,0 +1,15 @@
+PROG=		gethumd
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/memutil/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/memutil/Makefile
@@ -0,0 +1,15 @@
+PROG=		memutil
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/mweather/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/mweather/Makefile
@@ -0,0 +1,15 @@
+PROG=		mweather
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/shaapp/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/shaapp/Makefile
@@ -0,0 +1,15 @@
+PROG=		shaapp
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/swtloop/Makefile.app.orig	2016-06-20 12:38:29 UTC
+++ apps/swtloop/Makefile.app
@@ -0,0 +1,8 @@
+PROG=		tstfind
+CFLAGS=         -I. -Wall -I ../../common
+LDFLAGS=	-L ../../common -L ../../lib/userial
+LDADD=		-lmlanser -lmlancom 
+MAN=
+SRCS=           tstfind.c
+
+.include	<bsd.prog.mk>
--- apps/swtsngl/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/swtsngl/Makefile
@@ -0,0 +1,15 @@
+PROG=		swtsngl
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/temp/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/temp/Makefile
@@ -0,0 +1,15 @@
+PROG=		temp
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- apps/thermo/Makefile.app.orig	2016-06-20 12:38:29 UTC
+++ apps/thermo/Makefile.app
@@ -0,0 +1,8 @@
+PROG=		tstfind
+CFLAGS=         -I. -Wall -I ../../common
+LDFLAGS=	-L ../../common -L ../../lib/userial
+LDADD=		-lmlanser -lmlancom 
+MAN=
+SRCS=           tstfind.c
+
+.include	<bsd.prog.mk>
--- apps/tstfind/Makefile.orig	2016-06-20 12:38:29 UTC
+++ apps/tstfind/Makefile
@@ -0,0 +1,15 @@
+PROG=		tstfind
+PREFIX?=	/usr/local
+BINDIR=		${PREFIX}/bin
+MLANCOM=	${.CURDIR}/../../common
+MLANLIB=	${.CURDIR}/../../lib/userial
+CFLAGS=         -I. -Wall -I${MLANCOM}
+LDADD=		-L${MLANLIB} -lmlan
+DPADD=		${MLANLIB}/libmlan.a
+MAN=
+SRCS=           ${PROG}.c
+
+test:		${PROG}
+		./${PROG} /dev/cuaa0
+
+.include	<bsd.prog.mk>
--- common/ownet.h.orig	2016-06-20 12:38:29 UTC
+++ common/ownet.h
@@ -133,6 +133,10 @@
          typedef unsigned short ushort;
          typedef unsigned long  ulong;
       #endif
+      #if (__FreeBSD__)
+         #include <sys/types.h>
+         typedef unsigned long  ulong;
+      #endif
    #endif
    #ifdef SDCC
       //intent of ushort is 2 bytes unsigned.
--- lib/Makefile.orig	2016-06-20 12:38:29 UTC
+++ lib/Makefile
@@ -0,0 +1,3 @@
+SUBDIR= userial
+
+.include <bsd.subdir.mk>
--- lib/userial/Link/linuxlnk.c.orig	2016-06-20 12:38:29 UTC
+++ lib/userial/Link/linuxlnk.c
@@ -93,6 +93,7 @@
 #include <termios.h>
 #include <errno.h>
 #include <sys/time.h>
+#include <string.h>
 
 #include "ds2480.h"
 #include "ownet.h"
--- lib/userial/Makefile.orig	2016-06-20 12:38:29 UTC
+++ lib/userial/Makefile
@@ -0,0 +1,33 @@
+MLANCOM=	${.CURDIR}/../../common
+MLANLNK=	${.CURDIR}/Link
+LIB=		mlan
+CFLAGS=		-I. -Wall -I${MLANCOM}
+MK_PROFILE=	no
+PREFIX?=	/usr/local
+LIBDIR=		${PREFIX}/lib
+
+
+.PATH: ${MLANCOM} ${MLANLNK}
+
+SRCS=	ds2480ut.c owllu.c ownetu.c owsesu.c owtrnu.c 
+
+SRCS+=	linuxlnk.c
+
+SRCS+=	ad26.c atod20.c cnt1d.c \
+	crcutil.c findtype.c ibsha33o.c \
+	ioutil.c mbappreg.c mbee.c \
+	mbeprom.c mbnv.c mbnvcrc.c \
+	mbscr.c mbscrcrc.c mbscree.c \
+	mbscrex.c mbsha.c mbshaee.c \
+	owcache.c owerr.c owfile.c \
+	owpgrw.c owprgm.c rawmem.c \
+	screenio.c sha18.c sha33.c \
+	shadebit.c shadebitvm.c shaibutton.c \
+	swt05.c swt12.c swt1f.c \
+	temp10.c thermo21.c weather.c
+
+beforeinstall:
+	${INSTALL} ${COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
+		${_INSTALLFLAGS} ${MLANCOM}/ownet.h ${DESTDIR}/${PREFIX}/include
+
+.include <bsd.lib.mk>
