--- configure.in.org	2014-04-26 12:58:35.000000000 +0200
+++ configure.in	2014-09-12 16:26:40.000000000 +0200
@@ -47,31 +47,6 @@
 AC_ISC_POSIX
 AC_USE_SYSTEM_EXTENSIONS
 
-AC_TRY_RUN(main(){exit(0);},,[
-if test $CC != cc ; then
-AC_NOTE(Your $CC failed - restarting with CC=cc)
-AC_NOTE()
-CC=cc
-export CC
-exec $0 $configure_args
-fi
-])
-
-AC_TRY_RUN(main(){exit(0);},,
-exec 5>&2
-eval $ac_link
-AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;)
-AC_NOTE($ac_compile)
-AC_MSG_ERROR(Can't run the compiler - sorry))
-
-AC_TRY_RUN([
-main()
-{
-  int __something_strange_();
-  __something_strange_(0);
-}
-],AC_MSG_ERROR(Your compiler does not set the exit status - sorry))
-
 AC_PROG_AWK
 
 AC_PROG_INSTALL
@@ -306,7 +281,8 @@
 dnl    ****  FIFO tests  ****
 dnl
 
-AC_CHECKING(fifos)
+AC_CACHE_CHECK([fifos], [ac_cv_fifo],
+  [
 AC_TRY_RUN([
 /* For select - According to POSIX 1003.1-2001 */
 #include <sys/select.h>
@@ -371,12 +347,14 @@
     exit(1);
   exit(0);
 }
-], AC_NOTE(- your fifos are usable) fifo=1,
-AC_NOTE(- your fifos are not usable))
+], AC_NOTE(- your fifos are usable) ac_cv_fifo=yes,
+AC_NOTE(- your fifos are not usable) ac_cv_fifo=no )
 rm -f /tmp/conftest*
+])
 
-if test -n "$fifo"; then
-AC_CHECKING(for broken fifo implementation)
+if test x"$ac_cv_fifo" = xyes; then
+AC_CACHE_CHECK([for broken fifo implementation], [ac_cv_fifobr],
+  [
 AC_TRY_RUN([
 /* For select - According to POSIX 1003.1-2001 */
 #include <sys/select.h>
@@ -419,9 +397,14 @@
     exit(1);
   exit(0);
 }
-], AC_NOTE(- your implementation is ok), 
-AC_NOTE(- you have a broken implementation) AC_DEFINE(BROKEN_PIPE) fifobr=1)
+], AC_NOTE(- your implementation is ok) ac_cv_fifobr=no, 
+AC_NOTE(- you have a broken implementation) ac_cv_fifobr=yes)
 rm -f /tmp/conftest*
+])
+fi
+
+if test "x$ac_cv_fifobr" = "xyes" ; then
+  AC_DEFINE(BROKEN_PIPE)
 fi
 
 dnl
@@ -430,7 +413,8 @@
 dnl 	may need  	LIBS="$LIBS -lsocket" 	here
 dnl
 
-AC_CHECKING(sockets)
+AC_CACHE_CHECK([sockets], [ac_cv_sock],
+  [
 AC_TRY_RUN([
 /* For select - According to POSIX 1003.1-2001 */
 #include <sys/select.h>
@@ -481,12 +465,14 @@
     exit(1);
   exit(0);
 }
-], AC_NOTE(- your sockets are usable) sock=1,
-AC_NOTE(- your sockets are not usable))
+], AC_NOTE(- your sockets are usable) ac_cv_sock=yes,
+AC_NOTE(- your sockets are not usable) ac_cv_sock=no )
 rm -f /tmp/conftest*
+  ])
 
-if test -n "$sock"; then
-AC_CHECKING(socket implementation)
+if test x"$ac_cv_sock" = xyes; then
+AC_CACHE_CHECK([if domain sockets are stored in file system], [ac_cv_socknofs],
+  [
 AC_TRY_RUN([
 /* For select - According to POSIX 1003.1-2001 */
 #include <sys/select.h>
@@ -519,22 +505,26 @@
   close(s);
   exit(0);
 }
-],AC_NOTE(- you are normal),
-AC_NOTE(- unix domain sockets are not kept in the filesystem)
-AC_DEFINE(SOCK_NOT_IN_FS) socknofs=1)
+],AC_NOTE(- you are normal) av_cv_socknofs=no,
+AC_NOTE(- unix domain sockets are not kept in the filesystem) av_cv_socknofs=yes)
 rm -f /tmp/conftest*
