From c573b89139e7a068f5573abd565605bed60f293f Mon Sep 17 00:00:00 2001
From: Jussi Kukkonen <jussi.kukkonen@intel.com>
Date: Sat, 24 Feb 2018 15:18:33 +0100
Subject: [PATCH] [PATCH 3/4] Skip host file system checks when cross-compiling

Modified from patch by Maarten ter Huurne.

Upstream-Status: Submitted [http://savannah.gnu.org/bugs/?43223]

Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
---
 configure.ac | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/configure.ac b/src/configure.ac
index 74be368..bd748d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,7 +85,7 @@ AC_ARG_ENABLE(socket-dir,
 dnl
 dnl    ****  special unix variants  ****
 dnl
-if test -n "$ISC"; then
+if test "$cross_compiling" = no && test -n "$ISC" ; then
   AC_DEFINE(ISC) LIBS="$LIBS -linet"
 fi
 
@@ -96,10 +96,11 @@ dnl AC_DEFINE(OSF1)	# this disables MIPS again....
 dnl fi
 dnl fi
 
-if test -f /sysV68 ; then
+if test "$cross_compiling" = no && test -f /sysV68 ; then
 AC_DEFINE(sysV68)
 fi
 
+if test "$cross_compiling" = no ; then
 AC_CHECKING(for MIPS)
 if test -f /lib/libmld.a || test -f /usr/lib/libmld.a || test -f /usr/lib/cmplrs/cc/libmld.a; then
 oldlibs="$LIBS"
@@ -123,6 +124,7 @@ AC_DEFINE(USE_WAIT2) LIBS="$LIBS -lbsd" ; CC="$CC -I/usr/include/bsd"
 ))
 fi
 fi
+fi
 
 
 AC_CHECKING(for Ultrix)
@@ -132,7 +134,7 @@ AC_EGREP_CPP(YES_IS_DEFINED,
 #endif
 ], ULTRIX=1)
 
-if test -f /usr/lib/libpyr.a ; then
+if test "$cross_compiling" = no && test -f /usr/lib/libpyr.a ; then
 oldlibs="$LIBS"
 LIBS="$LIBS -lpyr"
 AC_CHECKING(Pyramid OSX)
@@ -653,17 +655,21 @@ AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
 dnl
 dnl    ****  PTY specific things  ****
 dnl
+if test "$cross_compiling" = no ; then
 AC_CHECKING(for /dev/ptc)
 if test -r /dev/ptc; then
 AC_DEFINE(HAVE_DEV_PTC)
 fi
+fi
 
+if test "$cross_compiling" = no ; then
 AC_CHECKING(for SVR4 ptys)
 sysvr4ptys=
 if test -c /dev/ptmx ; then
 AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
 sysvr4ptys=1])
 fi
+fi
 
 AC_CHECK_FUNCS(getpt)
 
@@ -673,6 +679,7 @@ AC_CHECK_FUNCS(openpty,,
 [AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])])
 fi
 
+if test "$cross_compiling" = no ; then
 AC_CHECKING(for ptyranges)
 if test -d /dev/ptym ; then
 pdir='/dev/ptym'
@@ -696,6 +703,7 @@ p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g'  | sort -u | tr -d '\
 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
 fi
+fi
 
 dnl    ****  pty mode/group handling ****
 dnl
@@ -843,14 +851,16 @@ fi
 dnl
 dnl    ****  loadav  ****
 dnl
+if test "$cross_compiling" = no ; then
 AC_CHECKING(for libutil(s))
 test -f /usr/lib/libutils.a && LIBS="$LIBS -lutils"
 test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil"
+fi
 
 AC_CHECKING(getloadavg)
 AC_TRY_LINK(,[getloadavg((double *)0, 0);],
 AC_DEFINE(LOADAV_GETLOADAVG) load=1,
-if test -f /usr/lib/libkvm.a ; then
+if test "$cross_compiling" = no && test -f /usr/lib/libkvm.a ; then
 olibs="$LIBS"
 LIBS="$LIBS -lkvm"
 AC_CHECKING(getloadavg with -lkvm)
@@ -1068,13 +1078,18 @@ dnl    ****  libraries  ****
 dnl
 
 AC_CHECKING(for crypt and sec libraries)
+if test "$cross_compiling" = no ; then
 test -f /lib/libcrypt_d.a || test -f /usr/lib/libcrypt_d.a && LIBS="$LIBS -lcrypt_d"
+fi
 oldlibs="$LIBS"
 LIBS="$LIBS -lcrypt"
 AC_CHECKING(crypt)
 AC_TRY_LINK(,,,LIBS="$oldlibs")
+if test "$cross_compiling" = no ; then
 test -f /lib/libsec.a || test -f /usr/lib/libsec.a && LIBS="$LIBS -lsec"
 test -f /lib/libshadow.a || test -f /usr/lib/libshadow.a && LIBS="$LIBS -lshadow"
+fi
+
 oldlibs="$LIBS"
 LIBS="$LIBS -lsun"
 AC_CHECKING(IRIX sun library)
-- 
2.17.1