From 5822ff87a221efce7ee75a2819f8cb064b1e509e Mon Sep 17 00:00:00 2001 From: okuji Date: Tue, 8 Mar 2005 01:01:06 +0000 Subject: [PATCH] 2005-03-08 Yoshinori Okuji Automatic loading of commands is supported. * normal/main.c (read_command_list): New function. (grub_normal_execute): Call read_command_list. * normal/command.c (grub_register_command): Return zero or CMD. Allocate CMD->NAME from the heap. Initialize CMD->MODULE_NAME to zero. Find the same name as well. If the same command is found and it is a dummy command, overwrite members. If it is not a dummy command, return zero. (grub_unregister_command): Free Q->NAME and Q->MODULE_NAME. (grub_command_find): If a dummy command is found, load a module and retry to find a command only once. * normal/cmdline.c (grub_tab_complete): Call grub_command_find to make sure that each command is loaded. * include/grub/normal.h (GRUB_COMMAND_FLAG_NOT_LOADED): New macro. (struct grub_command): Remove const from the member `name'. Add a new member `module_name'. (grub_register_command): Return grub_command_t. * commands/help.c (grub_cmd_help): Call grub_command_find to make sure that each command is loaded. * genmk.rb (PModule::rule): Specify a module name without the suffix ".mod" to gencmdlist.sh. --- ChangeLog | 32 ++++++++++++++++ commands/help.c | 43 ++++++++++++--------- conf/i386-pc.mk | 80 +++++++++++++++++++------------------- conf/powerpc-ieee1275.mk | 72 +++++++++++++++++----------------- genmk.rb | 5 ++- include/grub/normal.h | 24 +++++++----- normal/cmdline.c | 8 +++- normal/command.c | 83 ++++++++++++++++++++++++++++++++++++---- normal/main.c | 65 +++++++++++++++++++++++++++++++ 9 files changed, 297 insertions(+), 115 deletions(-) diff --git a/ChangeLog b/ChangeLog index b83bdcf16..bb54a863f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2005-03-08 Yoshinori Okuji + + Automatic loading of commands is supported. + + * normal/main.c (read_command_list): New function. + (grub_normal_execute): Call read_command_list. + + * normal/command.c (grub_register_command): Return zero or CMD. + Allocate CMD->NAME from the heap. + Initialize CMD->MODULE_NAME to zero. + Find the same name as well. If the same command is found and it is + a dummy command, overwrite members. If it is not a dummy command, + return zero. + (grub_unregister_command): Free Q->NAME and Q->MODULE_NAME. + (grub_command_find): If a dummy command is found, load a module + and retry to find a command only once. + + * normal/cmdline.c (grub_tab_complete): Call grub_command_find to + make sure that each command is loaded. + + * include/grub/normal.h (GRUB_COMMAND_FLAG_NOT_LOADED): New + macro. + (struct grub_command): Remove const from the member `name'. + Add a new member `module_name'. + (grub_register_command): Return grub_command_t. + + * commands/help.c (grub_cmd_help): Call grub_command_find to make + sure that each command is loaded. + + * genmk.rb (PModule::rule): Specify a module name without the + suffix ".mod" to gencmdlist.sh. + 2005-03-02 Yoshinori K. Okuji * gencmdlist.sh: New file. diff --git a/commands/help.c b/commands/help.c index b05787586..87480dfeb 100644 --- a/commands/help.c +++ b/commands/help.c @@ -40,33 +40,38 @@ grub_cmd_help (struct grub_arg_list *state __attribute__ ((unused)), int argc, int print_command_info (grub_command_t cmd) { - if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE) + if (grub_command_find (cmd->name)) { - char description[TERM_WIDTH / 2]; - int desclen = grub_strlen (cmd->summary); - - /* Make a string with a length of TERM_WIDTH / 2 - 1 filled - with the description followed by spaces. */ - grub_memset (description, ' ', TERM_WIDTH / 2 - 1); - description[TERM_WIDTH / 2 - 1] = '\0'; - grub_memcpy (description, cmd->summary, - (desclen < TERM_WIDTH / 2 - 1 - ? desclen : TERM_WIDTH / 2 - 1)); - - grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " "); + if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE) + { + char description[TERM_WIDTH / 2]; + int desclen = grub_strlen (cmd->summary); + + /* Make a string with a length of TERM_WIDTH / 2 - 1 filled + with the description followed by spaces. */ + grub_memset (description, ' ', TERM_WIDTH / 2 - 1); + description[TERM_WIDTH / 2 - 1] = '\0'; + grub_memcpy (description, cmd->summary, + (desclen < TERM_WIDTH / 2 - 1 + ? desclen : TERM_WIDTH / 2 - 1)); + + grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " "); + } } - return 0; } int print_command_help (grub_command_t cmd) { - if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) + if (grub_command_find (cmd->name)) { - if (cnt++ > 0) - grub_printf ("\n\n"); - - grub_arg_show_help (cmd); + if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg))) + { + if (cnt++ > 0) + grub_printf ("\n\n"); + + grub_arg_show_help (cmd); + } } return 0; } diff --git a/conf/i386-pc.mk b/conf/i386-pc.mk index f4ee07ade..9a353d0cd 100644 --- a/conf/i386-pc.mk +++ b/conf/i386-pc.mk @@ -996,7 +996,7 @@ CLEANFILES += cmd-chainloader.lst COMMANDFILES += cmd-chainloader.lst cmd-chainloader.lst: loader/i386/pc/chainloader.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_chain_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _chain.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_chain_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _chain > $@ || (rm -f $@; exit 1) _chain_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1041,7 +1041,7 @@ CLEANFILES += cmd-chainloader_normal.lst COMMANDFILES += cmd-chainloader_normal.lst cmd-chainloader_normal.lst: loader/i386/pc/chainloader_normal.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh chain.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(chain_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh chain > $@ || (rm -f $@; exit 1) chain_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1086,7 +1086,7 @@ CLEANFILES += cmd-fshelp.lst COMMANDFILES += cmd-fshelp.lst cmd-fshelp.lst: fs/fshelp.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fshelp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fshelp.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fshelp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fshelp > $@ || (rm -f $@; exit 1) fshelp_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1131,7 +1131,7 @@ CLEANFILES += cmd-fat.lst COMMANDFILES += cmd-fat.lst cmd-fat.lst: fs/fat.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fat.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fat > $@ || (rm -f $@; exit 1) fat_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1176,7 +1176,7 @@ CLEANFILES += cmd-ext2.lst COMMANDFILES += cmd-ext2.lst cmd-ext2.lst: fs/ext2.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ext2_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ext2.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ext2_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ext2 > $@ || (rm -f $@; exit 1) ext2_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1221,7 +1221,7 @@ CLEANFILES += cmd-ufs.lst COMMANDFILES += cmd-ufs.lst cmd-ufs.lst: fs/ufs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ufs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ufs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ufs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ufs > $@ || (rm -f $@; exit 1) ufs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1266,7 +1266,7 @@ CLEANFILES += cmd-minix.lst COMMANDFILES += cmd-minix.lst cmd-minix.lst: fs/minix.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(minix_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh minix.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(minix_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh minix > $@ || (rm -f $@; exit 1) minix_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1311,7 +1311,7 @@ CLEANFILES += cmd-hfs.lst COMMANDFILES += cmd-hfs.lst cmd-hfs.lst: fs/hfs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(hfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hfs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(hfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hfs > $@ || (rm -f $@; exit 1) hfs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1356,7 +1356,7 @@ CLEANFILES += cmd-jfs.lst COMMANDFILES += cmd-jfs.lst cmd-jfs.lst: fs/jfs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(jfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh jfs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(jfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh jfs > $@ || (rm -f $@; exit 1) jfs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1405,7 +1405,7 @@ CLEANFILES += cmd-linux.lst COMMANDFILES += cmd-linux.lst cmd-linux.lst: loader/i386/pc/linux.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _linux.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _linux > $@ || (rm -f $@; exit 1) _linux_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1450,7 +1450,7 @@ CLEANFILES += cmd-linux_normal.lst COMMANDFILES += cmd-linux_normal.lst cmd-linux_normal.lst: loader/i386/pc/linux_normal.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh linux.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh linux > $@ || (rm -f $@; exit 1) linux_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1497,7 +1497,7 @@ CLEANFILES += cmd-arg.lst COMMANDFILES += cmd-arg.lst cmd-arg.lst: normal/arg.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_cmdline.o: normal/cmdline.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1511,7 +1511,7 @@ CLEANFILES += cmd-cmdline.lst COMMANDFILES += cmd-cmdline.lst cmd-cmdline.lst: normal/cmdline.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_command.o: normal/command.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1525,7 +1525,7 @@ CLEANFILES += cmd-command.lst COMMANDFILES += cmd-command.lst cmd-command.lst: normal/command.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_context.o: normal/context.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1539,7 +1539,7 @@ CLEANFILES += cmd-context.lst COMMANDFILES += cmd-context.lst cmd-context.lst: normal/context.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_main.o: normal/main.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1553,7 +1553,7 @@ CLEANFILES += cmd-main.lst COMMANDFILES += cmd-main.lst cmd-main.lst: normal/main.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_menu.o: normal/menu.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1567,7 +1567,7 @@ CLEANFILES += cmd-menu.lst COMMANDFILES += cmd-menu.lst cmd-menu.lst: normal/menu.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_menu_entry.o: normal/menu_entry.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1581,7 +1581,7 @@ CLEANFILES += cmd-menu_entry.lst COMMANDFILES += cmd-menu_entry.lst cmd-menu_entry.lst: normal/menu_entry.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_i386_setjmp.o: normal/i386/setjmp.S $(CC) -Inormal/i386 -I$(srcdir)/normal/i386 $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -c -o $@ $< @@ -1595,7 +1595,7 @@ CLEANFILES += cmd-setjmp.lst COMMANDFILES += cmd-setjmp.lst cmd-setjmp.lst: normal/i386/setjmp.S gencmdlist.sh - set -e; $(CC) -Inormal/i386 -I$(srcdir)/normal/i386 $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal/i386 -I$(srcdir)/normal/i386 $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) @@ -1641,7 +1641,7 @@ CLEANFILES += cmd-hello.lst COMMANDFILES += cmd-hello.lst cmd-hello.lst: hello/hello.c gencmdlist.sh - set -e; $(CC) -Ihello -I$(srcdir)/hello $(CPPFLAGS) $(CFLAGS) $(hello_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hello.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ihello -I$(srcdir)/hello $(CPPFLAGS) $(CFLAGS) $(hello_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hello > $@ || (rm -f $@; exit 1) hello_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1686,7 +1686,7 @@ CLEANFILES += cmd-boot.lst COMMANDFILES += cmd-boot.lst cmd-boot.lst: commands/boot.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(boot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh boot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(boot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh boot > $@ || (rm -f $@; exit 1) boot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1731,7 +1731,7 @@ CLEANFILES += cmd-terminal.lst COMMANDFILES += cmd-terminal.lst cmd-terminal.lst: commands/terminal.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(terminal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh terminal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(terminal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh terminal > $@ || (rm -f $@; exit 1) terminal_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1776,7 +1776,7 @@ CLEANFILES += cmd-ls.lst COMMANDFILES += cmd-ls.lst cmd-ls.lst: commands/ls.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(ls_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ls.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(ls_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ls > $@ || (rm -f $@; exit 1) ls_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1821,7 +1821,7 @@ CLEANFILES += cmd-cmp.lst COMMANDFILES += cmd-cmp.lst cmd-cmp.lst: commands/cmp.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cmp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cmp.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cmp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cmp > $@ || (rm -f $@; exit 1) cmp_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1866,7 +1866,7 @@ CLEANFILES += cmd-cat.lst COMMANDFILES += cmd-cat.lst cmd-cat.lst: commands/cat.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cat.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cat > $@ || (rm -f $@; exit 1) cat_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1911,7 +1911,7 @@ CLEANFILES += cmd-help.lst COMMANDFILES += cmd-help.lst cmd-help.lst: commands/help.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(help_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh help.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(help_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh help > $@ || (rm -f $@; exit 1) help_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1956,7 +1956,7 @@ CLEANFILES += cmd-reboot.lst COMMANDFILES += cmd-reboot.lst cmd-reboot.lst: commands/i386/pc/reboot.c gencmdlist.sh - set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(reboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh reboot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(reboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh reboot > $@ || (rm -f $@; exit 1) reboot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2001,7 +2001,7 @@ CLEANFILES += cmd-halt.lst COMMANDFILES += cmd-halt.lst cmd-halt.lst: commands/i386/pc/halt.c gencmdlist.sh - set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(halt_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh halt.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands/i386/pc -I$(srcdir)/commands/i386/pc $(CPPFLAGS) $(CFLAGS) $(halt_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh halt > $@ || (rm -f $@; exit 1) halt_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2046,7 +2046,7 @@ CLEANFILES += cmd-vga.lst COMMANDFILES += cmd-vga.lst cmd-vga.lst: term/i386/pc/vga.c gencmdlist.sh - set -e; $(CC) -Iterm/i386/pc -I$(srcdir)/term/i386/pc $(CPPFLAGS) $(CFLAGS) $(vga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vga.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iterm/i386/pc -I$(srcdir)/term/i386/pc $(CPPFLAGS) $(CFLAGS) $(vga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh vga > $@ || (rm -f $@; exit 1) vga_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2091,7 +2091,7 @@ CLEANFILES += cmd-manager.lst COMMANDFILES += cmd-manager.lst cmd-manager.lst: font/manager.c gencmdlist.sh - set -e; $(CC) -Ifont -I$(srcdir)/font $(CPPFLAGS) $(CFLAGS) $(font_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh font.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifont -I$(srcdir)/font $(CPPFLAGS) $(CFLAGS) $(font_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh font > $@ || (rm -f $@; exit 1) font_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2136,7 +2136,7 @@ CLEANFILES += cmd-multiboot.lst COMMANDFILES += cmd-multiboot.lst cmd-multiboot.lst: loader/i386/pc/multiboot.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _multiboot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(_multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _multiboot > $@ || (rm -f $@; exit 1) _multiboot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2181,7 +2181,7 @@ CLEANFILES += cmd-multiboot_normal.lst COMMANDFILES += cmd-multiboot_normal.lst cmd-multiboot_normal.lst: loader/i386/pc/multiboot_normal.c gencmdlist.sh - set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh multiboot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/i386/pc -I$(srcdir)/loader/i386/pc $(CPPFLAGS) $(CFLAGS) $(multiboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh multiboot > $@ || (rm -f $@; exit 1) multiboot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2226,7 +2226,7 @@ CLEANFILES += cmd-amiga.lst COMMANDFILES += cmd-amiga.lst cmd-amiga.lst: partmap/amiga.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(amiga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh amiga.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(amiga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh amiga > $@ || (rm -f $@; exit 1) amiga_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2271,7 +2271,7 @@ CLEANFILES += cmd-apple.lst COMMANDFILES += cmd-apple.lst cmd-apple.lst: partmap/apple.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(apple_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh apple.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(apple_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh apple > $@ || (rm -f $@; exit 1) apple_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2316,7 +2316,7 @@ CLEANFILES += cmd-pc.lst COMMANDFILES += cmd-pc.lst cmd-pc.lst: partmap/pc.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(pc_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh pc.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(pc_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh pc > $@ || (rm -f $@; exit 1) pc_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2361,7 +2361,7 @@ CLEANFILES += cmd-sun.lst COMMANDFILES += cmd-sun.lst cmd-sun.lst: partmap/sun.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(sun_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh sun.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(sun_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh sun > $@ || (rm -f $@; exit 1) sun_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2406,7 +2406,7 @@ CLEANFILES += cmd-loopback.lst COMMANDFILES += cmd-loopback.lst cmd-loopback.lst: disk/loopback.c gencmdlist.sh - set -e; $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) $(loopback_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loopback.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) $(loopback_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loopback > $@ || (rm -f $@; exit 1) loopback_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2451,7 +2451,7 @@ CLEANFILES += cmd-default.lst COMMANDFILES += cmd-default.lst cmd-default.lst: commands/default.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(default_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh default.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(default_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh default > $@ || (rm -f $@; exit 1) default_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2496,7 +2496,7 @@ CLEANFILES += cmd-timeout.lst COMMANDFILES += cmd-timeout.lst cmd-timeout.lst: commands/timeout.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(timeout_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh timeout.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(timeout_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh timeout > $@ || (rm -f $@; exit 1) timeout_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2541,7 +2541,7 @@ CLEANFILES += cmd-configfile.lst COMMANDFILES += cmd-configfile.lst cmd-configfile.lst: commands/configfile.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(configfile_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh configfile.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(configfile_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh configfile > $@ || (rm -f $@; exit 1) configfile_mod_CFLAGS = $(COMMON_CFLAGS) CLEANFILES += moddep.lst command.lst diff --git a/conf/powerpc-ieee1275.mk b/conf/powerpc-ieee1275.mk index bbce339fa..8ed4a4206 100644 --- a/conf/powerpc-ieee1275.mk +++ b/conf/powerpc-ieee1275.mk @@ -763,7 +763,7 @@ CLEANFILES += cmd-fshelp.lst COMMANDFILES += cmd-fshelp.lst cmd-fshelp.lst: fs/fshelp.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fshelp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fshelp.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fshelp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fshelp > $@ || (rm -f $@; exit 1) fshelp_mod_CFLAGS = $(COMMON_CFLAGS) @@ -808,7 +808,7 @@ CLEANFILES += cmd-fat.lst COMMANDFILES += cmd-fat.lst cmd-fat.lst: fs/fat.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fat.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(fat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh fat > $@ || (rm -f $@; exit 1) fat_mod_CFLAGS = $(COMMON_CFLAGS) @@ -853,7 +853,7 @@ CLEANFILES += cmd-ext2.lst COMMANDFILES += cmd-ext2.lst cmd-ext2.lst: fs/ext2.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ext2_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ext2.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ext2_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ext2 > $@ || (rm -f $@; exit 1) ext2_mod_CFLAGS = $(COMMON_CFLAGS) @@ -898,7 +898,7 @@ CLEANFILES += cmd-ufs.lst COMMANDFILES += cmd-ufs.lst cmd-ufs.lst: fs/ufs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ufs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ufs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(ufs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ufs > $@ || (rm -f $@; exit 1) ufs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -943,7 +943,7 @@ CLEANFILES += cmd-minix.lst COMMANDFILES += cmd-minix.lst cmd-minix.lst: fs/minix.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(minix_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh minix.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(minix_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh minix > $@ || (rm -f $@; exit 1) minix_mod_CFLAGS = $(COMMON_CFLAGS) @@ -988,7 +988,7 @@ CLEANFILES += cmd-hfs.lst COMMANDFILES += cmd-hfs.lst cmd-hfs.lst: fs/hfs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(hfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hfs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(hfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hfs > $@ || (rm -f $@; exit 1) hfs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1033,7 +1033,7 @@ CLEANFILES += cmd-jfs.lst COMMANDFILES += cmd-jfs.lst cmd-jfs.lst: fs/jfs.c gencmdlist.sh - set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(jfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh jfs.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifs -I$(srcdir)/fs $(CPPFLAGS) $(CFLAGS) $(jfs_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh jfs > $@ || (rm -f $@; exit 1) jfs_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1082,7 +1082,7 @@ CLEANFILES += cmd-linux.lst COMMANDFILES += cmd-linux.lst cmd-linux.lst: loader/powerpc/ieee1275/linux.c gencmdlist.sh - set -e; $(CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(CPPFLAGS) $(CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _linux.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(CPPFLAGS) $(CFLAGS) $(_linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh _linux > $@ || (rm -f $@; exit 1) _linux_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1127,7 +1127,7 @@ CLEANFILES += cmd-linux_normal.lst COMMANDFILES += cmd-linux_normal.lst cmd-linux_normal.lst: loader/powerpc/ieee1275/linux_normal.c gencmdlist.sh - set -e; $(CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh linux.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Iloader/powerpc/ieee1275 -I$(srcdir)/loader/powerpc/ieee1275 $(CPPFLAGS) $(CFLAGS) $(linux_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh linux > $@ || (rm -f $@; exit 1) linux_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1175,7 +1175,7 @@ CLEANFILES += cmd-arg.lst COMMANDFILES += cmd-arg.lst cmd-arg.lst: normal/arg.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_cmdline.o: normal/cmdline.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1189,7 +1189,7 @@ CLEANFILES += cmd-cmdline.lst COMMANDFILES += cmd-cmdline.lst cmd-cmdline.lst: normal/cmdline.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_command.o: normal/command.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1203,7 +1203,7 @@ CLEANFILES += cmd-command.lst COMMANDFILES += cmd-command.lst cmd-command.lst: normal/command.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_context.o: normal/context.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1217,7 +1217,7 @@ CLEANFILES += cmd-context.lst COMMANDFILES += cmd-context.lst cmd-context.lst: normal/context.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_main.o: normal/main.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1231,7 +1231,7 @@ CLEANFILES += cmd-main.lst COMMANDFILES += cmd-main.lst cmd-main.lst: normal/main.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_menu.o: normal/menu.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1245,7 +1245,7 @@ CLEANFILES += cmd-menu.lst COMMANDFILES += cmd-menu.lst cmd-menu.lst: normal/menu.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_menu_entry.o: normal/menu_entry.c $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -c -o $@ $< @@ -1259,7 +1259,7 @@ CLEANFILES += cmd-menu_entry.lst COMMANDFILES += cmd-menu_entry.lst cmd-menu_entry.lst: normal/menu_entry.c gencmdlist.sh - set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal -I$(srcdir)/normal $(CPPFLAGS) $(CFLAGS) $(normal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod-normal_powerpc_setjmp.o: normal/powerpc/setjmp.S $(CC) -Inormal/powerpc -I$(srcdir)/normal/powerpc $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -c -o $@ $< @@ -1273,7 +1273,7 @@ CLEANFILES += cmd-setjmp.lst COMMANDFILES += cmd-setjmp.lst cmd-setjmp.lst: normal/powerpc/setjmp.S gencmdlist.sh - set -e; $(CC) -Inormal/powerpc -I$(srcdir)/normal/powerpc $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Inormal/powerpc -I$(srcdir)/normal/powerpc $(CPPFLAGS) $(ASFLAGS) $(normal_mod_ASFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh normal > $@ || (rm -f $@; exit 1) normal_mod_CFLAGS = $(COMMON_CFLAGS) normal_mod_ASFLAGS = $(COMMON_ASFLAGS) @@ -1319,7 +1319,7 @@ CLEANFILES += cmd-hello.lst COMMANDFILES += cmd-hello.lst cmd-hello.lst: hello/hello.c gencmdlist.sh - set -e; $(CC) -Ihello -I$(srcdir)/hello $(CPPFLAGS) $(CFLAGS) $(hello_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hello.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ihello -I$(srcdir)/hello $(CPPFLAGS) $(CFLAGS) $(hello_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh hello > $@ || (rm -f $@; exit 1) hello_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1364,7 +1364,7 @@ CLEANFILES += cmd-boot.lst COMMANDFILES += cmd-boot.lst cmd-boot.lst: commands/boot.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(boot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh boot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(boot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh boot > $@ || (rm -f $@; exit 1) boot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1409,7 +1409,7 @@ CLEANFILES += cmd-terminal.lst COMMANDFILES += cmd-terminal.lst cmd-terminal.lst: commands/terminal.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(terminal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh terminal.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(terminal_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh terminal > $@ || (rm -f $@; exit 1) terminal_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1454,7 +1454,7 @@ CLEANFILES += cmd-ls.lst COMMANDFILES += cmd-ls.lst cmd-ls.lst: commands/ls.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(ls_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ls.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(ls_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh ls > $@ || (rm -f $@; exit 1) ls_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1499,7 +1499,7 @@ CLEANFILES += cmd-cmp.lst COMMANDFILES += cmd-cmp.lst cmd-cmp.lst: commands/cmp.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cmp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cmp.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cmp_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cmp > $@ || (rm -f $@; exit 1) cmp_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1544,7 +1544,7 @@ CLEANFILES += cmd-cat.lst COMMANDFILES += cmd-cat.lst cmd-cat.lst: commands/cat.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cat.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(cat_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh cat > $@ || (rm -f $@; exit 1) cat_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1589,7 +1589,7 @@ CLEANFILES += cmd-manager.lst COMMANDFILES += cmd-manager.lst cmd-manager.lst: font/manager.c gencmdlist.sh - set -e; $(CC) -Ifont -I$(srcdir)/font $(CPPFLAGS) $(CFLAGS) $(font_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh font.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ifont -I$(srcdir)/font $(CPPFLAGS) $(CFLAGS) $(font_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh font > $@ || (rm -f $@; exit 1) font_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1634,7 +1634,7 @@ CLEANFILES += cmd-amiga.lst COMMANDFILES += cmd-amiga.lst cmd-amiga.lst: partmap/amiga.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(amiga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh amiga.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(amiga_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh amiga > $@ || (rm -f $@; exit 1) amiga_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1679,7 +1679,7 @@ CLEANFILES += cmd-apple.lst COMMANDFILES += cmd-apple.lst cmd-apple.lst: partmap/apple.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(apple_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh apple.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(apple_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh apple > $@ || (rm -f $@; exit 1) apple_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1724,7 +1724,7 @@ CLEANFILES += cmd-pc.lst COMMANDFILES += cmd-pc.lst cmd-pc.lst: partmap/pc.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(pc_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh pc.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(pc_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh pc > $@ || (rm -f $@; exit 1) pc_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1769,7 +1769,7 @@ CLEANFILES += cmd-sun.lst COMMANDFILES += cmd-sun.lst cmd-sun.lst: partmap/sun.c gencmdlist.sh - set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(sun_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh sun.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Ipartmap -I$(srcdir)/partmap $(CPPFLAGS) $(CFLAGS) $(sun_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh sun > $@ || (rm -f $@; exit 1) sun_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1814,7 +1814,7 @@ CLEANFILES += cmd-loopback.lst COMMANDFILES += cmd-loopback.lst cmd-loopback.lst: disk/loopback.c gencmdlist.sh - set -e; $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) $(loopback_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loopback.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Idisk -I$(srcdir)/disk $(CPPFLAGS) $(CFLAGS) $(loopback_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh loopback > $@ || (rm -f $@; exit 1) loopback_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1859,7 +1859,7 @@ CLEANFILES += cmd-suspend.lst COMMANDFILES += cmd-suspend.lst cmd-suspend.lst: commands/ieee1275/suspend.c gencmdlist.sh - set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(suspend_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh suspend.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(suspend_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh suspend > $@ || (rm -f $@; exit 1) suspend_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1904,7 +1904,7 @@ CLEANFILES += cmd-reboot.lst COMMANDFILES += cmd-reboot.lst cmd-reboot.lst: commands/ieee1275/reboot.c gencmdlist.sh - set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(reboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh reboot.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(reboot_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh reboot > $@ || (rm -f $@; exit 1) reboot_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1949,7 +1949,7 @@ CLEANFILES += cmd-halt.lst COMMANDFILES += cmd-halt.lst cmd-halt.lst: commands/ieee1275/halt.c gencmdlist.sh - set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(halt_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh halt.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands/ieee1275 -I$(srcdir)/commands/ieee1275 $(CPPFLAGS) $(CFLAGS) $(halt_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh halt > $@ || (rm -f $@; exit 1) halt_mod_CFLAGS = $(COMMON_CFLAGS) @@ -1994,7 +1994,7 @@ CLEANFILES += cmd-help.lst COMMANDFILES += cmd-help.lst cmd-help.lst: commands/help.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(help_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh help.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(help_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh help > $@ || (rm -f $@; exit 1) help_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2039,7 +2039,7 @@ CLEANFILES += cmd-default.lst COMMANDFILES += cmd-default.lst cmd-default.lst: commands/default.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(default_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh default.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(default_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh default > $@ || (rm -f $@; exit 1) default_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2084,7 +2084,7 @@ CLEANFILES += cmd-timeout.lst COMMANDFILES += cmd-timeout.lst cmd-timeout.lst: commands/timeout.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(timeout_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh timeout.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(timeout_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh timeout > $@ || (rm -f $@; exit 1) timeout_mod_CFLAGS = $(COMMON_CFLAGS) @@ -2129,7 +2129,7 @@ CLEANFILES += cmd-configfile.lst COMMANDFILES += cmd-configfile.lst cmd-configfile.lst: commands/configfile.c gencmdlist.sh - set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(configfile_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh configfile.mod > $@ || (rm -f $@; exit 1) + set -e; $(CC) -Icommands -I$(srcdir)/commands $(CPPFLAGS) $(CFLAGS) $(configfile_mod_CFLAGS) -E $< | sh $(srcdir)/gencmdlist.sh configfile > $@ || (rm -f $@; exit 1) configfile_mod_CFLAGS = $(COMMON_CFLAGS) CLEANFILES += moddep.lst command.lst diff --git a/genmk.rb b/genmk.rb index f967a443f..b5a0c7c68 100644 --- a/genmk.rb +++ b/genmk.rb @@ -1,6 +1,6 @@ #! /usr/bin/ruby -w # -# Copyright (C) 2002,2003,2004 Free Software Foundation, Inc. +# Copyright (C) 2002,2003,2004,2005 Free Software Foundation, Inc. # # This genmk.rb is free software; the author # gives unlimited permission to copy and/or distribute it, @@ -109,6 +109,7 @@ class PModule defsym = 'def-' + @name.suffix('lst') undsym = 'und-' + @name.suffix('lst') mod_name = File.basename(@name, '.mod') + symbolic_name = mod_name.sub(/\.[^\.]*$/, '') "CLEANFILES += #{@name} #{mod_obj} #{mod_src} #{pre_obj} #{objs_str} #{defsym} #{undsym} MOSTLYCLEANFILES += #{deps_str} @@ -162,7 +163,7 @@ COMMANDFILES += #{command} #{command}: #{src} gencmdlist.sh set -e; \ $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(#{flag}) $(#{prefix}_#{flag}) -E $< \ - | sh $(srcdir)/gencmdlist.sh #{@name} > $@ || (rm -f $@; exit 1) + | sh $(srcdir)/gencmdlist.sh #{symbolic_name} > $@ || (rm -f $@; exit 1) " end.join('') diff --git a/include/grub/normal.h b/include/grub/normal.h index e0194f6b9..1202ca4e8 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -1,7 +1,7 @@ /* normal.h - prototypes for the normal mode */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 2002,2003 Free Software Foundation, Inc. + * Copyright (C) 2002,2003,2005 Free Software Foundation, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -41,12 +41,14 @@ #define GRUB_COMMAND_FLAG_NO_ECHO 0x8 /* Don't print the command on booting. */ #define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10 +/* Not loaded yet. Used for auto-loading. */ +#define GRUB_COMMAND_FLAG_NOT_LOADED 0x20 /* The command description. */ struct grub_command { /* The name. */ - const char *name; + char *name; /* The callback function. */ grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args); @@ -63,6 +65,9 @@ struct grub_command /* The argument parser optionlist. */ const struct grub_arg_option *options; + /* The name of a module. Used for auto-loading. */ + char *module_name; + /* The next element. */ struct grub_command *next; }; @@ -142,13 +147,14 @@ void grub_menu_entry_run (grub_menu_entry_t entry); void grub_cmdline_run (int nested); int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, int echo_char, int readline); -void grub_register_command (const char *name, - grub_err_t (*func) (struct grub_arg_list *state, - int argc, char **args), - unsigned flags, - const char *summary, - const char *description, - const struct grub_arg_option *parser); +grub_command_t grub_register_command (const char *name, + grub_err_t (*func) (struct grub_arg_list *state, + int argc, + char **args), + unsigned flags, + const char *summary, + const char *description, + const struct grub_arg_option *parser); void grub_unregister_command (const char *name); grub_command_t grub_command_find (char *cmdline); grub_err_t grub_set_history (int newsize); diff --git a/normal/cmdline.c b/normal/cmdline.c index d235803f4..e431f2262 100644 --- a/normal/cmdline.c +++ b/normal/cmdline.c @@ -273,8 +273,12 @@ grub_tab_complete (char *buf, int *restore) int iterate_commands (grub_command_t cmd) { - if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE) - add_completion (cmd->name, " ", "commands", print_simple_completion); + if (grub_command_find (cmd->name)) + { + if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE) + add_completion (cmd->name, " ", "commands", + print_simple_completion); + } return 0; } diff --git a/normal/command.c b/normal/command.c index 66630e658..f3af5f4ca 100644 --- a/normal/command.c +++ b/normal/command.c @@ -27,7 +27,7 @@ static grub_command_t grub_command_list; -void +grub_command_t grub_register_command (const char *name, grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args), @@ -40,27 +40,63 @@ grub_register_command (const char *name, cmd = (grub_command_t) grub_malloc (sizeof (*cmd)); if (! cmd) - return; + return 0; - cmd->name = name; + cmd->name = grub_strdup (name); + if (! cmd->name) + { + grub_free (cmd); + return 0; + } + cmd->func = func; cmd->flags = flags; cmd->summary = summary; cmd->description = description; cmd->options = options; + cmd->module_name = 0; /* Keep the list sorted for simplicity. */ p = &grub_command_list; while (*p) { - if (grub_strcmp ((*p)->name, name) > 0) + if (grub_strcmp ((*p)->name, name) >= 0) break; p = &((*p)->next); } - cmd->next = *p; - *p = cmd; + if (*p && grub_strcmp ((*p)->name, name) == 0) + { + grub_command_t q; + + q = *p; + if (q->flags & GRUB_COMMAND_FLAG_NOT_LOADED) + { + q->func = cmd->func; + q->flags = cmd->flags; + q->summary = cmd->summary; + q->description = cmd->description; + q->options = cmd->options; + grub_free (cmd->name); + grub_free (cmd->module_name); + grub_free (cmd); + cmd = q; + } + else + { + grub_free (cmd->name); + grub_free (cmd); + cmd = 0; + } + } + else + { + cmd->next = *p; + *p = cmd; + } + + return cmd; } void @@ -72,6 +108,8 @@ grub_unregister_command (const char *name) if (grub_strcmp (name, q->name) == 0) { *p = q->next; + grub_free (q->name); + grub_free (q->module_name); grub_free (q); break; } @@ -82,17 +120,48 @@ grub_command_find (char *cmdline) { char *first_space; grub_command_t cmd; - + int count = 0; + first_space = grub_strchr (cmdline, ' '); if (first_space) *first_space = '\0'; + again: + for (cmd = grub_command_list; cmd; cmd = cmd->next) if (grub_strcmp (cmdline, cmd->name) == 0) break; if (! cmd) grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", cmdline); + else if (cmd->flags & GRUB_COMMAND_FLAG_NOT_LOADED) + { + /* Automatically load the command. */ + if (count == 0) + { + grub_dl_t mod; + char *module_name; + + module_name = grub_strdup (cmd->module_name); + if (module_name) + { + mod = grub_dl_load (module_name); + if (mod) + { + grub_dl_ref (mod); + count++; + goto again; + } + + grub_free (module_name); + } + } + + /* This module seems broken. */ + grub_unregister_command (cmdline); + grub_error (GRUB_ERR_UNKNOWN_COMMAND, "unknown command `%s'", cmdline); + cmd = 0; + } if (first_space) *first_space = ' '; diff --git a/normal/main.c b/normal/main.c index 27e63a041..7b4af362f 100644 --- a/normal/main.c +++ b/normal/main.c @@ -304,6 +304,69 @@ grub_normal_init_page (void) PACKAGE_VERSION); } +/* Read the file command.lst for auto-loading. */ +static void +read_command_list (void) +{ + const char *prefix; + + prefix = grub_env_get ("prefix"); + if (prefix) + { + char *filename; + + filename = grub_malloc (grub_strlen (prefix) + sizeof ("/command.lst")); + if (filename) + { + grub_file_t file; + + grub_sprintf (filename, "%s/command.lst", prefix); + file = grub_file_open (filename); + if (file) + { + char buf[80]; /* XXX arbitrary */ + + while (get_line (file, buf, sizeof (buf))) + { + char *p; + grub_command_t cmd; + + if (! grub_isgraph (buf[0])) + continue; + + p = grub_strchr (buf, ':'); + if (! p) + continue; + + *p = '\0'; + while (*++p == ' ') + ; + + if (! grub_isgraph (*p)) + continue; + + cmd = grub_register_command (buf, 0, + GRUB_COMMAND_FLAG_NOT_LOADED, + 0, 0, 0); + if (! cmd) + continue; + + cmd->module_name = grub_strdup (p); + if (! cmd->module_name) + grub_unregister_command (buf); + } + + grub_file_close (file); + } + + grub_free (filename); + } + } + + /* Ignore errors. */ + grub_errno = GRUB_ERR_NONE; +} + /* Read the config file CONFIG and execute the menu interface or the command-line interface. */ void @@ -319,6 +382,8 @@ grub_normal_execute (const char *config, int nested) grub_errno = GRUB_ERR_NONE; } + read_command_list (); + if (menu) { grub_menu_run (menu, nested);