diff --git a/src/sbbs3/Common.gmake b/src/sbbs3/Common.gmake
index 008145ec9eb27ecd57b49e75e7892e96a4794762..6990041d9e3f6551393a8be4cf51a579ea47490b 100644
--- a/src/sbbs3/Common.gmake
+++ b/src/sbbs3/Common.gmake
@@ -15,13 +15,13 @@ else
  JS_CFLAGS += -I$(XPDEV)../../include/mozilla/js
 endif
 ifndef JSLIBDIR
- JSLIBDIR := $(XPDEV)../../lib/mozilla/js/$(os).$(BUILD)
+ JSLIBDIR := $(XPDEV)../../lib/mozilla/js/$(machine).$(BUILD)
 endif
 ifndef JSLIB
  JSLIB	:=	js
 endif
 ifndef NSPRDIR
- NSPRDIR := $(XPDEV)../../lib/mozilla/nspr/$(os).$(BUILD)
+ NSPRDIR := $(XPDEV)../../lib/mozilla/nspr/$(machine).$(BUILD)
 endif
 JS_LDFLAGS += -L$(JSLIBDIR) -l$(JSLIB)
 #The following is needed for nspr support on Linux
diff --git a/src/sbbs3/GNUmakefile b/src/sbbs3/GNUmakefile
index 0dd5f82f06539cc1fa4e2318e1e8e94559cfbf82..e220f15fe13de3773df49cf5707a34412c4ee1cc 100644
--- a/src/sbbs3/GNUmakefile
+++ b/src/sbbs3/GNUmakefile
@@ -43,7 +43,10 @@ CFLAGS  +=  -I$(XPDEV)
 CFLAGS	+=  $(UIFC_CFLAGS)
 
 ifndef bcc
- LDFLAGS	+=	-lm -lutil
+ LDFLAGS	+=	-lm
+ ifneq ($(os),sunos)
+  LDFLAGS	+=	-lutil
+ endif
 endif
 
 ifeq ($(os),sunos)    # Solaris
@@ -80,6 +83,7 @@ $(SBBSLIB) : $(SBBS)
 	$(QUIET)touch -- '$(SBBSLIB)'
 
 ifneq ($(os),darwin)
+ifneq ($(os),sunos)
 SBBSLDFLAGS	:=	$(LDFLAGS) -rpath-link ./$(LIBODIR) -rpath ./ 
 #LDFLAGS		+=	-Wl,-rpath-link,./$(LIBODIR),-rpath,./
 LDFLAGS		+=	-Xlinker -rpath
@@ -93,6 +97,7 @@ LDFLAGS		+=	-Xlinker -rpath-link
 LDFLAGS		+=	-Xlinker $(NSPRDIR)
 endif
 endif
+endif
 
 CON_OBJS	= $(LIBODIR)/sbbscon.o $(LIBODIR)/conwrap.o \
 		  $(LIBODIR)/sbbs_ini.o
diff --git a/src/sbbs3/install/GNUmakefile b/src/sbbs3/install/GNUmakefile
index de2666540bf77035cc7bfc93bb0cfa4765b6171f..c192a314d0a10cbcd954efab44fef745d0d94985 100644
--- a/src/sbbs3/install/GNUmakefile
+++ b/src/sbbs3/install/GNUmakefile
@@ -17,17 +17,23 @@
 #USE_CURSES	=	1	# Curses version of UIFC
 #USE_FLTK	=	1	# Windowed version of UIFC
 USE_UIFC32	:=	1	# New 32-bit version of UIFC
-UIFC	=	../../uifc/
+UIFC_SRC	=	../../uifc/
 XPDEV	=	../../xpdev/
 
 NEED_UIFC	:=	1
 include $(XPDEV)/Common.gmake
-include $(UIFC)/Common.gmake
+include $(UIFC_SRC)/Common.gmake
+
+CFLAGS	+=	-I../
 
 ifdef STATIC
  LDFLAGS	+=	-static
 endif
 
+ifeq ($(os),sunos)
+ LDFLAGS	+=	-lsocket -lnsl
+endif
+
 $(SBBSINST): $(OBJS)
    ifdef USE_DIALOG
 	$(QUIET)$(MAKE) --no-print-directory -C ../../libdialog
