diff -Nurd aplus-fsf-4.22.orig/Makefile.am aplus-fsf-4.22/Makefile.am
--- aplus-fsf-4.22.orig/Makefile.am	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/Makefile.am	2018-02-28 11:20:38.000000000 -0500
@@ -13,3 +13,4 @@
 
 SUBDIRS = config src
 
+ACLOCAL_AMFLAGS = -I config
diff -Nurd aplus-fsf-4.22.orig/configure.in aplus-fsf-4.22/configure.in
--- aplus-fsf-4.22.orig/configure.in	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/configure.in	2018-02-28 13:56:52.000000000 -0500
@@ -4,9 +4,11 @@
 dnl See .../src/LICENSE for terms of distribution. 
 
 
-AC_INIT(src/dap/BcdPack.c)
+AC_INIT([aplus-fsf], [4.22])
+AC_CONFIG_SRCDIR([src/dap/BcdPack.c])
 AC_CONFIG_AUX_DIR(config)
-AM_INIT_AUTOMAKE(aplus-fsf,4.22)
+AC_CONFIG_MACRO_DIRS([config])
+AM_INIT_AUTOMAKE
 AM_MAINTAINER_MODE
 AC_PREREQ([2.50])
 
diff -Nurd aplus-fsf-4.22.orig/src/AplusGUI/AplusApplication.C aplus-fsf-4.22/src/AplusGUI/AplusApplication.C
--- aplus-fsf-4.22.orig/src/AplusGUI/AplusApplication.C	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/AplusGUI/AplusApplication.C	2018-02-28 03:03:57.000000000 -0500
@@ -1,3 +1,4 @@
+#include <CoreServices/CoreServices.h>
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Copyright (c) 1997-2008 Morgan Stanley All rights reserved.
diff -Nurd aplus-fsf-4.22.orig/src/AplusGUI/Makefile.am aplus-fsf-4.22/src/AplusGUI/Makefile.am
--- aplus-fsf-4.22.orig/src/AplusGUI/Makefile.am	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/AplusGUI/Makefile.am	2018-02-28 08:29:38.000000000 -0500
@@ -125,5 +125,5 @@
 	EnumTables.H\
 	Macros.H
 
-INCLUDES = -I.. -I/usr/X11R6/include
+INCLUDES = -I.. $(X_INCLUDES)
 
diff -Nurd aplus-fsf-4.22.orig/src/AplusGUI/Makefile.in aplus-fsf-4.22/src/AplusGUI/Makefile.in
--- aplus-fsf-4.22.orig/src/AplusGUI/Makefile.in	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/AplusGUI/Makefile.in	2018-02-28 04:16:49.000000000 -0500
@@ -210,7 +210,7 @@
 	Macros.H
 
 
-INCLUDES = -I.. -I/usr/X11R6/include
+INCLUDES = -I.. $(X_INCLUDES)
 subdir = src/AplusGUI
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_CLEAN_FILES =
diff -Nurd aplus-fsf-4.22.orig/src/IPC/IPCInterface.C aplus-fsf-4.22/src/IPC/IPCInterface.C
--- aplus-fsf-4.22.orig/src/IPC/IPCInterface.C	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/IPC/IPCInterface.C	2018-02-28 14:00:27.000000000 -0500
@@ -6,6 +6,7 @@
 //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <main/version.h>
 #include <dap/Warn.h>
 #include <dap/balloc.h>
 #include <a/f.h>
@@ -605,7 +606,7 @@
     
     if ((atree = getenv("ATREE")) == (char *)(0))
     {
-      atree = "/usr/local/a+";
+      atree = IMDIR;
     }
     ipcfile = bnstring(atree, "/lib/idap.+", (char *)(0));
     loadafile(ipcfile,0);
