From: Maarten ter Huurne <maarten@treewalker.org>
Date: Sat, 13 Sep 2014 12:04:41 +0200
Subject: Provide cross compilation alternatives for all AC_TRY_RUN uses

Signed-off-by: Maarten ter Huurne <maarten@treewalker.org>
[Ricardo: rebase on top of 4.3.1]
Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com>
---
 configure.ac | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git configure.ac configure.ac
index b8e3bec..c4b7cd4 100644
--- configure.ac
+++ configure.ac
@@ -348,7 +348,8 @@
   exit(0);
 }
 ], AC_NOTE(- your fifos are usable) fifo=1,
-AC_NOTE(- your fifos are not usable))
+AC_NOTE(- your fifos are not usable),
+AC_NOTE(- skipping check because we are cross compiling; assuming fifos are usable) fifo=1)
 rm -f /tmp/conftest*
 
 if test -n "$fifo"; then
@@ -396,7 +397,8 @@
   exit(0);
 }
 ], AC_NOTE(- your implementation is ok), 
-AC_NOTE(- you have a broken implementation) AC_DEFINE(BROKEN_PIPE) fifobr=1)
+AC_NOTE(- you have a broken implementation) AC_DEFINE(BROKEN_PIPE) fifobr=1,
+AC_NOTE(- skipping check because we are cross compiling; assuming fifo implementation is ok))
 rm -f /tmp/conftest*
 fi
 
@@ -458,7 +460,8 @@
   exit(0);
 }
 ], AC_NOTE(- your sockets are usable) sock=1,
-AC_NOTE(- your sockets are not usable))
+AC_NOTE(- your sockets are not usable),
+AC_NOTE(- skipping check because we are cross compiling; assuming sockets are usable) sock=1)
 rm -f /tmp/conftest*
 
 if test -n "$sock"; then
@@ -497,7 +500,8 @@
 }
 ],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_DEFINE(SOCK_NOT_IN_FS) socknofs=1,
+AC_NOTE(- skipping check because we are cross compiling; assuming sockets are normal))
 rm -f /tmp/conftest*
 fi
 
@@ -598,7 +602,8 @@
   exit(0);
 }
 ],AC_NOTE(- select is ok),
-AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN))
+AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN),
+AC_NOTE(- skipping check because we are cross compiling; assuming select is ok))
 
 dnl
 dnl    ****  termcap or terminfo  ****
@@ -640,7 +645,8 @@
 {
  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 terminfo database) AC_DEFINE(TERMINFO),
+AC_NOTE(- skipping check because we are cross compiling; assuming terminfo database is used) AC_DEFINE(TERMINFO))
 AC_CHECKING(ospeed)
 AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
 
@@ -775,7 +781,8 @@
     else
       AC_NOTE(- can't determine - assume ptys are world accessable)
     fi
-  ]
+  ],
+  AC_NOTE(- skipping check because we are cross compiling; assuming ptys are world accessable)
 )
 rm -f conftest_grp
 fi
@@ -859,7 +866,7 @@
 #endif
 ], load=1)
 fi
-if test -z "$load" ; then
+if test -z "$load" && test "$cross_compiling" = no ; then
 AC_CHECKING(for kernelfile)
 for core in /unix /vmunix /dynix /hp-ux /xelos /dev/ksyms /kernel/unix /kernel/genunix /unicos /mach /netbsd /386bsd /dgux /bsd /stand/vmunix; do
   if test -f $core || test -c $core; then
@@ -1052,7 +1059,7 @@
 #endif
   exit(0);
 }
-],,AC_DEFINE(SYSVSIGS))
+],,AC_DEFINE(SYSVSIGS),:)
 
 fi
 
@@ -1132,7 +1139,7 @@
   if (strncmp(buf, "cdedef", 6))
     exit(1);
   exit(0); /* libc version works properly.  */
-}], AC_DEFINE(USEBCOPY))
+}], AC_DEFINE(USEBCOPY),,:)
 
 AC_TRY_RUN([
 #define bcopy(s,d,l) memmove(d,s,l)
@@ -1147,7 +1154,8 @@
   if (strncmp(buf, "cdedef", 6))
     exit(1);
   exit(0); /* libc version works properly.  */
-}], AC_DEFINE(USEMEMMOVE))
+}], AC_DEFINE(USEMEMMOVE),,
+  AC_NOTE(- skipping check because we are cross compiling; use memmove) AC_DEFINE(USEMEMMOVE))
 
 AC_SYS_LONG_FILE_NAMES
 