diff --git a/src/sbbs3/install/objects.mk b/src/sbbs3/install/objects.mk
index 2fe65f1377fd8ac5ca2851ab9674f87953cb362b..989f9c6e88fc98ab6ca08bf8ee25761497a30c37 100644
--- a/src/sbbs3/install/objects.mk
+++ b/src/sbbs3/install/objects.mk
@@ -12,4 +12,5 @@ OBJS	=	$(LIBODIR)$(SLASH)sbbsinst.$(OFILE)\
 			$(LIBODIR)$(SLASH)genwrap.$(OFILE)\
 			$(LIBODIR)$(SLASH)dirwrap.$(OFILE)\
 			$(LIBODIR)$(SLASH)filewrap.$(OFILE)\
-			$(LIBODIR)$(SLASH)httpio.$(OFILE)
+			$(LIBODIR)$(SLASH)httpio.$(OFILE)\
+			$(LIBODIR)$(SLASH)uifcx.$(OFILE)
diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp
index fd2d6f5469381cdcedbeca373c9e97c516c0990b..c5fd9e5829287bc109a938a6c3b20b91fe56a7b6 100644
--- a/src/sbbs3/main.cpp
+++ b/src/sbbs3/main.cpp
@@ -41,6 +41,10 @@
 
 #ifdef __unix__
 	#include <sys/un.h>