+  ])
+fi
+
+if test "x$ac_cv_socknofs" = "xyes" ; then
+  AC_DEFINE(SOCK_NOT_IN_FS)
 fi
 
 
 dnl
 dnl    ****  choose sockets or fifos  ****
 dnl
-if test -n "$fifo"; then
-  if test -n "$sock"; then
+if test x"$ac_cv_fifo" = xyes; then
+  if test x"$ac_cv_sock" = xyes; then
     if test -n "$nore"; then
       AC_NOTE(- hmmm... better take the fifos)
       AC_DEFINE(NAMEDPIPE)
-    elif test -n "$fifobr"; then
+    elif test x"$ac_cv_fifobr" = xyes; then
       AC_NOTE(- as your fifos are broken lets use the sockets.)
     else
       AC_NOTE(- both sockets and fifos usable. let's take sockets.)
@@ -543,7 +533,7 @@
     AC_NOTE(- using named pipes, of course)
     AC_DEFINE(NAMEDPIPE)
   fi
-elif test -n "$sock"; then
+elif test x"$ac_cv_sock" = xyes; then
   AC_NOTE(- using unix-domain sockets, of course)
 else
   AC_MSG_ERROR(you have neither usable sockets nor usable pipes -> no screen)
@@ -553,7 +543,8 @@
 dnl    ****  check the select implementation ****
 dnl
 
-AC_CHECKING(select return value)
+AC_CACHE_CHECK([if select is broken], [ac_cv_select_broken],
+  [
 AC_TRY_RUN([
 /* For select - According to POSIX 1003.1-2001 */
 #include <sys/select.h>
@@ -647,8 +638,13 @@
     exit(1);
   exit(0);
 }
-],AC_NOTE(- select is ok),
-AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN))
+],AC_NOTE(- select is ok) ac_cv_select_broken=no,
+AC_NOTE(- select can't count) ac_cv_select_broken=yes)
+ ])
+
+if test x"$ac_cv_select_broken" = xyes; then
+  AC_DEFINE(SELECT_BROKEN)
+fi
 
 dnl
 dnl    ****  termcap or terminfo  ****
@@ -685,12 +681,20 @@
 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
 AC_MSG_ERROR(!!! no tgetent - no screen)))))))))
 
+AC_CACHE_CHECK([whether we talk terminfo], [ac_cv_terminfo],
+  [
 AC_TRY_RUN([
 main()
 {
  exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
-}], AC_NOTE(- you use the termcap database),
-AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO))
+}], AC_NOTE(- you use the termcap database) ac_cv_terminfo=no ,
+AC_NOTE(- you use the terminfo database) ac_cv_terminfo=yes)
+  ])
+
+if test "x$ac_cv_terminfo" = "xyes" ; then
+  AC_DEFINE(TERMINFO)
+fi
+
 AC_CHECKING(ospeed)
 AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
 
@@ -1169,51 +1173,72 @@
 AC_CHECKING(fdwalk)
 AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK))
 
-AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments)
-AC_TRY_RUN([
+[bcopy_test_prog='
+#include "confdefs.h"
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#endif
 main() {
   char buf[10];
   strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
+  mch_memmove(buf, buf + 2, 3);
   if (strncmp(buf, "ababcf", 6))
     exit(1);
   strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
+  mch_memmove(buf + 2, buf, 3);
   if (strncmp(buf, "cdedef", 6))
     exit(1);
   exit(0); /* libc version works properly.  */
-}], AC_DEFINE(USEBCOPY))
+}']
 
-AC_TRY_RUN([
-#define bcopy(s,d,l) memmove(d,s,l)
-main() {
-  char buf[10];
-  strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
-  if (strncmp(buf, "ababcf", 6))
-    exit(1);
-  strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
-  if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
-}], AC_DEFINE(USEMEMMOVE))
+dnl Check for memmove() before bcopy(), makes memmove() be used when both are
+dnl present, fixes problem with incompatibility between Solaris 2.4 and 2.5.
 
