[PATCH 1/2] ax_prog_cc_for_build: Fix BUILD_{EXE, OBJ}EXT for Autoconf 2.70
Kang-Che Sung <[email protected]> Sun, 5 May 2024 04:24:26 +0800
| Newsgroups | gmane.comp.sysutils.autoconf.archive-maintainers |
|---|---|
| Message-ID | <CADDzAfN7mdaw=5asm=TBfrAPEf6y1XkG3-6s1BwSEGn4Ttq6rA@mail.gmail.com> |
Autoconf 2.70 introduced a change in AC_SUBST behavior that the variable name in AC_SUBST no longer gets macro expanded. This breaks the rename syntaxes of BUILD_EXEEXT and BUILD_OBJEXT in AX_PROG_CC_FOR_BUILD. Change to an alternative approach of assigning BUILD_EXEEXT and BUILD_OBJEXT manually. The values of EXEEXT and OBJEXT have to be fixed too at the end of the AX_PROG_CC_FOR_BUILD code. --- m4/ax_prog_cc_for_build.m4 | 39 +++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4 index 1db8d73..0f92825 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 21 +#serial 22 AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl @@ -51,8 +51,6 @@ pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl -pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl -pushdef([ac_cv_objext], ac_cv_build_objext)dnl pushdef([ac_exeext], ac_build_exeext)dnl pushdef([ac_objext], ac_build_objext)dnl pushdef([CC], CC_FOR_BUILD)dnl @@ -60,9 +58,7 @@ pushdef([CPP], CPP_FOR_BUILD)dnl pushdef([GCC], GCC_FOR_BUILD)dnl pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl -pushdef([EXEEXT], BUILD_EXEEXT)dnl pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl -pushdef([OBJEXT], BUILD_OBJEXT)dnl pushdef([host], build)dnl pushdef([host_alias], build_alias)dnl pushdef([host_cpu], build_cpu)dnl @@ -78,6 +74,21 @@ pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compi pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl pushdef([cross_compiling], cross_compiling_build)dnl +dnl These variables are problematic to rename by M4 macros, so we save +dnl their values in alternative names, and restore the values later. +dnl +dnl _AC_COMPILER_EXEEXT and _AC_COMPILER_OBJEXT internally call +dnl AC_SUBST which prevents the renaming of EXEEXT and OBJEXT +dnl variables. It's not a good idea to rename ac_cv_exeext and +dnl ac_cv_objext either as they're related. +dnl Renaming ac_exeext and ac_objext is safe though. +AS_VAR_SET_IF([ac_cv_exeext], + [ac_cv_host_exeext=$ac_cv_exeext + AS_UNSET([ac_cv_exeext])]) +AS_VAR_SET_IF([ac_cv_objext], + [ac_cv_host_objext=$ac_cv_objext + AS_UNSET([ac_cv_objext])]) + cross_compiling_build=no ac_build_tool_prefix= @@ -120,9 +131,7 @@ popdef([host_vendor])dnl popdef([host_cpu])dnl popdef([host_alias])dnl popdef([host])dnl -popdef([OBJEXT])dnl popdef([LDFLAGS])dnl -popdef([EXEEXT])dnl popdef([CPPFLAGS])dnl popdef([CFLAGS])dnl popdef([GCC])dnl @@ -130,8 +139,6 @@ popdef([CPP])dnl popdef([CC])dnl popdef([ac_objext])dnl popdef([ac_exeext])dnl -popdef([ac_cv_objext])dnl -popdef([ac_cv_exeext])dnl popdef([ac_cv_c_compiler_gnu])dnl popdef([ac_cv_prog_cc_g])dnl popdef([ac_cv_prog_cc_cross])dnl @@ -140,6 +147,20 @@ popdef([ac_cv_prog_cc_c89])dnl popdef([ac_cv_prog_gcc])dnl popdef([ac_cv_prog_CPP])dnl +BUILD_EXEEXT=$ac_cv_exeext +BUILD_OBJEXT=$ac_cv_objext + +AS_VAR_SET_IF([ac_cv_host_exeext], + [ac_cv_exeext=$ac_cv_host_exeext + EXEEXT=$ac_cv_host_exeext], + [AS_UNSET([ac_cv_exeext]) + AS_UNSET([EXEEXT])]) +AS_VAR_SET_IF([ac_cv_host_objext], + [ac_cv_objext=$ac_cv_host_objext + OBJEXT=$ac_cv_host_objext], + [AS_UNSET([ac_cv_objext]) + AS_UNSET([OBJEXT])]) + dnl restore global variables ac_ext, ac_cpp, ac_compile, dnl ac_link, ac_compiler_gnu (dependant on the current dnl language after popping): -- 2.44.0