Configure cleanups and a fix
cover Configure cleanups and a fix
The first patch is a fix to bring configure inline with the INSTALL documentation which says that HOST_* variables supercede their unprefixed counterparts. In fact, prior to this change the HOST_CC variable was ignored and set unconditionally as $CC.
The following 4 patches are changes to cleanup configure.
Glenn
Glenn Washburn (5):
configure: Allow HOST_CC to override CC
configure: Sort AM_CONDITIONALs alphabetically
configure: Remove dead code
configure: Remove unused CFLAGS definitions
configure: Whitespace changes to improve readability
configure.ac | 151 ++++++++++++++++++++++----------------------------- 1 file changed, 66 insertions(+), 85 deletions(-)
Signature · 1 line
2.27.0
PATCH 1/5 configure: Allow HOST_CC to override CC
According to the INSTALL, "The HOST_* variables override not prefixed variables". This change makes it so, instead of previous behavior, which was to ignore the HOST_CC environment variable.
--- configure.ac | 5 +++++ 1 file changed, 5 insertions(+)
configure.ac +5 -0
@@ -78,6 +78,11 @@ grub_TRANSFORM([grub-sparc64-setup]) grub_TRANSFORM([grub-render-label]) grub_TRANSFORM([grub-file]) +# Allow HOST_CC to override CC +if test "x$HOST_CC" != x; then + CC=$HOST_CC +fi + # Optimization flag. Allow user to override. if test "x$TARGET_CFLAGS" = x; then TARGET_CFLAGS=-Os
Signature · 1 line
2.27.0
Re: [PATCH 1/5] configure: Allow HOST_CC to override CC
Quoted 14 lines · Glenn Washburn
According to the INSTALL, "The HOST_* variables override not prefixed variables". This change makes it so, instead of previous behavior, which was to ignore the
HOST_CCenvironment variable.Signed-off-by Glenn Washburn <[email protected]>--- configure.ac | 5 +++++ 1 file changed, 5 insertions(+)configure.ac +0
-0
configure.ac grub_TRANSFORM([grub-sparc64-setup]) · line 85
Quoted 8 lines
configure.ac +5
-0@@ -78,6 +78,11 @@ grub_TRANSFORM([grub-sparc64-setup]) grub_TRANSFORM([grub-render-label]) grub_TRANSFORM([grub-file]) +# Allow HOST_CC to override CC +if test "x$HOST_CC" != x; then + CC=$HOST_CC +fi +
I am OK with this change but what about the other HOST_* variables mentioned in the INSTALL file, e.g. HOST_CFLAGS? It seems to me we have the same/similar problems with them. Could you fix these issues too?
And it looks the TARGET_* variables also do not work as mentioned in the INSTALL file. So, the INSTALL file should be updated and/or configure.ac fixed.
Daniel
PATCH 2/5 configure: Sort AM_CONDITIONALs alphabetically
In reply to Glenn Washburn--- configure.ac | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
configure.ac +14 -14
@@ -1996,36 +1996,36 @@ AC_SUBST(BUILD_LIBM) AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) +AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) +AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) +AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot]) +AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) +AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) +AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) +AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) -AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_qemu], [test x$target_cpu = xi386 -a x$platform = xqemu]) AM_CONDITIONAL([COND_i386_ieee1275], [test x$target_cpu = xi386 -a x$platform = xieee1275]) AM_CONDITIONAL([COND_i386_coreboot], [test x$target_cpu = xi386 -a x$platform = xcoreboot]) AM_CONDITIONAL([COND_i386_multiboot], [test x$target_cpu = xi386 -a x$platform = xmultiboot]) -AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) AM_CONDITIONAL([COND_i386_xen], [test x$target_cpu = xi386 -a x$platform = xxen]) AM_CONDITIONAL([COND_i386_xen_pvh], [test x$target_cpu = xi386 -a x$platform = xxen_pvh]) -AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) +AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) +AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc]) AM_CONDITIONAL([COND_mips_loongson], [test x$target_cpu = xmipsel -a x$platform = xloongson]) AM_CONDITIONAL([COND_mips_qemu_mips], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xqemu_mips]) -AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu = xmipsel ")" -a x$platform = xarc]) -AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) -AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) -AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) -AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel]) AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips]) -AM_CONDITIONAL([COND_arm], [test x$target_cpu = xarm ]) -AM_CONDITIONAL([COND_arm_uboot], [test x$target_cpu = xarm -a x$platform = xuboot]) -AM_CONDITIONAL([COND_arm_coreboot], [test x$target_cpu = xarm -a x$platform = xcoreboot]) -AM_CONDITIONAL([COND_arm_efi], [test x$target_cpu = xarm -a x$platform = xefi]) -AM_CONDITIONAL([COND_arm64], [test x$target_cpu = xarm64 ]) -AM_CONDITIONAL([COND_arm64_efi], [test x$target_cpu = xarm64 -a x$platform = xefi]) +AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275]) AM_CONDITIONAL([COND_riscv32], [test x$target_cpu = xriscv32 ]) AM_CONDITIONAL([COND_riscv64], [test x$target_cpu = xriscv64 ]) AM_CONDITIONAL([COND_riscv32_efi], [test x$target_cpu = xriscv32 -a x$platform = xefi]) AM_CONDITIONAL([COND_riscv64_efi], [test x$target_cpu = xriscv64 -a x$platform = xefi]) +AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275]) +AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu]) +AM_CONDITIONAL([COND_x86_64_efi], [test x$target_cpu = xx86_64 -a x$platform = xefi]) +AM_CONDITIONAL([COND_x86_64_xen], [test x$target_cpu = xx86_64 -a x$platform = xxen]) AM_CONDITIONAL([COND_HOST_HURD], [test x$host_kernel = xhurd]) AM_CONDITIONAL([COND_HOST_LINUX], [test x$host_kernel = xlinux])
Signature · 1 line
2.27.0
PATCH 3/5 configure: Remove dead code
In reply to Glenn WashburnIt appears as though the intent of this code is to define abort() and main() symbols for some configure tests. However, it never gets used because the if if only entered when not building for *-emu, but the next if block only runs when building for *-emu. And the if block after that unconditionally resets CFLAGS. So this code can have no effect.
Also move grub_ASM_USCORE to put with other marcos defined in aclocal.m4.
--- configure.ac | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
configure.ac +1 -10
@@ -1433,16 +1433,6 @@ CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -grub_ASM_USCORE -if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then -if test x$grub_cv_asm_uscore = xyes; then -DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" -else -DEFSYM="-Wl,--defsym,abort=main -Wl,--defsym,_main=main -Wl,--defsym,__main=main" -fi -CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" -fi - # Check for libgcc symbols if test x"$platform" = xemu; then AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms)
@@ -1456,6 +1446,7 @@ fi LIBS="" # Defined in aclocal.m4. +grub_ASM_USCORE grub_PROG_TARGET_CC if test "x$TARGET_APPLE_LINKER" != x1 ; then grub_PROG_OBJCOPY_ABSOLUTE
Signature · 1 line
2.27.0
PATCH 4/5 configure: Remove unused CFLAGS definitions
In reply to Glenn WashburnThese CFLAGS definitions are reset below them before they have a change to affect anything. The exception is the *-emu case, which is put in the next if block, which is the only place its used before getting reset.
--- configure.ac | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
configure.ac +1 -7
@@ -1424,17 +1424,11 @@ fi # Set them to their new values for the tests below. CC="$TARGET_CC" -if test x"$platform" = xemu ; then -CFLAGS="$TARGET_CFLAGS -Wno-error" -elif test "x$TARGET_APPLE_LINKER" = x1 ; then -CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" -else -CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" -fi CPPFLAGS="$TARGET_CPPFLAGS" # Check for libgcc symbols if test x"$platform" = xemu; then +CFLAGS="$TARGET_CFLAGS -Wno-error" AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __clzdi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) fi
Signature · 1 line
2.27.0
PATCH 5/5 configure: Whitespace changes to improve readability
In reply to Glenn Washburn--- configure.ac | 99 ++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 54 deletions(-)
configure.ac +45 -54
@@ -112,18 +112,10 @@ case "$target_cpu" in target_cpu=mips machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1" ;; - arm*) - target_cpu=arm - ;; - aarch64*) - target_cpu=arm64 - ;; - riscv32*) - target_cpu=riscv32 - ;; - riscv64*) - target_cpu=riscv64 - ;; + arm*) target_cpu=arm ;; + aarch64*) target_cpu=arm64 ;; + riscv32*) target_cpu=riscv32 ;; + riscv64*) target_cpu=riscv64 ;; esac # Specify the platform (such as firmware).
@@ -252,7 +244,7 @@ case "$platform" in emu) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_EMU=1" ;; loongson) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_LOONGSON=1" ;; qemu_mips) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_MIPS_QEMU_MIPS=1" ;; - arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;; + arc) machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE_ARC=1" ;; esac if test x${target_cpu} = xmipsel ; then machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_MACHINE=`echo mips_$platform | sed y,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ,`"
@@ -1476,9 +1468,9 @@ int va_arg_func (int fixed, va_list args);]], [[]])], CPPFLAGS="$SAVED_CPPFLAGS" ]) -if test x"$grub_cv_cc_isystem" = xyes ; then - TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" -fi + if test x"$grub_cv_cc_isystem" = xyes ; then + TARGET_CPPFLAGS="$TARGET_CPPFLAGS -nostdinc -isystem `$TARGET_CC -print-file-name=include`" + fi fi AC_CACHE_CHECK([whether -Wtrampolines work], [grub_cv_cc_wtrampolines], [
@@ -1509,9 +1501,9 @@ AC_ARG_ENABLE([mm-debug], AS_HELP_STRING([--enable-mm-debug], [include memory manager debugging])) if test x$enable_mm_debug = xyes; then - MM_DEBUG=1 + MM_DEBUG=1 else - MM_DEBUG=0 + MM_DEBUG=0 fi AC_SUBST([MM_DEBUG])
@@ -1547,62 +1539,61 @@ AC_ARG_ENABLE([grub-emu-pci], if test "$platform" = emu; then -if test x"$enable_grub_emu_sdl" = xno ; then - grub_emu_sdl_excuse="explicitly disabled" -fi -[if [ x"$grub_emu_sdl_excuse" = x ]; then + if test x"$enable_grub_emu_sdl" = xno ; then + grub_emu_sdl_excuse="explicitly disabled" + fi + [if [ x"$grub_emu_sdl_excuse" = x ]; then # Check for libSDL libraries.] AC_CHECK_LIB([SDL], [SDL_Init], [LIBSDL="-lSDL"], [grub_emu_sdl_excuse=["libSDL libraries are required to build \`grub-emu' with SDL support"]]) AC_SUBST([LIBSDL]) -[fi] + [fi] -[if [ x"$grub_emu_sdl_excuse" = x ]; then + [if [ x"$grub_emu_sdl_excuse" = x ]; then # Check for headers.] AC_CHECK_HEADERS([SDL/SDL.h], [], [grub_emu_sdl_excuse=["libSDL header file is required to build \`grub-emu' with SDL support"]]) -[fi] + [fi] -if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then + if test x"enable_grub_emu_sdl" = xyes && test x"$grub_emu_sdl_excuse" != x ; then AC_MSG_ERROR([SDL support for grub-emu was explicitly requested but can't be compiled ($grub_emu_sdl_excuse)]) -fi -if test x"$grub_emu_sdl_excuse" = x ; then -enable_grub_emu_sdl=yes -else -enable_grub_emu_sdl=no -fi + fi + if test x"$grub_emu_sdl_excuse" = x ; then + enable_grub_emu_sdl=yes + else + enable_grub_emu_sdl=no + fi -if test x"$enable_grub_emu_pci" != xyes ; then - grub_emu_pci_excuse="not enabled" -fi + if test x"$enable_grub_emu_pci" != xyes ; then + grub_emu_pci_excuse="not enabled" + fi -[if [ x"$grub_emu_pci_excuse" = x ]; then - # Check for libpci libraries.] - AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], + [if [ x"$grub_emu_pci_excuse" = x ]; then + # Check for libpci libraries.] + AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], [grub_emu_pci_excuse=["need libpciaccess library"]]) AC_SUBST([LIBPCIACCESS]) -[fi] -[if [ x"$grub_emu_pci_excuse" = x ]; then + [fi] + [if [ x"$grub_emu_pci_excuse" = x ]; then # Check for headers.] AC_CHECK_HEADERS([pciaccess.h], [], [grub_emu_pci_excuse=["need libpciaccess headers"]]) -[fi] + [fi] -if test x"$grub_emu_pci_excuse" = x ; then -enable_grub_emu_pci=yes -else - -enable_grub_emu_pci=no -fi + if test x"$grub_emu_pci_excuse" = x ; then + enable_grub_emu_pci=yes + else + enable_grub_emu_pci=no + fi -AC_SUBST([enable_grub_emu_sdl]) -AC_SUBST([enable_grub_emu_pci]) + AC_SUBST([enable_grub_emu_sdl]) + AC_SUBST([enable_grub_emu_pci]) else -# Ignore --enable-emu-* if platform is not emu -enable_grub_emu_sdl=no -enable_grub_emu_pci=no + # Ignore --enable-emu-* if platform is not emu + enable_grub_emu_sdl=no + enable_grub_emu_pci=no fi AC_ARG_ENABLE([grub-mkfont],
@@ -1634,9 +1625,9 @@ if test x"$enable_grub_mkfont" = xyes && test x"$grub_mkfont_excuse" != x ; then AC_MSG_ERROR([grub-mkfont was explicitly requested but can't be compiled ($grub_mkfont_excuse)]) fi if test x"$grub_mkfont_excuse" = x ; then -enable_grub_mkfont=yes + enable_grub_mkfont=yes else -enable_grub_mkfont=no + enable_grub_mkfont=no fi AC_SUBST([enable_grub_mkfont])
Signature · 1 line
2.27.0
Quoted 7 lines · Glenn Washburn
The first patch is a fix to bring configure inline with the INSTALL documentation which says that HOST_* variables supercede their unprefixed counterparts. In fact, prior to this change the
HOST_CCvariable was ignored and set unconditionally as $CC.The following 4 patches are changes to cleanup configure.
Quoted 8 lines
Glenn
Glenn Washburn (5):
configure: AllowHOST_CCto override CC
configure: SortAM_CONDITIONALsalphabetically
configure: Remove dead code
configure: Remove unused CFLAGS definitions
configure: Whitespace changes to improve readability
For all the patches: Reviewed-by: Daniel Kiper <[email protected]>...
Daniel