build: improve env var handling for cross build

We can use `$ac_precious_vars` to get at autoconf's conception of which
environment variables are relevant.  This makes "HOST_..." setup more
consistent for cross-compilation setups.

Fixes: #4006
Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2019-06-04 16:20:20 +02:00
parent a71c5039ad
commit 72ad94d548

View file

@ -53,10 +53,30 @@ elif test "$host" != "$build"; then
AC_MSG_NOTICE([... use HOST_CPPFLAGS / HOST_CFLAGS / HOST_LDFLAGS if neccessary])
AC_MSG_NOTICE([...])
( CPPFLAGS="$HOST_CPPFLAGS"; \
CFLAGS="$HOST_CFLAGS"; \
LDFLAGS="$HOST_LDFLAGS"; \
cd hosttools; "${abssrc}/configure" "--host=$build" "--build=$build" "--enable-clippy-only" "--disable-nhrpd" "--disable-vtysh"; ) || exit 1
(
for var in $ac_precious_vars; do
dnl special cases
case "$var" in
YACC|YFLAGS) continue;;
PYTHON*) retain=true;;
*) retain=false;
esac
eval "hostvar=\"\${HOST_$var}\""
eval "targetvar=\"\${$var}\""
if test -n "$hostvar"; then
eval "$var='$hostvar'"
_AS_ECHO_LOG([host $var='$hostvar'])
elif $retain; then
_AS_ECHO_LOG([host retain $var='$targetvar'])
else
eval "unset $var"
_AS_ECHO_LOG([host unset $var])
fi
done
cd hosttools
"${abssrc}/configure" "--host=$build" "--build=$build" "--enable-clippy-only" "--disable-nhrpd" "--disable-vtysh"
) || exit 1
AC_MSG_NOTICE([...])
AC_MSG_NOTICE([... cross-compilation: finished self-configuring for build platform tools])