sim: set up build-time compiler settings

Message ID 20210222044404.12333-1-vapier@gentoo.org
State New
Headers show
Series
  • sim: set up build-time compiler settings
Related show

Commit Message

Kevin Buettner via Gdb-patches Feb. 22, 2021, 4:44 a.m.
Some sim dirs were already setting up CFLAGS_FOR_BUILD in inconsistent
ways.  Move it to a common place for reuse.
---
 sim/m4/sim_ac_common.m4 | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.30.0

Patch

diff --git a/sim/m4/sim_ac_common.m4 b/sim/m4/sim_ac_common.m4
index 0f3052abec37..f67c7f8be937 100644
--- a/sim/m4/sim_ac_common.m4
+++ b/sim/m4/sim_ac_common.m4
@@ -30,15 +30,16 @@  AC_C_BIGENDIAN
 AC_ARG_PROGRAM
 AC_PROG_INSTALL
 
-# Put a plausible default for CC_FOR_BUILD in Makefile.
-if test -z "$CC_FOR_BUILD"; then
-  if test "x$cross_compiling" = "xno"; then
-    CC_FOR_BUILD='$(CC)'
-  else
-    CC_FOR_BUILD=gcc
-  fi
+dnl Setup toolchain settings for build-time tools..
+if test "x$cross_compiling" = "xno"; then
+  : "${CC_FOR_BUILD:=\$(CC)}"
+  : "${CFLAGS_FOR_BUILD:=\$(CFLAGS)}"
+else
+  : "${CC_FOR_BUILD:=gcc}"
+  : "${CFLAGS_FOR_BUILD:=-g -O}"
 fi
 AC_SUBST(CC_FOR_BUILD)
+AC_SUBST(CFLAGS_FOR_BUILD)
 
 AC_SUBST(CFLAGS)
 AC_CHECK_TOOL(AR, ar)