diff --git a/ChangeLog b/ChangeLog index e531b719f..60a18994c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +1999-06-27 OKUJI Yoshinori + + * configure.in (CFLAGS): Set to "-g", since only this flag is + always sharable. + (STAGE1_CFLAGS): Set to "-O2", and AC_SUBST this. + (GRUB_CFLAGS): Likewise. + (saved_CFLAGS): New variable for temporarily saving CFLAGS. + (STAGE2_CFLAGS): Set to "-Os" if this option is available, + otherwise set to "-fno-strength-reduce -fno-unroll-loops", + and then AC_SUBST this. + * grub/Makefile.am (AM_CFLAGS): Prepended @GRUB_CFLAGS@. + * stage1/Makefile.am (AM_CFLAGS): Prepended @STAGE1_CFLAGS@. + * stage2/Makefile.am (libgrub_a_CFLAGS): Prepened @GRUB_CFLAGS@. + (STAGE2_COMPILE): Prepended @STAGE2_CFLAGS@. + + * stage2/asm.S (chain_stage2): Pass CURRENT_PARTITION and + CURRENT_DRIVE, instead of INSTALL_PARTITION and BOOT_DRIVE. + 1999-06-27 Pavel Roskin * configure.in: set CFLAGS to "-Os -g" for compilers which diff --git a/Makefile.in b/Makefile.in index 51eb6ed86..11de444e2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -62,12 +62,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ diff --git a/configure b/configure index 8154b5ac8..fee390565 100644 --- a/configure +++ b/configure @@ -1244,24 +1244,29 @@ else fi +# optimization flags if test "x$ac_cv_prog_gcc" = xyes; then if test "x$default_CFLAGS" = xyes; then + CFLAGS="-g" + STAGE1_CFLAGS="-O2" + GRUB_CFLAGS="-O2" echo $ac_n "checking whether optimization for size works""... $ac_c" 1>&6 -echo "configure:1251: checking whether optimization for size works" >&5 +echo "configure:1255: checking whether optimization for size works" >&5 if eval "test \"\${size_flag+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else + saved_CFLAGS=$CFLAGS CFLAGS="-Os -g" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1270: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* size_flag=yes else @@ -1271,25 +1276,30 @@ else size_flag=no fi rm -f conftest* + CFLAGS=$saved_CFLAGS fi echo "$ac_t""$size_flag" 1>&6 if test "x$size_flag" = xyes; then - CFLAGS="-Os -g" + STAGE2_CFLAGS="-Os" else - CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops -g" + STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops" fi fi fi + + + + # Enforce coding standards. CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused" # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. set dummy ${ac_tool_prefix}ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1293: checking for $ac_word" >&5 +echo "configure:1303: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_LD+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1321,7 +1331,7 @@ fi # Extract the first word of "${ac_tool_prefix}objcopy", so it can be a program name with args. set dummy ${ac_tool_prefix}objcopy; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1325: checking for $ac_word" >&5 +echo "configure:1335: checking for $ac_word" >&5 if eval "test \"\${ac_cv_prog_OBJCOPY+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1354,7 +1364,7 @@ fi # Defined in acinclude.m4. echo $ac_n "checking symbol names produced by ${CC-cc}""... $ac_c" 1>&6 -echo "configure:1358: checking symbol names produced by ${CC-cc}" >&5 +echo "configure:1368: checking symbol names produced by ${CC-cc}" >&5 if eval "test \"\${grub_cv_asm_ext_c+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1367,7 +1377,7 @@ func (int *list) } EOF -if { ac_try='${CC-cc} -S conftest.c'; { (eval echo configure:1371: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then : +if { ac_try='${CC-cc} -S conftest.c'; { (eval echo configure:1381: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.s; then : else { echo "configure: error: ${CC-cc} failed to produce assembly code" 1>&2; exit 1; } fi @@ -1396,7 +1406,7 @@ EOF echo $ac_n "checking whether ${OBJCOPY} works for absolute addresses""... $ac_c" 1>&6 -echo "configure:1400: checking whether ${OBJCOPY} works for absolute addresses" >&5 +echo "configure:1410: checking whether ${OBJCOPY} works for absolute addresses" >&5 if eval "test \"\${grub_cv_prog_objcopy_absolute+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1408,21 +1418,21 @@ blah (void) } EOF -if { (eval echo configure:1412: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then : +if { (eval echo configure:1422: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.o; then : else { echo "configure: error: ${CC-cc} cannot compile C source code" 1>&2; exit 1; } fi grub_cv_prog_objcopy_absolute=yes for link_addr in 2000 8000 7C00; do - if { ac_try='${LD-ld} -N -Ttext $link_addr conftest.o -o conftest.exec'; { (eval echo configure:1418: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : + if { ac_try='${LD-ld} -N -Ttext $link_addr conftest.o -o conftest.exec'; { (eval echo configure:1428: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : else { echo "configure: error: ${LD-ld} cannot link at address $link_addr" 1>&2; exit 1; } fi - if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1422: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : + if { ac_try='${OBJCOPY-objcopy} -O binary conftest.exec conftest'; { (eval echo configure:1432: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then : else { echo "configure: error: ${OBJCOPY-objcopy} cannot create binary files" 1>&2; exit 1; } fi - if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1426: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then + if test ! -f conftest.old || { ac_try='cmp -s conftest.old conftest'; { (eval echo configure:1436: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then mv -f conftest conftest.old else grub_cv_prog_objcopy_absolute=no @@ -1439,7 +1449,7 @@ fi echo $ac_n "checking for .code16 addr32 assembler support""... $ac_c" 1>&6 -echo "configure:1443: checking for .code16 addr32 assembler support" >&5 +echo "configure:1453: checking for .code16 addr32 assembler support" >&5 if eval "test \"\${grub_cv_asm_addr32+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1449,7 +1459,7 @@ l1: addr32 movb %al, l1 EOF -if { ac_try='${CC-cc} -c conftest.s'; { (eval echo configure:1453: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then +if { ac_try='${CC-cc} -c conftest.s'; { (eval echo configure:1463: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } && test -s conftest.o; then grub_cv_asm_addr32=yes else grub_cv_asm_addr32=no @@ -1464,7 +1474,7 @@ fi # Check for curses libraries. echo $ac_n "checking for getch in -lncurses""... $ac_c" 1>&6 -echo "configure:1468: checking for getch in -lncurses" >&5 +echo "configure:1478: checking for getch in -lncurses" >&5 ac_lib_var=`echo ncurses'_'getch | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1472,7 +1482,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1497: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1506,7 +1516,7 @@ EOF else echo "$ac_t""no" 1>&6 echo $ac_n "checking for getch in -lcurses""... $ac_c" 1>&6 -echo "configure:1510: checking for getch in -lcurses" >&5 +echo "configure:1520: checking for getch in -lcurses" >&5 ac_lib_var=`echo curses'_'getch | sed 'y%./+-:%__p__%'` if eval "test \"\${ac_cv_lib_$ac_lib_var+set}\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1514,7 +1524,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1539: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1727,6 +1737,9 @@ s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g s%@CC@%$CC%g s%@RANLIB@%$RANLIB%g +s%@STAGE1_CFLAGS@%$STAGE1_CFLAGS%g +s%@STAGE2_CFLAGS@%$STAGE2_CFLAGS%g +s%@GRUB_CFLAGS@%$GRUB_CFLAGS%g s%@LD@%$LD%g s%@OBJCOPY@%$OBJCOPY%g s%@GRUB_LIBS@%$GRUB_LIBS%g diff --git a/configure.in b/configure.in index c956d1a69..7853910cf 100644 --- a/configure.in +++ b/configure.in @@ -56,20 +56,30 @@ AC_CHECK_TOOL(CC, gcc) AC_PROG_CC AC_PROG_RANLIB +# optimization flags if test "x$ac_cv_prog_gcc" = xyes; then if test "x$default_CFLAGS" = xyes; then + CFLAGS="-g" + STAGE1_CFLAGS="-O2" + GRUB_CFLAGS="-O2" AC_CACHE_CHECK([whether optimization for size works], size_flag, [ + saved_CFLAGS=$CFLAGS CFLAGS="-Os -g" AC_TRY_COMPILE(, , size_flag=yes, size_flag=no) + CFLAGS=$saved_CFLAGS ]) if test "x$size_flag" = xyes; then - CFLAGS="-Os -g" + STAGE2_CFLAGS="-Os" else - CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops -g" + STAGE2_CFLAGS="-O2 -fno-strength-reduce -fno-unroll-loops" fi fi fi +AC_SUBST(STAGE1_CFLAGS) +AC_SUBST(STAGE2_CFLAGS) +AC_SUBST(GRUB_CFLAGS) + # Enforce coding standards. CPPFLAGS="$CPPFLAGS -Wall -Wmissing-prototypes -Wunused" diff --git a/debian/Makefile.in b/debian/Makefile.in index d964484c8..8233eaa3f 100644 --- a/debian/Makefile.in +++ b/debian/Makefile.in @@ -62,12 +62,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ diff --git a/docs/Makefile.in b/docs/Makefile.in index f9462d8a0..2e2121f41 100644 --- a/docs/Makefile.in +++ b/docs/Makefile.in @@ -62,12 +62,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ diff --git a/grub/Makefile.am b/grub/Makefile.am index f101b7318..2433bc7f2 100644 --- a/grub/Makefile.am +++ b/grub/Makefile.am @@ -1,6 +1,7 @@ sbin_PROGRAMS = grub -AM_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings -I$(top_srcdir)/stage2 +AM_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings \ + -I$(top_srcdir)/stage2 grub_SOURCES = main.c asmstub.c grub_LDADD = ../stage2/libgrub.a @GRUB_LIBS@ diff --git a/grub/Makefile.in b/grub/Makefile.in index 8969f00d4..8c00d259c 100644 --- a/grub/Makefile.in +++ b/grub/Makefile.in @@ -62,12 +62,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ @@ -76,7 +79,9 @@ install_sh = @install_sh@ sbin_PROGRAMS = grub -AM_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings -I$(top_srcdir)/stage2 +AM_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings \ + -I$(top_srcdir)/stage2 + grub_SOURCES = main.c asmstub.c grub_LDADD = ../stage2/libgrub.a @GRUB_LIBS@ diff --git a/stage1/Makefile.am b/stage1/Makefile.am index 901ca65e6..19c29e1f4 100644 --- a/stage1/Makefile.am +++ b/stage1/Makefile.am @@ -3,7 +3,7 @@ nodist_pkgdata_DATA = stage1 CLEANFILES = $(pkgdata_DATA) # We can't use builtins or standard includes. -AM_CFLAGS = -fno-builtin -nostdinc +AM_CFLAGS = @STAGE1_CFLAGS@ -fno-builtin -nostdinc noinst_PROGRAMS = stage1.exec stage1_exec_SOURCES = stage1.S diff --git a/stage1/Makefile.in b/stage1/Makefile.in index c7729b82b..42d85d93f 100644 --- a/stage1/Makefile.in +++ b/stage1/Makefile.in @@ -60,12 +60,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ @@ -77,7 +80,7 @@ nodist_pkgdata_DATA = stage1 CLEANFILES = $(pkgdata_DATA) # We can't use builtins or standard includes. -AM_CFLAGS = -fno-builtin -nostdinc +AM_CFLAGS = @STAGE1_CFLAGS@ -fno-builtin -nostdinc noinst_PROGRAMS = stage1.exec stage1_exec_SOURCES = stage1.S diff --git a/stage2/Makefile.am b/stage2/Makefile.am index 9d8b07c9c..21f89b26e 100644 --- a/stage2/Makefile.am +++ b/stage2/Makefile.am @@ -12,7 +12,7 @@ EXTRA_DIST = smp-imps.c $(noinst_SCRIPTS) noinst_LIBRARIES = libgrub.a libgrub_a_SOURCES = boot.c common.c char_io.c cmdline.c disk_io.c \ gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c stage2.c -libgrub_a_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings +libgrub_a_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings # Stage 2 and Stage 1.5's. pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor) @@ -23,7 +23,7 @@ noinst_PROGRAMS = stage2.exec e2fs_stage1_5.exec fat_stage1_5.exec \ MOSTLYCLEANFILES = $(noinst_PROGRAMS) STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 -STAGE2_COMPILE = -fno-builtin -nostdinc +STAGE2_COMPILE = @STAGE2_CFLAGS@ -fno-builtin -nostdinc STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 \ diff --git a/stage2/Makefile.in b/stage2/Makefile.in index a87c9636d..1bfc32762 100644 --- a/stage2/Makefile.in +++ b/stage2/Makefile.in @@ -60,12 +60,15 @@ host_triplet = @host@ AMTAR = @AMTAR@ AMTARFLAGS = @AMTARFLAGS@ CC = @CC@ +GRUB_CFLAGS = @GRUB_CFLAGS@ GRUB_LIBS = @GRUB_LIBS@ LD = @LD@ MAKEINFO = @MAKEINFO@ OBJCOPY = @OBJCOPY@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ +STAGE1_CFLAGS = @STAGE1_CFLAGS@ +STAGE2_CFLAGS = @STAGE2_CFLAGS@ VERSION = @VERSION@ host_cpu = @host_cpu@ host_vendor = @host_vendor@ @@ -89,7 +92,7 @@ noinst_LIBRARIES = libgrub.a libgrub_a_SOURCES = boot.c common.c char_io.c cmdline.c disk_io.c \ gunzip.c fsys_ffs.c fsys_ext2fs.c fsys_fat.c stage2.c -libgrub_a_CFLAGS = -DGRUB_UTIL=1 -fwritable-strings +libgrub_a_CFLAGS = @GRUB_CFLAGS@ -DGRUB_UTIL=1 -fwritable-strings # Stage 2 and Stage 1.5's. pkgdatadir = $(datadir)/$(PACKAGE)/$(host_cpu)-$(host_vendor) @@ -101,7 +104,7 @@ noinst_PROGRAMS = stage2.exec e2fs_stage1_5.exec fat_stage1_5.exec \ MOSTLYCLEANFILES = $(noinst_PROGRAMS) STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000 -STAGE2_COMPILE = -fno-builtin -nostdinc +STAGE2_COMPILE = @STAGE2_CFLAGS@ -fno-builtin -nostdinc STAGE1_5_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,2000 STAGE1_5_COMPILE = $(STAGE2_COMPILE) -DNO_DECOMPRESSION=1 -DSTAGE1_5=1 \ diff --git a/stage2/asm.S b/stage2/asm.S index 9f5f7feba..a02bd2cde 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -201,12 +201,12 @@ ENTRY(chain_stage2) /* generate linear address */ addl %eax, %ebx - /* store install info */ - movl EXT_C(install_partition), %eax + /* set up to pass the partition where stage2 is located in */ + movl EXT_C(current_partition), %eax movl %eax, EXT_C(install_partition)-EXT_C(start)(%ebx) - /* set up to pass boot drive */ - movb EXT_C(boot_drive), %dl + /* set up to pass the drive where stage2 is located in */ + movb EXT_C(current_drive), %dl call EXT_C(prot_to_real) .code16