Parttool autoloading and improvements
* Makefile.in (pkglib_DATA): add parttool.lst
(parttool.lst): new target
* genmk.rb: generate parttool-*
(CLEANFILES): add #{parttool}
(PARTTOOLFILES): new variable
* genparttoollist.sh: new file
* parttool/pcpart.c (grub_pcpart_boot): more feedback
(grub_pcpart_type): likewise
* commands/parttool.c (helpmsg): new variable
(grub_cmd_parttool): output help if not enough arguments are supplied
autoload modules
(GRUB_MOD_INIT(parttool)): use helpmsg
Filter /etc/grub.d/10_* so that only add-ons for native kernels are
installed.
* Makefile.in (host_kernel): New variable.
* conf/common.rmk (grub-mkconfig_SCRIPTS): Conditionalize all 10_*.in
scripts instead of just the windows one.
* configure.ac: Initialize and AC_SUBST `host_kernel'.
* util/update-grub_lib.in: Copy to ...
* util/grub-mkconfig_lib.in: ... this. Update all users.
* util/update-grub_lib.in: Make it a stub to `grub-mkconfigig_lib.in'.
* util/update-grub.in: Rename to ...
* util/grub-mkconfig.in: ... this. Update all users. Remove `-y'
option. Add `--output' option to allow users to specify the generated
configuration file. Default to stdout.
(update_grub_dir): Rename to ...
(grub_mkconfig_dir): ... this.
(grub_cfg): Default to an empty string.
* conf/common.rmk (update-grub): Rename to ...
(grub-mkconfig): ... this.
(update-grub_lib): Copy to ...
(grub-mkconfig_lib): ... this.
(update-grub_SCRIPTS): Copy to ...
(grub-mkconfig_SCRIPTS): ... this. Update all users.
(update-grub_DATA): Rename to ...
(grub-mkconfig_DATA): ... this.
* Makefile.in: Add `target_os' and `enable_grub_pe2elf'.
* conf/common.rmk: Install `grub-pe2elf' only if requested.
Install `grub.d/10_windows' only on Cygwin.
* configure.ac: Add subst of `target_os'.
Check `target_os' also before setting TARGET_OBJ2ELF.
Add `--enable-grub-pe2elf'.
* common.rmk (bin_UTILITIES): Add grub-pe2elf.
(grub_pe2elf_SOURCES): New macro.
(CLEANFILES): Add grub-pe2elf.
* include/grub/efi/pe32.h (GRUB_PE32_SCN_ALIGN_1BYTES): New constant.
(GRUB_PE32_SCN_ALIGN_2BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_4BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_8BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_16BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_32BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_64BYTES): Likewise.
(GRUB_PE32_SCN_ALIGN_SHIFT): Likewise.
(GRUB_PE32_SCN_ALIGN_MASK): Likewise.
(GRUB_PE32_SYM_CLASS_EXTERNAL): Likewise.
(GRUB_PE32_SYM_CLASS_STATIC): Likewise.
(GRUB_PE32_SYM_CLASS_FILE): Likewise.
(GRUB_PE32_DT_FUNCTION): Likewise.
(GRUB_PE32_REL_I386_DIR32): Likewise.
(GRUB_PE32_REL_I386_REL32): Likewise.
(grub_pe32_symbol): New structure.
(grub_pe32_reloc): Likewise.
* util/grub-pe2elf.c: New file.
* configure.ac: Set TARGET_OBJ2ELF if host os is cygwin. Don't test for
start symbol in non pc platform.
* genmk.rb: Use TARGET_OBJ2ELF to convert native object format to elf.
The following patches are from Christian Franke.
* include/grub/dl.h: Remove .previous, gas supports this only
for ELF format.
* include/grub/symbol.h [__CYGWIN__] (#define FUNCTION/VARIABLE):
Remove .type, gas supports this only for ELF format.
* kern/dl.c (grub_dl_resolve_dependencies): Add check for trailing
nullbytes in symbol table. This fixes an infinite loop if table is
zero filled.
* Makefile.in: Add autoconf replacements TARGET_IMG_LDSCRIPT,
TARGET_IMG_LDFLAGS and EXEEXT.
* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): Replace -Wl,-N by
TARGET_IMG_LDFLAGS_AC.
(grub_CHECK_STACK_ARG_PROBE): New function.
* conf/i386-pc.rmk: Replace -Wl,-N by TARGET_IMG_LDFLAGS.
* conf/i386-pc-cygwin-ld-img.sc: New linker script.
* configure.ac: Add check for linker script "conf/${target}-img-ld.c"
to set TARGET_IMG_LD* accordingly.
Add check for Cygwin to set TARGET_MOD_OBJCOPY accordingly.
Add call to grub_CHECK_STACK_ARG_PROBE.
Use TARGET_IMG_LDFLAGS to check start, bss_start, end symbols.
* genkernsyms.sh.in: Handle HAVE_ASM_USCORE case.
* genmk.rb: Add EXEEXT to CLEANFILES.
* Makefile.in (UNICODE_ARROWS, UNICODE_LINES): New variables (they
define the codes for arrows and lines used for the menu).
(ascii.pff): Generate fonts for $(UNICODE_ARROWS) and $(UNICODE_LINES)
as well.
* util/update-grub_lib.in (font_path): Prefer ascii.pff over complete
fonts, because the latter are too slow.
* Makefile.in (MODULE_LDFLAGS): New variable.
* aclocal.m4 (grub_PROG_LD_BUILD_ID_NONE): New macro. Check if
the linker accepts --build-id=none.
* configure.ac: Call grub_PROG_LD_BUILD_ID_NONE. Substitute
MODULE_LDFLAGS.
* genmk.rb: Use MODULE_LDFLAGS when linking modules.
* Makefile.in (RMKFILES): Add missing arch i386-ieee1275 and
i386-linuxbios.
* commands/hexdump.c (grub_cmd_hexdump): Support dumping of device,
change the buffer size to 4096 for cdrom device.
* conf/i386-ieee1275.rmk (pkglib_MODULES): Add _linux.mod, linux.mod
and nand.mod.
(_linux_mod_SOURCES): New variable.
(_linux_mod_CFLAGS): Likewise.
(_linux_mod_LDFLAGS): Likewise.
(linux_mod_SOURCES): Likewise.
(linux_mod_CFLAGS): Likewise.
(linux_mod_LDFLAGS): Likewise.
(nand_mod_SOURCES): Likewise.
(nand_mod_CFLAGS): Likewise.
(nand_mod_LDFLAGS): Likewise.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): Return
GRUB_ERR_UNKNOWN_DEVICE instead of GRUB_ERR_BAD_DEVICE if no device
type property. (nand device in olpc don't have this property)
* include/grub/disk.h (grub_disk_dev_id): New macro
GRUB_DISK_DEVICE_NAND_ID.
* include/grub/i386/ieee1275/loader.h (grub_rescue_cmd_linux): New
function prototype.
(grub_rescue_cmd_initrd): Likewise.
* include/grub/i386/linux.h (GRUB_LINUX_OFW_SIGNATURE): New macro.
(linux_kernel_params): Add new member ofw_signature, ofw_num_items,
ofw_cif_handler and ofw_idt, adjust padding number.
* include/grub/i386/pc/memory.h (grub_upper_mem): Export it if
GRUB_MACHINE_IEEE1275 is defined.
* include/grub/ieee1275/ieee1275.h (grub_available_iterate):
Use NESTED_FUNC_ATTR attribute on the hook parameter.
* kern/powerpc/ieee1275/init.c (grub_claim_heap): Use NESTED_FUNC_ATTR
on nested function heap_init.
(grub_upper_mem): New variable for i386-ieee1275.
(grub_get_extended_memory): New function for i386-ieee1275.
(grub_machine_init): Call grub_get_extended_memory for i386-ieee1275.
* kern/powerpc/ieee1275/openfw.c (grub_available_iterate): Use
NESTED_FUNC_ATTR on the hook parameter. Don't quit if no device type
property.
* loader/i386/ieee1275/linux.c: New file.
* loader/i386/ieee1275/linux_normal.c: New file.
* disk/ieee1275/nand.c: New file.
* configure.ac: Probe for `help2man'.
* Makefile.in (builddir): New variable.
(HELP2MAN): Likewise. Set to `true' when @HELP2MAN@ doesn't provide it,
or otherwise add a few flags/options to it.
(install-local): For every executable utility or script that is
installed, invoke $(HELP2MAN) to install a manpage based on --help
output.
* util/i386/pc/grub-install.in: Move down `update-grub_lib' sourcing, so
that it doesn't prevent --help from working in build tree.
* util/i386/pc/grub-mkrescue.in (usage): Replace `grub-devel@gnu.org'
with `bug-grub@gnu.org'.
* util/powerpc/ieee1275/grub-mkrescue.in (usage): Likewise.
* util/update-grub.in (usage): New function.
Implement proper argument check, with support for --help and --version
(as well as existing -y).
* configure.ac: Search for possible unifont.hex locations, and
define UNIFONT_HEX if found.
* Makefile.in (UNIFONT_HEX): Define variable.
(DATA): Rename to ...
(PKGLIB): ... this. Update all users.
(PKGDATA): New variable.
(pkgdata_IMAGES): Rename to ...
(pkglib_IMAGES): ... this. Update all users.
(pkgdata_MODULES): Rename to ...
(pkglib_MODULES): ... this. Update all users.
(pkgdata_PROGRAMS): Rename to ...
(pkglib_PROGRAMS): ... this. Update all users.
(pkgdata_DATA): Rename to ...
(pkglib_DATA): ... this. Update all users.
(CLEANFILES): Redefine to `$(pkglib_DATA) $(pkgdata_DATA)'.
(unicode.pff, ascii.pff): New rules.
(all-local): Add `$(PKGDATA)' dependency.
(install-local): Process `$(PKGDATA)'.
* util/update-grub_lib.in (font_path): Search for *.pff files in
a few more locations, including `${pkgdata}'.
* util/update-grub_lib.in: New file.
* DISTLIST: Add update-grub_lib.in.
* conf/common.rmk: Generate update-grub_lib and install it in
$(lib_DATA).
* Makefile.in: Add install routine for $(lib_DATA).
* util/grub.d/00_header.in: Use convert_system_path_to_grub_path()
function provided by update-grub_lib to support arbitrary paths of
unifont.pff.
* util/update-grub.in: Use convert_system_path_to_grub_path() to
initialize GRUB_DRIVE_BOOT and GRUB_DRIVE_BOOT_GRUB variables.
./configure --program-transform-name="s/grub/grub2/"
And the installed files (in this case for i386-pc) will be:
/usr/lib/grub2/i386-pc/*
/usr/local/sbin/grub2-emu
/usr/local/sbin/grub2-install
...etc
Also grub2-install place boot files in "/boot/grub2"
This allows easy integration into distributions as it allows grub2 to
sit side by side with a grub legacy install without.
* Makefile.in (enable_grub_emu): New variable.
* configure.ac (--enable-grub-emu): New option.
Do the checks for (n)curses only if `--enable-grub-emu' is requested.
* conf/i386-efi.rmk (sbin_UTILITIES): Add `grub-emu' only if requested.
* conf/i386-pc.rmk: Likewise.
* conf/powerpc-ieee1275.rmk: Likewise.
* conf/sparc64-ieee1275.rmk (bin_UTILITIES): Likewise.
Add --with-platform to configure. Use pkglibdir instead of
pkgdatadir. This is reported by Roger Leigh.
* util/powerpc/ieee1275/grub-install.in (datadir): Removed.
(host_vendor): Likewise.
(host_os): Likewise.
(pkgdatadir): Likewise.
(platform): New variable.
(pkglibdir): Likewise.
Use PKGLIBDIR instead of PKGDATADIR.
* util/i386/pc/grub-install.in (datadir): Removed.
(host_vendor): Likewise.
(host_os): Likewise.
(pkgdatadir): Likewise.
(platform): New variable.
(pkglibdir): Likewise.
Use PKGLIBDIR instead of PKGDATADIR.
* util/powerpc/ieee1275/grub-mkimage.c (usage): Use GRUB_LIBDIR
instead of GRUB_DATADIR.
(main): Likewise.
* util/i386/pc/grub-mkimage.c (usage): Likewise.
(main): Likewise.
* util/i386/efi/grub-mkimage.c (usage): Likewise.
(main): Likewise.
* configure.ac (--with-platform): New option.
Use PLATFORM instead of HOST_VENDOR to specify a platform.
* Makefile.in: Include a makefile based on PLATFORM instead of
HOST_VENDOR.
(pkgdatadir): Not appended by the machine type.
(pkglibdir): Appended by the machine type.
(host_vendor): Removed.
(platform): New variable.
(BUILD_CPPFLAGS): Specify GRUB_LIBDIR instead of GRUB_DATADIR.
(install-local): Use PKGLIBDIR instead of PKGDATADIR.
(uninstall): Likewise.
* INSTALL: GNU Bison is required.
* configure.ac: Rewritten the test to detect Bison.
* Makefile.in (YACC): New variable. Reported by Xun Sun
<xun.sun.cn@gmail.com>.
* Makefile.in (LIBLZO): New variable.
* configure.ac: Check for LZO version 2.
* util/i386/pc/grub-mkimage.c [HAVE_LZO_LZO1X_H]: Include
lzo/lzo1x.h instead of lzo1x.h.
* conf/i386-pc.rmk (grub_mkimage_LDFLAGS): Use $(LIBLZO) instead
of -llzo.
* util/i386/pc/grub-setup.c (main): Do not free PREFIX
twice. Reported by Vladimir Serbinenko <phcoder@gmail.com>.
* partmap/pc.c (pc_partition_map_probe): Restore P->DATA after
copying the data from PARTITION to P.
* kern/rescue.c (grub_rescue_cmd_rmmod): If the reference count is
negative, unload the module.
* util/i386/pc/grub-setup.c (setup): The name of the PC partition
map is "pc_partition_map" but not "pc".
(usage): Fix the description. The options are --boot-image and
--core-image but not --boot-file or --core-file.
(main): If not specified explicitly, make BOOT_FILE and CORE_FILE
based on DEFAULT_BOOT_FILE and DEFAULT_CORE_FILE with DIR or
DEFAULT_DIRECTORY.
* util/i386/pc/grub-install.in: Do not specify --boot-file or
--core-file. Specify INSTALL_DEVICE as an argument.
* util/console.c: Include config.h.
[HAVE_NCURSeS_CURSES_H]: Include ncurses/curses.h.
[HAVE_NCURSES_H]: Include ncurses.h.
[HAVE_CURSES_H]: Include curses.h.
[!A_NORMAL] (A_NORMAL): Defined as zero.
[!A_STANDOUT] (A_STANDOUT): Likewise.
* conf/i386-pc.rmk (grub_emu_LDFLAGS): Use $(LIBCURSES) instead of
-lncurses.
* conf/powerpc-ieee1275.rmk (grub_emu_LDFLAGS): Likewise.
* configure.ac: Check for curses libraries and headers.
* Makefile.in (LIBCURSES): New variable.
* genmk.rb (Script::rule): Set the executable bits.
* util/i386/pc/biosdisk.c (grub_util_biosdisk_get_grub_dev): The
name of the PC partition map is "pc_partition_map" but not "pc".
* DISTLIST: Added util/i386/pc/grub-install.in.
* util/i386/pc/grub-install.in: New file.
* conf/i386-pc.rmk (sbin_SCRIPTS): New variable.
(grub_install_SOURCES): Likewise.
* genmk.rb: Added support for scripts.
(Script): New class.
(scripts): New variable.
* Makefile.in (install-local): Install sbin_SCRIPTS by
INSTALL_SCRIPT.
(uninstall): Remove sbin_SCRIPTS.
* util/i386/pc/grub-setup.c (main): If the argument is not a GRUB
device, try to get a GRUB device by
grub_util_biosdisk_get_grub_dev.
Free DEST_DEV.
* util/i386/pc/grub-mkdevicemap.c (usage): Remove a duplicated
description for --device-map.
* DISTLIST: New file.
* gendistlist.sh: Likewise.
* Makefile.in (COMMON_DISTFILES): Removed.
(BOOT_DISTFILES): Likewise.
(CONF_DISTFILES): Likewise.
(DISK_DISTFILES): Likewise.
(FS_DISTFILES): Likewise.
(INCLUDE_DISTFILES): Likewise.
(KERN_DISTFILES): Likewise.
(LOADER_DISTFILES): Likewise.
(TERM_DISTFILES): Likewise.
(UTIL_DISTFILES): Likewise.
(DISTFILES): Likewise.
(uninstall): Uninstall files in $(pkgdata_DATA).
(DISTLIST): New target.
(distdir): Use the contents of the file DISTLIST to get a list of
distributed files.
* commands/default.h: New file.
* commands/timeout.h: Likewise.
* normal/context.c: Likewise.
* util/misc.c: Do not include sys/times.h.
Include sys/time.h and grub/machine/time.h.
(grub_get_rtc): Rewritten with gettimeofday.
* util/grub-emu.c (main): Call grub_default_init and
grub_timeout_init before grub_normal_init, and call
grub_timeout_fini and grub_default_fini after grub_main.
* util/console.c (grub_ncurses_checkkey): Return the read
character or -1.
* normal/menu.c (run_menu): Set MENU->TIMEOUT to -1 once it
timeouts.
* normal/main.c (read_config_file): Push MENU. If this fails,
print an error and wait for a user input.
Print an error only if GRUB_ERRNO is not GRUB_ERR_NONE.
If a menu is empty or an error occurs, pop MENU.
(grub_normal_execute): Pop and free MENU after grub_menu_run
returns.
* kern/loader.c (grub_loader_boot): Call grub_machine_fini.
* include/grub/powerpc/ieee1275/time.h [GRUB_UTIL]: Do not
include time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/i386/pc/time.h [GRUB_UTIL]: Do not include
time.h.
[GRUB_UTIL] (GRUB_TICKS_PER_SECOND): Use the same definition as
without GRUB_UTIL.
* include/grub/normal.h (struct grub_menu_list): New struct.
(grub_menu_list_t): New type.
(struct grub_context): New struct.
(grub_context_t): New type.
(grub_register_command): Got rid of EXPORT_FUNC.
(grub_unregister_command): Likewise.
(grub_context_get): New prototype.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
[GRUB_UTIL] (grub_default_init): Likewise.
[GRUB_UTIL] (grub_default_fini): Likewise.
[GRUB_UTIL] (grub_timeout_init): Likewise.
[GRUB_UTIL] (grub_timeout_fini): Likewise.
* conf/i386-pc.rmk (grub_emu_SOURCES): Added commands/default.c,
commands/timeout.c and normal/context.c.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Copied from
conf/i386-pc.rmk.
(pkgdata_MODULES): Added default.mod and timeout.mod.
(normal_mod_SOURCES): Added normal/context.c.
(default_mod_SOURCES): New variable.
(default_mod_CFLAGS): Likewise.
(timeout_mod_SOURCES): Likewise.
(timeout_mod_CFLAGS): Likewise.
* Makefile.in (all-local): Added $(MKFILES).