+AC_CACHE_CHECK([whether memmove handles overlaps],[ac_cv_memmove_handles_overlap],
+  [
+    AC_TRY_RUN([#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog],
+      [
+	ac_cv_memmove_handles_overlap=yes
+      ],[
+	ac_cv_memmove_handles_overlap=no
+      ])
+  ])
 
-AC_TRY_RUN([
-#define bcopy(s,d,l) memcpy(d,s,l)
-main() {
-  char buf[10];
-  strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
-  if (strncmp(buf, "ababcf", 6))
-    exit(1);
-  strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
-  if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
-}], AC_DEFINE(USEMEMCPY))
+if test "x$ac_cv_memmove_handles_overlap" = "xyes" ; then
+  AC_DEFINE(USEMEMMOVE)
+else
+  AC_CACHE_CHECK([whether bcopy handles overlaps],[ac_cv_bcopy_handles_overlap],
+    [
+      AC_TRY_RUN([#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog],
+      [
+	ac_cv_bcopy_handles_overlap=yes
+      ],[
+	ac_cv_bcopy_handles_overlap=no
+      ])
+    ])
+
+  if test "x$ac_cv_bcopy_handles_overlap" = "xyes" ; then
+    AC_DEFINE(USEBCOPY)
+  else
+    AC_CACHE_CHECK([whether memcpy handles overlaps],[ac_cv_memcpy_handles_overlap],
+      [
+	AC_TRY_RUN([#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog],
+	  [
+	    ac_cv_memcpy_handles_overlap=yes
+	  ],[
+	    ac_cv_memcpy_handles_overlap=no
+	  ])
+      ])
+
+    if test "x$ac_cv_memcpy_handles_overlap" = "xyes" ; then
+      AC_DEFINE(USEMEMCPY)
+    fi
+  fi
+fi
 
 AC_SYS_LONG_FILE_NAMES
 
@@ -1299,8 +1324,6 @@
 dnl Ptx bug workaround -- insert -lc after -ltermcap
 test -n "$seqptx" && LIBS="-ltermcap -lc -lsocket -linet -lnsl -lsec -lseq"
 
-AC_TRY_RUN(main(){exit(0);},,AC_MSG_ERROR(Can't run the compiler - internal error. Sorry.))
-
 ETCSCREENRC=
 AC_MSG_CHECKING(for the global screenrc file)
 AC_ARG_WITH(sys-screenrc, [  --with-sys-screenrc=path to the global screenrc file], [ ETCSCREENRC="${withval}" ])
--- configure.org	2014-09-12 17:53:00.000000000 +0200
+++ configure	2014-09-12 17:53:10.000000000 +0200
@@ -3657,86 +3657,6 @@
 
 
 
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-main(){exit(0);}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-
-if test $CC != cc ; then
-echo "Your $CC failed - restarting with CC=cc" 1>&6
-
-echo "" 1>&6
-
-CC=cc
-export CC
-exec $0 $configure_args
-fi
-
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-main(){exit(0);}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  exec 5>&2
-eval $ac_link
-echo "CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;" 1>&6
-
-echo "$ac_compile" 1>&6
-
-as_fn_error $? "Can't run the compiler - sorry" "$LINENO" 5
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-main()
-{
-  int __something_strange_();
-  __something_strange_(0);
-}
-
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-  as_fn_error $? "Your compiler does not set the exit status - sorry" "$LINENO" 5
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
 for ac_prog in gawk mawk nawk awk
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
@@ -4397,8 +4317,12 @@
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking fifos..." >&5
-$as_echo "$as_me: checking fifos..." >&6;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking fifos" >&5
+$as_echo_n "checking fifos... " >&6; }
+if ${ac_cv_fifo+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -4475,10 +4399,10 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- your fifos are usable" 1>&6
- fifo=1
+ ac_cv_fifo=yes
 else
   echo "- your fifos are not usable" 1>&6
-
+ ac_cv_fifo=no
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
@@ -4486,9 +4410,17 @@
 
 rm -f /tmp/conftest*
 
-if test -n "$fifo"; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken fifo implementation..." >&5
-$as_echo "$as_me: checking for broken fifo implementation..." >&6;}
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fifo" >&5
+$as_echo "$ac_cv_fifo" >&6; }
+
+if test x"$ac_cv_fifo" = xyes; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for broken fifo implementation" >&5
+$as_echo_n "checking for broken fifo implementation... " >&6; }
+if ${ac_cv_fifobr+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -4543,22 +4475,34 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- your implementation is ok" 1>&6
-
+ ac_cv_fifobr=no
 else
   echo "- you have a broken implementation" 1>&6
- $as_echo "#define BROKEN_PIPE 1" >>confdefs.h
- fifobr=1
+ ac_cv_fifobr=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
 rm -f /tmp/conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fifobr" >&5
+$as_echo "$ac_cv_fifobr" >&6; }
 fi
 
+if test "x$ac_cv_fifobr" = "xyes" ; then
+  $as_echo "#define BROKEN_PIPE 1" >>confdefs.h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sockets" >&5
+$as_echo_n "checking sockets... " >&6; }
+if ${ac_cv_sock+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking sockets..." >&5
-$as_echo "$as_me: checking sockets..." >&6;}
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -4621,10 +4565,10 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- your sockets are usable" 1>&6
- sock=1
+ ac_cv_sock=yes
 else
   echo "- your sockets are not usable" 1>&6
-
+ ac_cv_sock=no
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
@@ -4632,9 +4576,17 @@
 
 rm -f /tmp/conftest*
 
-if test -n "$sock"; then
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking socket implementation..." >&5
-$as_echo "$as_me: checking socket implementation..." >&6;}
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sock" >&5
+$as_echo "$ac_cv_sock" >&6; }
+
+if test x"$ac_cv_sock" = xyes; then
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if domain sockets are stored in file system" >&5
+$as_echo_n "checking if domain sockets are stored in file system... " >&6; }
+if ${ac_cv_socknofs+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -4679,29 +4631,36 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- you are normal" 1>&6
-
+ av_cv_socknofs=no
 else
   echo "- unix domain sockets are not kept in the filesystem" 1>&6
-
-$as_echo "#define SOCK_NOT_IN_FS 1" >>confdefs.h
- socknofs=1
+ av_cv_socknofs=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
 rm -f /tmp/conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_socknofs" >&5
+$as_echo "$ac_cv_socknofs" >&6; }
 fi
 
