From f9b2bb38ef4b39234dc4f6d615d0aea975be5af3 Mon Sep 17 00:00:00 2001
From: Kang-Che Sung <explorer09@gmail.com>
Date: Mon, 6 May 2024 00:38:12 +0800
Subject: [PATCH 3/3] ax_prog_cc_for_build: Allow user override of cache vars
 again

Bring back support of user override of cache variables that have been
broken in serial 20 or earlier. Specifically the user can now override
these cavhe variables again:

* ac_cv_build_exeext
* ac_cv_build_objext
* ac_cv_build_c_compiler_gnu

(Note: The overrides only exist for users to workaround 'configure'
bugs. There is no guarantee that the variable names will be stable.)
---
 m4/ax_prog_cc_for_build.m4 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4
index d707082..95f4f72 100644
--- a/m4/ax_prog_cc_for_build.m4
+++ b/m4/ax_prog_cc_for_build.m4
@@ -32,7 +32,7 @@
 #   and this notice are preserved. This file is offered as-is, without any
 #   warranty.
 
-#serial 26
+#serial 27
 
 AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
 AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
@@ -86,15 +86,21 @@ dnl ac_cv_objext either as they're related.
 dnl Renaming ac_exeext and ac_objext is safe though.
 dnl
 ac_cv_host_exeext=$ac_cv_exeext
-AS_UNSET([ac_cv_exeext])
+AS_VAR_SET_IF([ac_cv_build_exeext],
+  [ac_cv_exeext=$ac_cv_build_exeext],
+  [AS_UNSET([ac_cv_exeext])])
 ac_cv_host_objext=$ac_cv_objext
-AS_UNSET([ac_cv_objext])
+AS_VAR_SET_IF([ac_cv_build_objext],
+  [ac_cv_objext=$ac_cv_build_objext],
+  [AS_UNSET([ac_cv_objext])])
 dnl
 dnl ac_cv_c_compiler_gnu is used in _AC_LANG_COMPILER_GNU (called by
 dnl AC_PROG_CC) indirectly.
 dnl
 ac_cv_host_c_compiler_gnu=$ac_cv_c_compiler_gnu
-AS_UNSET([ac_cv_c_compiler_gnu])
+AS_VAR_SET_IF([ac_cv_build_c_compiler_gnu],
+  [ac_cv_c_compiler_gnu=$ac_cv_build_c_compiler_gnu],
+  [AS_UNSET([ac_cv_c_compiler_gnu])])
 
 cross_compiling_build=no
 
-- 
2.44.0