diff -Nurd aplus-fsf-4.22.orig/src/MSGUI/MSGraphUI.C aplus-fsf-4.22/src/MSGUI/MSGraphUI.C
--- aplus-fsf-4.22.orig/src/MSGUI/MSGraphUI.C	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/MSGUI/MSGraphUI.C	2018-02-28 03:02:03.000000000 -0500
@@ -1493,7 +1493,7 @@
       {
         xs=trace->xAxis();
         ys=trace->yAxis();
-        if(trace->style()!=MSG::Text&&trace->dataCount()>1&&trace->legend()>0)
+        if(trace->style()!=MSG::Text&&trace->dataCount()>1&&trace->legend()>(void*)0)
          {
            if (setX==MSFalse) 
             {
diff -Nurd aplus-fsf-4.22.orig/src/MSGUI/Makefile.am aplus-fsf-4.22/src/MSGUI/Makefile.am
--- aplus-fsf-4.22.orig/src/MSGUI/Makefile.am	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/MSGUI/Makefile.am	2018-02-28 08:29:28.000000000 -0500
@@ -400,5 +400,5 @@
 	MSTreeView.C\
 	MSTypeEntryField.C
 
-INCLUDES = -I.. -I/usr/X11R6/include
+INCLUDES = -I.. $(X_INCLUDES)
 
diff -Nurd aplus-fsf-4.22.orig/src/MSGUI/Makefile.in aplus-fsf-4.22/src/MSGUI/Makefile.in
--- aplus-fsf-4.22.orig/src/MSGUI/Makefile.in	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/MSGUI/Makefile.in	2018-02-28 04:17:49.000000000 -0500
@@ -486,7 +486,7 @@
 	MSTypeEntryField.C
 
 
-INCLUDES = -I.. -I/usr/X11R6/include
+INCLUDES = -I.. $(X_INCLUDES)
 subdir = src/MSGUI
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
 CONFIG_CLEAN_FILES =
diff -Nurd aplus-fsf-4.22.orig/src/MSTypes/MSBinaryMatrix.C aplus-fsf-4.22/src/MSTypes/MSBinaryMatrix.C
--- aplus-fsf-4.22.orig/src/MSTypes/MSBinaryMatrix.C	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/MSTypes/MSBinaryMatrix.C	2018-02-28 03:02:03.000000000 -0500
@@ -832,7 +832,7 @@
      unsigned char *dp=d->elements();
      unsigned char *mp=aBinaryMatrix_.data();
      unsigned char *row=aBinaryMatrix_.data()+aBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do
 	 {
@@ -842,7 +842,7 @@
       }
      mp=bBinaryMatrix_.data();
      row=bBinaryMatrix_.data()+bBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do
 	 {
@@ -869,7 +869,7 @@
      unsigned char *dp=d->elements();
      unsigned char *mp=data();
      unsigned char *row=data()+columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do
 	 {
@@ -879,7 +879,7 @@
       }
      mp=aBinaryMatrix_.data();
      row=aBinaryMatrix_.data()+aBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
         do
          {
@@ -917,7 +917,7 @@
      unsigned char *dp=d->elements();
      unsigned char *mp=aBinaryMatrix_.data();
      unsigned char *row=aBinaryMatrix_.data()+aBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do 
 	 {
@@ -929,7 +929,7 @@
      dp=d->elements()+aBinaryMatrix_.columns();
      mp=bBinaryMatrix_.data();
      row=bBinaryMatrix_.data()+bBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do
 	 {
@@ -957,7 +957,7 @@
      unsigned char *dp=d->elements();
      unsigned char *mp=data();
      unsigned char *row=data()+columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do 
 	 {
@@ -969,7 +969,7 @@
      dp=d->elements()+columns();
      mp=aBinaryMatrix_.data();
      row=aBinaryMatrix_.data()+aBinaryMatrix_.columns();
-     if (mp>0)
+     if (mp>(void*)0)
       {
 	do
 	 {
diff -Nurd aplus-fsf-4.22.orig/src/MSTypes/MSFloatMatrix.H aplus-fsf-4.22/src/MSTypes/MSFloatMatrix.H
--- aplus-fsf-4.22.orig/src/MSTypes/MSFloatMatrix.H	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/MSTypes/MSFloatMatrix.H	2018-02-28 03:02:03.000000000 -0500
@@ -27,7 +27,7 @@
 template<class Type> class MSMatrixSTypePick; // MSTypeMatrix indexed by an unsigned int
 
 #if !defined(MS_NO_PREDECLARE_SPECIALIZATION)
-class MSMatrixSTypePick<double>; 
+template<> class MSMatrixSTypePick<double>; 
 #endif
 
 
@@ -206,7 +206,7 @@
   friend MSTypesExport MSTypeMatrix<double> allElementsDo(const MSTypeMatrix<double>&,MathFunction);
   friend MSTypesExport MSTypeMatrix<double> allElementsDo(const MSTypeMatrix<double>&,
 					     ElementWiseFunction,
-					     void *clientData_=0);
+					     void *clientData_);
   MSTypeMatrix<double>& sin(void);
   MSTypeMatrix<double>& sinh(void);
   MSTypeMatrix<double>& cos(void);
diff -Nurd aplus-fsf-4.22.orig/src/a/Makefile.am aplus-fsf-4.22/src/a/Makefile.am
--- aplus-fsf-4.22.orig/src/a/Makefile.am	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/a/Makefile.am	2018-02-28 12:24:02.000000000 -0500
@@ -50,9 +50,7 @@
 	x.h
 
 
-CFLAGS = @CFLAGS@ -DBSTUB
-
-INCLUDES = -I..
+AM_CPPFLAGS = -DBSTUB -I..
 
 fsftestdir = $(libdir)
 apterdir = $(libdir)
diff -Nurd aplus-fsf-4.22.orig/src/a/beamconv.c aplus-fsf-4.22/src/a/beamconv.c
--- aplus-fsf-4.22.orig/src/a/beamconv.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/a/beamconv.c	2018-02-28 03:02:03.000000000 -0500
@@ -11,6 +11,7 @@
  * formats of mmap'd files used by A+
  */
 
+#include <string.h>
 #include <a/fncdcls.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff -Nurd aplus-fsf-4.22.orig/src/a/bstub.c aplus-fsf-4.22/src/a/bstub.c
--- aplus-fsf-4.22.orig/src/a/bstub.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/a/bstub.c	2018-02-28 03:02:03.000000000 -0500
@@ -19,6 +19,7 @@
 
 #include <pthread.h>		/* Needed for locking in *_cover()  */
 #include <stdio.h>
+#include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/cxc/c.c aplus-fsf-4.22/src/cxc/c.c
--- aplus-fsf-4.22.orig/src/cxc/c.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxc/c.c	2018-02-28 03:02:03.000000000 -0500
@@ -9,6 +9,7 @@
 
 #include <a/development.h>
 #include <stdio.h>
+#include <string.h>
 
 #include <a/k.h>
 #include <a/fncdcls.h>
diff -Nurd aplus-fsf-4.22.orig/src/cxs/S.c aplus-fsf-4.22/src/cxs/S.c
--- aplus-fsf-4.22.orig/src/cxs/S.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxs/S.c	2018-02-28 14:00:35.000000000 -0500
@@ -6,6 +6,7 @@
 /*                                                                           */
 /*****************************************************************************/
 #include <stdlib.h>
+#include <main/version.h>
 #include <dap/dap.h>
 #include <a/fncdcls.h>
 
@@ -17,7 +18,7 @@
 
   if ((atree = getenv("ATREE")) == (char *)(0))
   {
-    atree = "/usr/local/a+";
+    atree = IMDIR;
   }
   sfile = bnstring(atree, "/lib/s.+", (char *)(0));
   loadafile(sfile,0);
diff -Nurd aplus-fsf-4.22.orig/src/cxsys/asock.c aplus-fsf-4.22/src/cxsys/asock.c
--- aplus-fsf-4.22.orig/src/cxsys/asock.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxsys/asock.c	2018-02-28 03:50:11.000000000 -0500
@@ -6,7 +6,9 @@
 /*                                                                           */
 /*****************************************************************************/
 #include <a/development.h>
+#include <unistd.h>
 #include <stdio.h>
+#include <string.h>
 #include <signal.h>
 #include <netdb.h>
 #include <errno.h>
@@ -20,6 +22,7 @@
 #else
 #include <sys/filio.h>
 #endif
+#include <sys/ioctl.h>
 
 #include <a/k.h>
 #include <a/fncdcls.h>
diff -Nurd aplus-fsf-4.22.orig/src/cxsys/eponymous.c aplus-fsf-4.22/src/cxsys/eponymous.c
--- aplus-fsf-4.22.orig/src/cxsys/eponymous.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxsys/eponymous.c	2018-02-28 03:49:21.000000000 -0500
@@ -62,6 +62,7 @@
 #  include <sys/termios.h>
 #  include <sys/filio.h>
 #endif
+#  include <sys/ioctl.h>
 
 /* #  if defined(__cplusplus) || defined(_LCC_LIB) */
 /* #    undef __STDC__ */
@@ -531,7 +532,7 @@
   lt.tm_sec=a->p[5];       /* second           */
   lt.tm_isdst=0;  	   /* daylight savings NOT in effect */
 /*   z->p[0]=mktime(&lt)-altzone;  */
-#if defined(_AIX) || defined(HAVE_SVR4) || defined (__osf__) || defined(HAVE_MKTIME)
+#if ( defined(_AIX) || defined(HAVE_SVR4) || defined (__osf__) || defined(HAVE_MKTIME) ) && !defined(NO_TIMEZONE)
   z->p[0]=mktime(&lt); 
   if( z->p[0] != -1) 
     z->p[0]=z->p[0]-timezone;  
@@ -618,9 +619,9 @@
   return z;
 }
 
-fflush_stdout()
+I fflush_stdout()
 {
-  fflush(stdout);
+  return fflush(stdout);
 }
 
 I ep_setenv(e)C*e;{R putenv(strdup(e));}
diff -Nurd aplus-fsf-4.22.orig/src/cxsys/millisleep.c aplus-fsf-4.22/src/cxsys/millisleep.c
--- aplus-fsf-4.22.orig/src/cxsys/millisleep.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxsys/millisleep.c	2018-02-28 12:23:26.000000000 -0500
@@ -8,7 +8,7 @@
 #include <stdio.h>
 #include <sys/time.h>
 
-millisleep(i)
+void millisleep(i)
 int i;
 {
 	struct timeval tv;
diff -Nurd aplus-fsf-4.22.orig/src/cxsys/sfe.c aplus-fsf-4.22/src/cxsys/sfe.c
--- aplus-fsf-4.22.orig/src/cxsys/sfe.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/cxsys/sfe.c	2018-02-28 03:02:03.000000000 -0500
@@ -13,7 +13,9 @@
 * Creation Date:	Sat Jan 21 13:52:42 EST 1989
 \*********************************************************************/
 
+#include <unistd.h>
 #include <stdio.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/balloc.c aplus-fsf-4.22/src/dap/balloc.c
--- aplus-fsf-4.22.orig/src/dap/balloc.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/balloc.c	2018-02-28 03:57:44.000000000 -0500
@@ -16,6 +16,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <unistd.h>
 #include <dap/Warn.h>
 #include <dap/balloc.h>
 #include <dap/ulto.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/bdup.c aplus-fsf-4.22/src/dap/bdup.c
--- aplus-fsf-4.22.orig/src/dap/bdup.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bdup.c	2018-02-28 03:58:32.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 
 /* external function definitions */
diff -Nurd aplus-fsf-4.22.orig/src/dap/bdup_r.c aplus-fsf-4.22/src/dap/bdup_r.c
--- aplus-fsf-4.22.orig/src/dap/bdup_r.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bdup_r.c	2018-02-28 03:58:42.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 
 /* external function definitions */
diff -Nurd aplus-fsf-4.22.orig/src/dap/bfree.c aplus-fsf-4.22/src/dap/bfree.c
--- aplus-fsf-4.22.orig/src/dap/bfree.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bfree.c	2018-02-28 03:58:58.000000000 -0500
@@ -7,6 +7,8 @@
 /*****************************************************************************/
 /* contributed by Daniel F. Fisher */
 
+#include <stdlib.h>
+
 /* external function definitions */
 void 
 bfree(char *p)
diff -Nurd aplus-fsf-4.22.orig/src/dap/bnstring.c aplus-fsf-4.22/src/dap/bnstring.c
--- aplus-fsf-4.22.orig/src/dap/bnstring.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bnstring.c	2018-02-28 03:59:26.000000000 -0500
@@ -18,6 +18,8 @@
  */
 
 /* header file inclusions */
+#include <string.h>
+#include <strings.h>
 #if !defined(__cfront)
 #include <stdarg.h>
 #endif
diff -Nurd aplus-fsf-4.22.orig/src/dap/bnstring_r.c aplus-fsf-4.22/src/dap/bnstring_r.c
--- aplus-fsf-4.22.orig/src/dap/bnstring_r.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bnstring_r.c	2018-02-28 04:24:08.000000000 -0500
@@ -13,6 +13,8 @@
  */
 
 /* header file inclusions */
+#include <string.h>
+#include <strings.h>
 #if !defined(__cfront)
 #include <stdarg.h>
 #endif
diff -Nurd aplus-fsf-4.22.orig/src/dap/brealloc.c aplus-fsf-4.22/src/dap/brealloc.c
--- aplus-fsf-4.22.orig/src/dap/brealloc.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/brealloc.c	2018-02-28 03:59:55.000000000 -0500
@@ -13,6 +13,7 @@
 #else
 #include <malloc.h>
 #endif
+#include <unistd.h>
 
 #include <errno.h>
 #include <string.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffread.c aplus-fsf-4.22/src/dap/buffread.c
--- aplus-fsf-4.22.orig/src/dap/buffread.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffread.c	2018-02-28 04:00:24.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/buff.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffroom.c aplus-fsf-4.22/src/dap/buffroom.c
--- aplus-fsf-4.22.orig/src/dap/buffroom.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffroom.c	2018-02-28 04:00:45.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffroom_r.c aplus-fsf-4.22/src/dap/buffroom_r.c
--- aplus-fsf-4.22.orig/src/dap/buffroom_r.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffroom_r.c	2018-02-28 08:03:36.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffstuff.c aplus-fsf-4.22/src/dap/buffstuff.c
--- aplus-fsf-4.22.orig/src/dap/buffstuff.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffstuff.c	2018-02-28 04:01:00.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffstuff_r.c aplus-fsf-4.22/src/dap/buffstuff_r.c
--- aplus-fsf-4.22.orig/src/dap/buffstuff_r.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffstuff_r.c	2018-02-28 08:03:55.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/bufftrim.c aplus-fsf-4.22/src/dap/bufftrim.c
--- aplus-fsf-4.22.orig/src/dap/bufftrim.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/bufftrim.c	2018-02-28 08:04:07.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffwrite.c aplus-fsf-4.22/src/dap/buffwrite.c
--- aplus-fsf-4.22.orig/src/dap/buffwrite.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffwrite.c	2018-02-28 04:01:30.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/buff.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/buffzero.c aplus-fsf-4.22/src/dap/buffzero.c
--- aplus-fsf-4.22.orig/src/dap/buffzero.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/buffzero.c	2018-02-28 04:01:14.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/buff.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/connclose.c aplus-fsf-4.22/src/dap/connclose.c
--- aplus-fsf-4.22.orig/src/dap/connclose.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/connclose.c	2018-02-28 04:01:54.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/balloc.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/dapterm.c aplus-fsf-4.22/src/dap/dapterm.c
--- aplus-fsf-4.22.orig/src/dap/dapterm.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/dapterm.c	2018-02-28 04:02:11.000000000 -0500
@@ -8,6 +8,8 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <string.h>
+#include <strings.h>
 #include <dap/balloc.h>
 #include <dap/tod.h>
 #include <dap/node.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/doclose.c aplus-fsf-4.22/src/dap/doclose.c
--- aplus-fsf-4.22.orig/src/dap/doclose.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/doclose.c	2018-02-28 04:02:24.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/misc.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/doread.c aplus-fsf-4.22/src/dap/doread.c
--- aplus-fsf-4.22.orig/src/dap/doread.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/doread.c	2018-02-28 04:29:55.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/tv.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/dowrite.c aplus-fsf-4.22/src/dap/dowrite.c
--- aplus-fsf-4.22.orig/src/dap/dowrite.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/dowrite.c	2018-02-28 04:02:34.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/tv.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/error.c aplus-fsf-4.22/src/dap/error.c
--- aplus-fsf-4.22.orig/src/dap/error.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/error.c	2018-02-28 04:02:53.000000000 -0500
@@ -18,6 +18,8 @@
 #include <errno.h>
 #include <sys/time.h>
 #include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
 
 typedef void (*VPF) ();
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/fdscopy.c aplus-fsf-4.22/src/dap/fdscopy.c
--- aplus-fsf-4.22.orig/src/dap/fdscopy.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/fdscopy.c	2018-02-28 04:03:14.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/fds.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/fdszero.c aplus-fsf-4.22/src/dap/fdszero.c
--- aplus-fsf-4.22.orig/src/dap/fdszero.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/fdszero.c	2018-02-28 04:03:31.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/fds.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/fletchpatch.c aplus-fsf-4.22/src/dap/fletchpatch.c
--- aplus-fsf-4.22.orig/src/dap/fletchpatch.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/fletchpatch.c	2018-02-28 04:03:42.000000000 -0500
@@ -16,6 +16,7 @@
  */
 
 /* header file inclusions */
+#include <strings.h>
 #include <dap/balloc.h>
 #include <dap/misc.h>
 #include <dap/fletch.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/getmuser.c aplus-fsf-4.22/src/dap/getmuser.c
--- aplus-fsf-4.22.orig/src/dap/getmuser.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/getmuser.c	2018-02-28 04:25:24.000000000 -0500
@@ -6,6 +6,9 @@
 /*                                                                           */
 /*****************************************************************************/
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <rpcsvc/ypclnt.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/getrp.c aplus-fsf-4.22/src/dap/getrp.c
--- aplus-fsf-4.22.orig/src/dap/getrp.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/getrp.c	2018-02-28 04:04:26.000000000 -0500
@@ -7,6 +7,7 @@
 /*****************************************************************************/
 /* contributed by Douglas P. Kingston III */
 
+#include <stdlib.h>
 #include <stdio.h>
 #include <ctype.h>
 #include <string.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/hostname.c aplus-fsf-4.22/src/dap/hostname.c
--- aplus-fsf-4.22.orig/src/dap/hostname.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/hostname.c	2018-02-28 04:30:40.000000000 -0500
@@ -8,11 +8,11 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
+#include <strings.h>
 #include <a/development.h>
 #include <sys/param.h>
-#if defined(HAVE_SVR4)
 #include <netdb.h>
-#endif
 #include <dap/Warn.h>
 #include <dap/misc.h>
 
diff -Nurd aplus-fsf-4.22.orig/src/dap/hppname_in.c aplus-fsf-4.22/src/dap/hppname_in.c
--- aplus-fsf-4.22.orig/src/dap/hppname_in.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/hppname_in.c	2018-02-28 04:05:14.000000000 -0500
@@ -13,6 +13,7 @@
  */
 
 /* header file inclusions */
+#include <strings.h>
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <dap/notsunos4.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/lstnclose.c aplus-fsf-4.22/src/dap/lstnclose.c
--- aplus-fsf-4.22.orig/src/dap/lstnclose.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/lstnclose.c	2018-02-28 04:28:05.000000000 -0500
@@ -8,6 +8,8 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <unistd.h>
+#include <strings.h>
 #include <errno.h>
 #include <dap/Warn.h>
 #include <dap/balloc.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/lstnopen.c aplus-fsf-4.22/src/dap/lstnopen.c
--- aplus-fsf-4.22.orig/src/dap/lstnopen.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/lstnopen.c	2018-02-28 04:06:10.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <sys/types.h>
 #if defined(HAVE_SVR4)
 #include <sys/filio.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/nodesort.c aplus-fsf-4.22/src/dap/nodesort.c
--- aplus-fsf-4.22.orig/src/dap/nodesort.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/nodesort.c	2018-02-28 04:29:25.000000000 -0500
@@ -8,6 +8,9 @@
 /* contributed by Keith W. Iverson */
 
 /* header file inclusions */
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
 #include <dap/balloc.h>
 #include <dap/node.h>
 #include <dap/kvp.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/service.c aplus-fsf-4.22/src/dap/service.c
--- aplus-fsf-4.22.orig/src/dap/service.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/service.c	2018-02-28 04:06:48.000000000 -0500
@@ -9,9 +9,7 @@
 
 #include <string.h>
 #include <sys/param.h>
-#if defined(HAVE_SVR4)
 #include <netdb.h>
-#endif
 #include <rpcsvc/ypclnt.h>
 #include <dap/balloc.h>
 #include <dap/Warn.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/servname_in.c aplus-fsf-4.22/src/dap/servname_in.c
--- aplus-fsf-4.22.orig/src/dap/servname_in.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/servname_in.c	2018-02-28 04:07:08.000000000 -0500
@@ -13,6 +13,7 @@
  */
 
 /* header file inclusions */
+#include <strings.h>
 #include <sys/types.h>
 #include <sys/uio.h>
 #include <dap/notsunos4.h>
diff -Nurd aplus-fsf-4.22.orig/src/dap/sgnloriginal.c aplus-fsf-4.22/src/dap/sgnloriginal.c
--- aplus-fsf-4.22.orig/src/dap/sgnloriginal.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/dap/sgnloriginal.c	2018-02-28 04:07:21.000000000 -0500
@@ -8,6 +8,7 @@
 /* contributed by Daniel F. Fisher */
 
 /* header file inclusions */
+#include <strings.h>
 #include <a/development.h>
 #include <dap/Warn.h>
 #include <dap/sgnl.h>
diff -Nurd aplus-fsf-4.22.orig/src/esf/dyld2.c aplus-fsf-4.22/src/esf/dyld2.c
--- aplus-fsf-4.22.orig/src/esf/dyld2.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/esf/dyld2.c	2018-02-28 03:56:27.000000000 -0500
@@ -7,9 +7,7 @@
 /*****************************************************************************/
 
 #include <sys/param.h>
-#if !defined(__APPLE__)
 #include <dlfcn.h>
-#endif
 #if defined(__NetBSD__) || defined(__FreeBSD) || defined (__APPLE__)
 #include <stdlib.h>
 #else
diff -Nurd aplus-fsf-4.22.orig/src/esf/pack.c aplus-fsf-4.22/src/esf/pack.c
--- aplus-fsf-4.22.orig/src/esf/pack.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/esf/pack.c	2018-02-28 03:55:50.000000000 -0500
@@ -6,6 +6,7 @@
 /*                                                                           */
 /*****************************************************************************/
 #include <a/development.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
diff -Nurd aplus-fsf-4.22.orig/src/esf/primpro.c aplus-fsf-4.22/src/esf/primpro.c
--- aplus-fsf-4.22.orig/src/esf/primpro.c	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/esf/primpro.c	2018-02-28 03:02:03.000000000 -0500
@@ -7,6 +7,7 @@
 /*****************************************************************************/
 #include <unistd.h>
 #include <stdio.h>
+#include <string.h>
 #include <sys/times.h>
 #include <limits.h>
 #include <a/fir.h>
diff -Nurd aplus-fsf-4.22.orig/src/main/Makefile.am aplus-fsf-4.22/src/main/Makefile.am
--- aplus-fsf-4.22.orig/src/main/Makefile.am	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/main/Makefile.am	2018-02-28 14:03:20.000000000 -0500
@@ -21,9 +21,7 @@
 	matherr.c \
 	version.h
 
-CFLAGS = @CFLAGS@ -DBSTUB
-
-INCLUDES = -I.. $(X_INCLUDES)
+AM_CPPFLAGS = -DBSTUB -I.. $(X_INCLUDES)
 
 aplus_LDADD = \
 	$(top_srcdir)/src/IPC/libIPC.la \
@@ -37,21 +35,7 @@
 	$(top_srcdir)/src/dap/libdap.la \
 	$(top_srcdir)/src/MSGUI/libMSGUI.la \
 	$(top_srcdir)/src/MSIPC/libMSIPC.la \
-	$(top_srcdir)/src/MSTypes/libMSTypes.la 
-
-aplus_LDFLAGS = \
-	-L$(top_srcdir)/src/IPC \
-	-L$(top_srcdir)/src/cxs \
-	-L$(top_srcdir)/src/cxb \
-	-L$(top_srcdir)/src/AplusGUI \
-	-L$(top_srcdir)/src/cxsys \
-	-L$(top_srcdir)/src/cxc \
-	-L$(top_srcdir)/src/esf \
-	-L$(top_srcdir)/src/a \
-	-L$(top_srcdir)/src/dap \
-	-L$(top_srcdir)/src/MSGUI \
-	-L$(top_srcdir)/src/MSIPC \
-	-L$(top_srcdir)/src/MSTypes \
+	$(top_srcdir)/src/MSTypes/libMSTypes.la \
 	$(X_LIBS) $(LIBS)
 
 install-exec-hook:
@@ -61,7 +45,7 @@
 
 aplus_main.c: version.h
 
-version.h: FORCE
+version.h: $(top_builddir)/config.status
 	echo "Making $@";\
 	rm -f $@;\
 	cat version.h.template | sed -e s/%RCVAL%/$(VERSION)/ \
diff -Nurd aplus-fsf-4.22.orig/src/main/Makefile.in aplus-fsf-4.22/src/main/Makefile.in
--- aplus-fsf-4.22.orig/src/main/Makefile.in	2018-02-28 01:40:08.000000000 -0500
+++ aplus-fsf-4.22/src/main/Makefile.in	2018-02-28 03:03:16.000000000 -0500
@@ -126,18 +126,6 @@
 
 
 aplus_LDFLAGS = \
-	-L$(top_srcdir)/src/IPC \
-	-L$(top_srcdir)/src/cxs \
-	-L$(top_srcdir)/src/cxb \
-	-L$(top_srcdir)/src/AplusGUI \
-	-L$(top_srcdir)/src/cxsys \
-	-L$(top_srcdir)/src/cxc \
-	-L$(top_srcdir)/src/esf \
-	-L$(top_srcdir)/src/a \
-	-L$(top_srcdir)/src/dap \
-	-L$(top_srcdir)/src/MSGUI \
-	-L$(top_srcdir)/src/MSIPC \
-	-L$(top_srcdir)/src/MSTypes \
 	$(X_LIBS) $(LIBS)
 
 subdir = src/main