+if test "x$ac_cv_socknofs" = "xyes" ; then
+  $as_echo "#define SOCK_NOT_IN_FS 1" >>confdefs.h
 
-if test -n "$fifo"; then
-  if test -n "$sock"; then
+fi
+
+
+if test x"$ac_cv_fifo" = xyes; then
+  if test x"$ac_cv_sock" = xyes; then
     if test -n "$nore"; then
       echo "- hmmm... better take the fifos" 1>&6
 
       $as_echo "#define NAMEDPIPE 1" >>confdefs.h
 
-    elif test -n "$fifobr"; then
+    elif test x"$ac_cv_fifobr" = xyes; then
       echo "- as your fifos are broken lets use the sockets." 1>&6
 
     else
@@ -4714,7 +4673,7 @@
     $as_echo "#define NAMEDPIPE 1" >>confdefs.h
 
   fi
-elif test -n "$sock"; then
+elif test x"$ac_cv_sock" = xyes; then
   echo "- using unix-domain sockets" 1>&6
 
 else
@@ -4722,8 +4681,12 @@
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking select return value..." >&5
-$as_echo "$as_me: checking select return value..." >&6;}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if select is broken" >&5
+$as_echo_n "checking if select is broken... " >&6; }
+if ${ac_cv_select_broken+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -4829,17 +4792,25 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- select is ok" 1>&6
-
+ ac_cv_select_broken=no
 else
   echo "- select can't count" 1>&6
- $as_echo "#define SELECT_BROKEN 1" >>confdefs.h
-
+ ac_cv_select_broken=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_select_broken" >&5
+$as_echo "$ac_cv_select_broken" >&6; }
+
+if test x"$ac_cv_select_broken" = xyes; then
+  $as_echo "#define SELECT_BROKEN 1" >>confdefs.h
+
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent..." >&5
 $as_echo "$as_me: checking for tgetent..." >&6;}
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -5008,6 +4979,12 @@
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we talk terminfo" >&5
+$as_echo_n "checking whether we talk terminfo... " >&6; }
+if ${ac_cv_terminfo+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
 if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
@@ -5024,16 +5001,25 @@
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
   echo "- you use the termcap database" 1>&6
-
+ ac_cv_terminfo=no
 else
   echo "- you use the terminfo database" 1>&6
- $as_echo "#define TERMINFO 1" >>confdefs.h
-
+ ac_cv_terminfo=yes
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_terminfo" >&5
+$as_echo "$ac_cv_terminfo" >&6; }
+
+if test "x$ac_cv_terminfo" = "xyes" ; then
+  $as_echo "#define TERMINFO 1" >>confdefs.h
+
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking ospeed..." >&5
 $as_echo "$as_me: checking ospeed..." >&6;}
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6140,32 +6126,52 @@
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memcpy/memmove/bcopy handles overlapping arguments..." >&5
-$as_echo "$as_me: checking whether memcpy/memmove/bcopy handles overlapping arguments..." >&6;}
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
+bcopy_test_prog='
+#include "confdefs.h"
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#endif
 main() {
   char buf[10];
   strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
+  mch_memmove(buf, buf + 2, 3);
   if (strncmp(buf, "ababcf", 6))
     exit(1);
   strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
+  mch_memmove(buf + 2, buf, 3);
   if (strncmp(buf, "cdedef", 6))
     exit(1);
   exit(0); /* libc version works properly.  */
-}
+}'
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memmove handles overlaps" >&5
+$as_echo_n "checking whether memmove handles overlaps... " >&6; }
+if ${ac_cv_memmove_handles_overlap+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define mch_memmove(s,d,l) memmove(d,s,l) $bcopy_test_prog
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
-  $as_echo "#define USEBCOPY 1" >>confdefs.h
+
+	ac_cv_memmove_handles_overlap=yes
+
+else
+
+	ac_cv_memmove_handles_overlap=no
 
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
@@ -6173,7 +6179,21 @@
 fi
 
 
-if test "$cross_compiling" = yes; then :
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_memmove_handles_overlap" >&5
+$as_echo "$ac_cv_memmove_handles_overlap" >&6; }
+
+if test "x$ac_cv_memmove_handles_overlap" = "xyes" ; then
+  $as_echo "#define USEMEMMOVE 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether bcopy handles overlaps" >&5
+$as_echo_n "checking whether bcopy handles overlaps... " >&6; }
+if ${ac_cv_bcopy_handles_overlap+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+      if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot run test program while cross compiling
@@ -6181,23 +6201,15 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-
-#define bcopy(s,d,l) memmove(d,s,l)
-main() {
-  char buf[10];
-  strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
-  if (strncmp(buf, "ababcf", 6))
-    exit(1);
-  strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
-  if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
-}
+#define mch_bcopy(s,d,l) bcopy(d,s,l) $bcopy_test_prog
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
-  $as_echo "#define USEMEMMOVE 1" >>confdefs.h
+
+	ac_cv_bcopy_handles_overlap=yes
+
+else
+
+	ac_cv_bcopy_handles_overlap=no
 
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
@@ -6205,8 +6217,21 @@
 fi
 
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_bcopy_handles_overlap" >&5
+$as_echo "$ac_cv_bcopy_handles_overlap" >&6; }
 
