]> git.puffer.fish Git - mirror/frr.git/commitdiff
build: improve env var handling for cross build
authorDavid Lamparter <equinox@diac24.net>
Tue, 4 Jun 2019 14:20:20 +0000 (16:20 +0200)
committerDavid Lamparter <equinox@diac24.net>
Wed, 12 Jun 2019 17:22:59 +0000 (19:22 +0200)
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>
configure.ac

index db995bedb57140d4bf5adf446c88315282626dae..589e8dc4412660f98c2e7cfe32754344e8d930d1 100755 (executable)
@@ -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])