+	#ifndef SUN_LEN
+		#define SUN_LEN(su) \
+	        (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
+	#endif
 #endif
 
 //---------------------------------------------------------------------------
@@ -4004,7 +4008,7 @@ void DLLCALL bbs_thread(void* arg)
 
 #ifdef __unix__	//	unix-domain spy sockets
 	for(i=first_node;i<=last_node;i++)  {
-	    if((uspy_listen_socket[i-1]=socket(PF_LOCAL,SOCK_STREAM,0))==INVALID_SOCKET)
+	    if((uspy_listen_socket[i-1]=socket(PF_UNIX,SOCK_STREAM,0))==INVALID_SOCKET)
 	        lprintf(LOG_ERR,"Node %d !ERROR %d creating local spy socket"
 	            , i, errno);
 	    else {
@@ -4013,7 +4017,7 @@ void DLLCALL bbs_thread(void* arg)
 	            startup->socket_open(startup->cbdata,TRUE);
 	    }
 	
-	    uspy_addr.sun_family=AF_LOCAL;
+	    uspy_addr.sun_family=AF_UNIX;
 	    if((unsigned int)snprintf(str,sizeof(uspy_addr.sun_path),
 	            "%slocalspy%d.sock", startup->temp_dir, i)
 	            >=sizeof(uspy_addr.sun_path))
diff --git a/src/sbbs3/sbbs.h b/src/sbbs3/sbbs.h
index b2164b07fc9614a5eef88c478b48fdd1a19cd24b..9a3762d528a54bf222b2cdc3825663f062d99c0d 100644
--- a/src/sbbs3/sbbs.h
+++ b/src/sbbs3/sbbs.h
@@ -1024,6 +1024,11 @@ BOOL 	md(char *path);
 	/* file.cpp */
 	BOOL	filematch(char *filename, char *filespec);
 
+	/* sbbscon.c */
+	#if defined(__unix__) && defined(NEEDS_DAEMON)
+	int daemon(int nochdir, int noclose);
+	#endif
+
 #endif /* SBBS */
 
 extern const char* wday[];	/* abbreviated weekday names */
diff --git a/src/sbbs3/xtrn.cpp b/src/sbbs3/xtrn.cpp
index 82157c4bb0543a8cf0465b9de947efa6a5ad01d0..855bd555110fde03b48ca4efcfb1d75e47b6e8cc 100644
--- a/src/sbbs3/xtrn.cpp
+++ b/src/sbbs3/xtrn.cpp
@@ -68,45 +68,100 @@
 
 	#include <termios.h>
 
-#if defined(__QNX__)
-	/*
-	 * Control Character Defaults
-	 */
+/*
+ * Control Character Defaults
+ */
+#ifndef CTRL
 	#define CTRL(x)	(x&037)
+#endif
+#ifndef CEOF
 	#define	CEOF		CTRL('d')
+#endif
+#ifndef CEOL
 	#define	CEOL		0xff		/* XXX avoid _POSIX_VDISABLE */
+#endif
+#ifndef CERASE
 	#define	CERASE		0177
+#endif
+#ifndef CERASE2
 	#define	CERASE2		CTRL('h')
+#endif
+#ifndef CINTR
 	#define	CINTR		CTRL('c')
+#endif
+#ifndef CSTATUS
 	#define	CSTATUS		CTRL('t')
+#endif
+#ifndef CKILL
 	#define	CKILL		CTRL('u')
+#endif
+#ifndef CMIN
 	#define	CMIN		1
+#endif
+#ifndef CQUIT
 	#define	CQUIT		034		/* FS, ^\ */
+#endif
+#ifndef CSUSP
 	#define	CSUSP		CTRL('z')
+#endif
+#ifndef CTIME
 	#define	CTIME		0
+#endif
+#ifndef CDSUSP
 	#define	CDSUSP		CTRL('y')
+#endif
+#ifndef CSTART
 	#define	CSTART		CTRL('q')
+#endif
+#ifndef CSTOP
 	#define	CSTOP		CTRL('s')
+#endif
+#ifndef CLNEXT
 	#define	CLNEXT		CTRL('v')
+#endif
+#ifndef CDISCARD
 	#define	CDISCARD 	CTRL('o')
+#endif
+#ifndef CWERASE
 	#define	CWERASE 	CTRL('w')
+#endif
+#ifndef CREPRINT
 	#define	CREPRINT 	CTRL('r')
+#endif
+#ifndef CEOT
 	#define	CEOT		CEOF
-	/* compat */
+#endif
+/* compat */
+#ifndef CBRK
 	#define	CBRK		CEOL
+#endif
+#ifndef CRPRNT
 	#define CRPRNT		CREPRINT
+#endif
+#ifndef CFLUSH
 	#define	CFLUSH		CDISCARD
 #endif
 
-#if defined(__solaris__) || defined(__QNX__)
+#ifndef TTYDEF_IFLAG
 	#define TTYDEF_IFLAG    (BRKINT | ICRNL | IMAXBEL | IXON | IXANY)
+#endif
+#ifndef TTYDEF_OFLAG
 	#define TTYDEF_OFLAG    (OPOST | ONLCR)
+#endif
+#ifndef TTYDEF_LFLAG
 	#define TTYDEF_LFLAG    (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL)
+#endif
+#ifndef TTYDEF_CFLAG
 	#define TTYDEF_CFLAG    (CREAD | CS8 | HUPCL)
+#endif
+#if defined(__QNX__) || defined(__solaris__)
 	static cc_t     ttydefchars[NCCS] = {
         CEOF,   CEOL,   CEOL,   CERASE, CWERASE, CKILL, CREPRINT,
         CERASE2, CINTR, CQUIT,  CSUSP,  CDSUSP, CSTART, CSTOP,  CLNEXT,
-        CDISCARD, CMIN, CTIME,  CSTATUS, _POSIX_VDISABLE
+        CDISCARD, CMIN, CTIME,  CSTATUS
+#ifndef __solaris__
+	, _POSIX_VDISABLE
+#endif
 	};
 #endif
 
@@ -1004,6 +1059,35 @@ BYTE* lf_expand(BYTE* inbuf, ulong inlen, BYTE* outbuf, ulong& newlen)
 
 #define MAX_ARGS 1000
 
+#ifdef NEEDS_SETENV
+static int setenv(const char *name, const char *value, int overwrite)
+{
+	char *envstr;
+	char *oldenv;
+	if(overwrite || getenv(name)==NULL) {
+		envstr=(char *)malloc(strlen(name)+strlen(value)+2);
+		if(envstr==NULL) {
+			errno=ENOMEM;
+			return(-1);
+		}
+		putenv(envstr);
+	}
+	return(0);
+}
+#endif
+
+#ifdef NEEDS_CFMAKERAW
+void
+cfmakeraw(struct termios *t)
+{
+	t->c_iflag &= ~(IMAXBEL|IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+	t->c_oflag &= ~OPOST;
+	t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+	t->c_cflag &= ~(CSIZE|PARENB);
+	t->c_cflag |= CS8;
+}
+#endif
+
 #ifdef NEEDS_FORKPTY
 static int login_tty(int fd)
 {