# Program name transformations
AC_ARG_PROGRAM
+# Optimization flag. Allow user to override.
+if test "x$TARGET_CFLAGS" = x; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -Os"
+fi
+
case "$target_cpu" in
i[[3456]]86) target_cpu=i386 ;;
sparc) target_cpu=sparc64 ;;
LDFLAGS="$TARGET_LDFLAGS"
LIBS=""
-if test "x$TARGET_CFLAGS" = x; then
- # debug flags.
- TARGET_CFLAGS="-Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
- -Wundef -Wstrict-prototypes -g"
+# debug flags.
+TARGET_CFLAGS="$TARGET_CFLAGS -Wall -W -Wshadow -Wpointer-arith -Wmissing-prototypes \
+ -Wundef -Wstrict-prototypes -g"
- # optimization flags.
- AC_CACHE_CHECK([whether optimization for size works], grub_cv_cc_Os, [
- CFLAGS=-Os
+# Force no alignment to save space on i386.
+if test "x$target_cpu" = xi386; then
+ AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
+ CFLAGS="$CFLAGS -falign-loops=1"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_cc_Os=yes],
- [grub_cv_cc_Os=no])
+ [grub_cv_cc_falign_loop=yes],
+ [grub_cv_cc_falign_loop=no])
])
- if test "x$grub_cv_cc_Os" = xyes; then
- TARGET_CFLAGS="$TARGET_CFLAGS -Os"
- else
- TARGET_CFLAGS="$TARGET_CFLAGS -O2 -fno-strength-reduce -fno-unroll-loops"
- fi
- # Force no alignment to save space on i386.
- if test "x$target_cpu" = xi386; then
- AC_CACHE_CHECK([whether -falign-loops works], [grub_cv_cc_falign_loop], [
- CFLAGS="$CFLAGS -falign-loops=1"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_cc_falign_loop=yes],
- [grub_cv_cc_falign_loop=no])
- ])
-
- if test "x$grub_cv_cc_falign_loop" = xyes; then
- TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
- else
- TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
- fi
-
- # Some toolchains enable these features by default, but they need
- # registers that aren't set up properly in GRUB.
- TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
+ if test "x$grub_cv_cc_falign_loop" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -falign-jumps=1 -falign-loops=1 -falign-functions=1"
+ else
+ TARGET_CFLAGS="$TARGET_CFLAGS -malign-jumps=1 -malign-loops=1 -malign-functions=1"
fi
- # By default, GCC 4.4 generates .eh_frame sections containing unwind
- # information in some cases where it previously did not. GRUB doesn't need
- # these and they just use up vital space. Restore the old compiler
- # behaviour.
- AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
- [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
- [grub_cv_cc_fno_dwarf2_cfi_asm=no])
- CFLAGS="$SAVE_CFLAGS"
- ])
-
- if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
- TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
- fi
+ # Some toolchains enable these features by default, but they need
+ # registers that aren't set up properly in GRUB.
+ TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow"
+fi
+
+# By default, GCC 4.4 generates .eh_frame sections containing unwind
+# information in some cases where it previously did not. GRUB doesn't need
+# these and they just use up vital space. Restore the old compiler
+# behaviour.
+AC_CACHE_CHECK([whether -fno-dwarf2-cfi-asm works], [grub_cv_cc_fno_dwarf2_cfi_asm], [
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -fno-dwarf2-cfi-asm"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [grub_cv_cc_fno_dwarf2_cfi_asm=yes],
+ [grub_cv_cc_fno_dwarf2_cfi_asm=no])
+ CFLAGS="$SAVE_CFLAGS"
+])
+
+if test "x$grub_cv_cc_fno_dwarf2_cfi_asm" = xyes; then
+ TARGET_CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm"
fi
grub_apple_target_cc