-if test "$cross_compiling" = yes; then :
+  if test "x$ac_cv_bcopy_handles_overlap" = "xyes" ; then
+    $as_echo "#define USEBCOPY 1" >>confdefs.h
+
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memcpy handles overlaps" >&5
+$as_echo_n "checking whether memcpy handles overlaps... " >&6; }
+if ${ac_cv_memcpy_handles_overlap+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+	if test "$cross_compiling" = yes; then :
   { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
 as_fn_error $? "cannot run test program while cross compiling
@@ -6214,23 +6239,15 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-
-#define bcopy(s,d,l) memcpy(d,s,l)
-main() {
-  char buf[10];
-  strcpy(buf, "abcdefghi");
-  bcopy(buf, buf + 2, 3);
-  if (strncmp(buf, "ababcf", 6))
-    exit(1);
-  strcpy(buf, "abcdefghi");
-  bcopy(buf + 2, buf, 3);
-  if (strncmp(buf, "cdedef", 6))
-    exit(1);
-  exit(0); /* libc version works properly.  */
-}
+#define mch_memcpy(s,d,l) memcpy(d,s,l) $bcopy_test_prog
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
-  $as_echo "#define USEMEMCPY 1" >>confdefs.h
+
+	    ac_cv_memcpy_handles_overlap=yes
+
+else
+
+	    ac_cv_memcpy_handles_overlap=no
 
 fi
 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
@@ -6238,6 +6255,17 @@
 fi
 
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_memcpy_handles_overlap" >&5
+$as_echo "$ac_cv_memcpy_handles_overlap" >&6; }
+
+    if test "x$ac_cv_memcpy_handles_overlap" = "xyes" ; then
+      $as_echo "#define USEMEMCPY 1" >>confdefs.h
+
+    fi
+  fi
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long file names" >&5
 $as_echo_n "checking for long file names... " >&6; }
 if ${ac_cv_sys_long_file_names+:} false; then :
@@ -6718,26 +6746,6 @@
 fi
 test -n "$seqptx" && LIBS="-ltermcap -lc -lsocket -linet -lnsl -lsec -lseq"
 
-if test "$cross_compiling" = yes; then :
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run test program while cross compiling
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-main(){exit(0);}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
-  as_fn_error $? "Can't run the compiler - internal error. Sorry." "$LINENO" 5
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-
 ETCSCREENRC=
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the global screenrc file" >&5
 $as_echo_n "checking for the global screenrc file... " >&6; }
