From 2083672af13f98a2efcd467b1a818eff5669b942 Mon Sep 17 00:00:00 2001 From: Vladimir 'phcoder' Serbinenko Date: Sun, 7 Feb 2010 04:23:44 +0100 Subject: [PATCH] Remove -DGRUB_UTIL when compiling grub-emu --- commands/parttool.c | 2 +- conf/any-emu.rmk | 4 +-- efiemu/main.c | 4 +-- efiemu/mm.c | 4 +-- include/grub/dl.h | 9 +++-- include/grub/mm.h | 2 +- include/grub/multiboot2.h | 70 --------------------------------------- include/grub/normal.h | 33 ------------------ include/grub/partition.h | 14 -------- include/grub/pci.h | 2 +- kern/dl.c | 2 +- loader/xnu.c | 6 ++-- util/grub-emu.c | 2 -- util/misc.c | 4 +++ 14 files changed, 24 insertions(+), 134 deletions(-) delete mode 100644 include/grub/multiboot2.h diff --git a/commands/parttool.c b/commands/parttool.c index 5ad6133ca..0850c5e1d 100644 --- a/commands/parttool.c +++ b/commands/parttool.c @@ -175,7 +175,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } /* Load modules. */ -#ifndef GRUB_UTIL +#if GRUB_NO_MODULES { const char *prefix; prefix = grub_env_get ("prefix"); diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk index 542cd9bd1..0f717c59c 100644 --- a/conf/any-emu.rmk +++ b/conf/any-emu.rmk @@ -1,7 +1,7 @@ # -*- makefile -*- COMMON_LDFLAGS += -nostdlib -COMMON_CFLAGS += -DGRUB_UTIL=1 +COMMON_CFLAGS += # Used by various components. These rules need to precede them. script/lexer.c_DEPENDENCIES = grub_script.tab.h @@ -21,7 +21,7 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \ util/hostdisk.c util/getroot.c \ \ grub_emu_init.c gnulib/progname.c -kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 +kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) kernel_img_LDFLAGS = $(COMMON_LDFLAGS) TARGET_NO_STRIP = yes TARGET_NO_DYNAMIC_MODULES = yes diff --git a/efiemu/main.c b/efiemu/main.c index 9480bfc4d..8a8a508fa 100644 --- a/efiemu/main.c +++ b/efiemu/main.c @@ -265,7 +265,7 @@ grub_efiemu_autocore (void) grub_free (filename); if (err) return err; -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU err = grub_machine_efiemu_init_tables (); if (err) return err; @@ -313,7 +313,7 @@ grub_cmd_efiemu_load (grub_command_t cmd __attribute__ ((unused)), err = grub_efiemu_load_file (args[0]); if (err) return err; -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU err = grub_machine_efiemu_init_tables (); if (err) return err; diff --git a/efiemu/mm.c b/efiemu/mm.c index 6099a14ee..4b293606f 100644 --- a/efiemu/mm.c +++ b/efiemu/mm.c @@ -281,7 +281,7 @@ grub_efiemu_mmap_init (void) // the place for memory used by efiemu itself mmap_reserved_size = GRUB_EFI_MAX_MEMORY_TYPE + 1; -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU grub_machine_mmap_iterate (bounds_hook); #endif @@ -394,7 +394,7 @@ grub_efiemu_mmap_fill (void) } } -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU grub_machine_mmap_iterate (fill_hook); #endif diff --git a/include/grub/dl.h b/include/grub/dl.h index ac0ecd336..17e03f400 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -91,7 +91,12 @@ grub_dl_t grub_dl_load_core (void *addr, grub_size_t size); int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod); void grub_dl_unload_unneeded (void); void grub_dl_unload_all (void); -#ifdef GRUB_UTIL +#if defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) +#define GRUB_NO_MODULES 1 +#else +#define GRUB_NO_MODULES 0 +#endif +#if GRUB_NO_MODULES static inline int grub_dl_ref (grub_dl_t mod) { @@ -116,7 +121,7 @@ grub_err_t grub_dl_register_symbol (const char *name, void *addr, grub_err_t grub_arch_dl_check_header (void *ehdr); grub_err_t grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr); -#if defined (_mips) && ! defined (GRUB_UTIL) +#if defined (_mips) && ! defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) #define GRUB_LINKER_HAVE_INIT 1 void grub_arch_dl_init_linker (void); #endif diff --git a/include/grub/mm.h b/include/grub/mm.h index 4caf80511..4f443ee25 100644 --- a/include/grub/mm.h +++ b/include/grub/mm.h @@ -36,7 +36,7 @@ void *EXPORT_FUNC(grub_realloc) (void *ptr, grub_size_t size); void *EXPORT_FUNC(grub_memalign) (grub_size_t align, grub_size_t size); /* For debugging. */ -#if defined(MM_DEBUG) && !defined(GRUB_UTIL) +#if defined(MM_DEBUG) && !defined(GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) /* Set this variable to 1 when you want to trace all memory function calls. */ extern int EXPORT_VAR(grub_mm_debug); diff --git a/include/grub/multiboot2.h b/include/grub/multiboot2.h deleted file mode 100644 index af10cdc21..000000000 --- a/include/grub/multiboot2.h +++ /dev/null @@ -1,70 +0,0 @@ -/* multiboot2.h - multiboot2 header file with grub definitions. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2005,2007 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#ifndef GRUB_MULTIBOOT2_HEADER -#define GRUB_MULTIBOOT2_HEADER 1 - -#include -#include -#include - -#ifndef GRUB_UTIL -typedef grub_uint32_t uint32_t; -typedef grub_uint64_t uint64_t; -#define __WORDSIZE GRUB_TARGET_WORDSIZE -#endif - -struct multiboot2_tag_header; - -grub_err_t -grub_mb2_tag_alloc (grub_addr_t *addr, int key, grub_size_t len); - -grub_err_t -grub_mb2_tags_arch_create (void); - -void -grub_mb2_arch_boot (grub_addr_t entry, void *tags); - -void -grub_mb2_arch_unload (struct multiboot2_tag_header *tags); - -grub_err_t -grub_mb2_arch_elf32_hook (Elf32_Phdr *phdr, grub_addr_t *addr, int *do_load); - -grub_err_t -grub_mb2_arch_elf64_hook (Elf64_Phdr *phdr, grub_addr_t *addr, int *do_load); - -grub_err_t -grub_mb2_arch_module_alloc (grub_size_t size, grub_addr_t *addr); - -grub_err_t -grub_mb2_arch_module_free (grub_addr_t addr, grub_size_t size); - -void -grub_multiboot2 (int argc, char *argv[]); - -void -grub_module2 (int argc, char *argv[]); - -#define for_each_tag(tag, tags) \ - for (tag = tags; \ - tag && tag->key != MULTIBOOT2_TAG_END; \ - tag = (struct multiboot2_tag_header *)((char *)tag + tag->len)) - -#endif /* ! GRUB_MULTIBOOT2_HEADER */ diff --git a/include/grub/normal.h b/include/grub/normal.h index e804fde77..fad1a41ba 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -110,37 +110,4 @@ void read_terminal_list (void); void grub_set_more (int onoff); -#ifdef GRUB_UTIL -void grub_normal_init (void); -void grub_normal_fini (void); -void grub_hello_init (void); -void grub_hello_fini (void); -void grub_ls_init (void); -void grub_ls_fini (void); -void grub_cat_init (void); -void grub_cat_fini (void); -void grub_boot_init (void); -void grub_boot_fini (void); -void grub_cmp_init (void); -void grub_cmp_fini (void); -void grub_terminal_init (void); -void grub_terminal_fini (void); -void grub_loop_init (void); -void grub_loop_fini (void); -void grub_help_init (void); -void grub_help_fini (void); -void grub_halt_init (void); -void grub_halt_fini (void); -void grub_reboot_init (void); -void grub_reboot_fini (void); -void grub_configfile_init (void); -void grub_configfile_fini (void); -void grub_search_init (void); -void grub_search_fini (void); -void grub_test_init (void); -void grub_test_fini (void); -void grub_blocklist_init (void); -void grub_blocklist_fini (void); -#endif - #endif /* ! GRUB_NORMAL_HEADER */ diff --git a/include/grub/partition.h b/include/grub/partition.h index d35658cdd..faa89cea6 100644 --- a/include/grub/partition.h +++ b/include/grub/partition.h @@ -83,20 +83,6 @@ void EXPORT_FUNC(grub_partition_map_register) (grub_partition_map_t partmap); void EXPORT_FUNC(grub_partition_map_unregister) (grub_partition_map_t partmap); -#ifdef GRUB_UTIL -void grub_msdos_partition_map_init (void); -void grub_msdos_partition_map_fini (void); -void grub_amiga_partition_map_init (void); -void grub_amiga_partition_map_fini (void); -void grub_apple_partition_map_init (void); -void grub_apple_partition_map_fini (void); -void grub_sun_partition_map_init (void); -void grub_sun_partition_map_fini (void); -void grub_gpt_partition_map_init (void); -void grub_gpt_partition_map_fini (void); -void grub_apple_partition_map_init (void); -void grub_apple_partition_map_fini (void); -#endif static inline grub_disk_addr_t grub_partition_get_start (const grub_partition_t p) diff --git a/include/grub/pci.h b/include/grub/pci.h index 1f3ac7fc7..89bd1034a 100644 --- a/include/grub/pci.h +++ b/include/grub/pci.h @@ -68,7 +68,7 @@ typedef grub_uint32_t grub_pci_id_t; -#ifdef GRUB_UTIL +#ifdef GRUB_MACHINE_EMU #include #else typedef grub_uint32_t grub_pci_address_t; diff --git a/kern/dl.c b/kern/dl.c index 4735a004a..278d5b568 100644 --- a/kern/dl.c +++ b/kern/dl.c @@ -469,7 +469,7 @@ grub_dl_resolve_dependencies (grub_dl_t mod, Elf_Ehdr *e) return GRUB_ERR_NONE; } -#ifndef GRUB_UTIL +#if !GRUB_NO_MODULES int grub_dl_ref (grub_dl_t mod) { diff --git a/loader/xnu.c b/loader/xnu.c index cf9fa740b..8f1d0c641 100644 --- a/loader/xnu.c +++ b/loader/xnu.c @@ -1390,7 +1390,7 @@ grub_cmd_xnu_splash (grub_extcmd_t cmd, } -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU static grub_err_t grub_cmd_xnu_resume (grub_command_t cmd __attribute__ ((unused)), int argc, char *args[]) @@ -1444,7 +1444,7 @@ GRUB_MOD_INIT(xnu) N_("Load a splash image for XNU."), xnu_splash_cmd_options); -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU cmd_resume = grub_register_command ("xnu_resume", grub_cmd_xnu_resume, 0, N_("Load XNU hibernate image.")); #endif @@ -1456,7 +1456,7 @@ GRUB_MOD_INIT(xnu) GRUB_MOD_FINI(xnu) { -#ifndef GRUB_UTIL +#ifndef GRUB_MACHINE_EMU grub_unregister_command (cmd_resume); #endif grub_unregister_command (cmd_mkext); diff --git a/util/grub-emu.c b/util/grub-emu.c index f64e66c5f..08ae19836 100644 --- a/util/grub-emu.c +++ b/util/grub-emu.c @@ -157,8 +157,6 @@ main (int argc, char *argv[]) set_program_name (argv[0]); - grub_util_init_nls (); - while ((opt = getopt_long (argc, argv, "r:d:m:vH:hV", options, 0)) != -1) switch (opt) { diff --git a/util/misc.c b/util/misc.c index 8c79e8d9b..7381c8fdd 100644 --- a/util/misc.c +++ b/util/misc.c @@ -104,6 +104,7 @@ grub_util_error (const char *fmt, ...) exit (1); } +#ifdef GRUB_UTIL int grub_err_printf (const char *fmt, ...) { @@ -116,6 +117,7 @@ grub_err_printf (const char *fmt, ...) return ret; } +#endif void * xmalloc (size_t size) @@ -598,6 +600,7 @@ make_system_path_relative_to_its_root (const char *path) return buf3; } +#ifdef GRUB_UTIL void grub_util_init_nls (void) { @@ -607,3 +610,4 @@ grub_util_init_nls (void) textdomain (PACKAGE); #endif /* ENABLE_NLS */ } +#endif