diff --git a/Makefile.in b/Makefile.in
index 5b585de1c..4db261990 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -85,8 +85,8 @@ LDFLAGS = @LDFLAGS@ $(LIBS)
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
TARGET_CC = @TARGET_CC@
-TARGET_CFLAGS = @TARGET_CFLAGS@
-TARGET_ASFLAGS = @TARGET_ASFLAGS@
+TARGET_CFLAGS = -ffreestanding @TARGET_CFLAGS@
+TARGET_ASFLAGS = -nostdinc -fno-builtin @TARGET_ASFLAGS@
TARGET_MODULE_FORMAT = @TARGET_MODULE_FORMAT@
TARGET_APPLE_CC = @TARGET_APPLE_CC@
OBJCONV = @OBJCONV@
@@ -94,9 +94,9 @@ TARGET_CPPFLAGS = @TARGET_CPPFLAGS@ -I$(srcdir)/include -I$(builddir) -I$(buildd
ifneq ($(platform), emu)
TARGET_CPPFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
endif
-TARGET_LDFLAGS = @TARGET_LDFLAGS@
+TARGET_LDFLAGS = -nostdlib @TARGET_LDFLAGS@
TARGET_IMG_LDSCRIPT = @TARGET_IMG_LDSCRIPT@
-TARGET_IMG_LDFLAGS = @TARGET_IMG_LDFLAGS@
+TARGET_IMG_LDFLAGS = -nostdlib @TARGET_IMG_LDFLAGS@
TARGET_IMG_CFLAGS = @TARGET_IMG_CFLAGS@
TARGET_OBJ2ELF = @TARGET_OBJ2ELF@
EXEEXT = @EXEEXT@
diff --git a/conf/any-emu.rmk b/conf/any-emu.rmk
index e6e1357e6..42bc8df5b 100644
--- a/conf/any-emu.rmk
+++ b/conf/any-emu.rmk
@@ -1,10 +1,6 @@
# -*- makefile -*-
-COMMON_LDFLAGS += -nostdlib
-COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include) -fno-builtin
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS += -nostdinc -isystem $(shell $(TARGET_CC) -print-file-name=include)
kernel_img_RELOCATABLE = yes
pkglib_PROGRAMS = kernel.img
@@ -19,10 +15,7 @@ kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
util/hostdisk.c util/getroot.c util/mm.c util/time.c \
\
gnulib/progname.c util/hostfs.c disk/host.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- list.h handler.h command.h i18n.h env_private.h
+kernel_img_HEADERS += datetime.h
kernel_img_CFLAGS = $(CPPFLAGS) $(CFLAGS) -Wno-undef
kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
TARGET_NO_STRIP = yes
@@ -80,14 +73,6 @@ endif
include $(srcdir)/conf/common.mk
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
grub_emu_init.h: genemuinitheader.sh $(pkglib_MODULES)
rm -f $@; echo $(pkglib_MODULES) | sh $(srcdir)/genemuinitheader.sh $(NM) > $@
DISTCLEANFILES += grub_emu_init.h
diff --git a/conf/common.rmk b/conf/common.rmk
index c7954d0d8..9817d506d 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -1,5 +1,8 @@
# -*- makefile -*-
+# Used by various components. These rules need to precede them.
+script/lexer.c_DEPENDENCIES = grub_script.tab.h
+
sbin_UTILITIES += grub-mkdevicemap
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
util/deviceiter.c \
@@ -100,6 +103,24 @@ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c
kern/handler.c kern/err.c kern/parser.c kern/list.c \
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c
+MOSTLYCLEANFILES += symlist.c kernel_syms.lst
+DEFSYMFILES += kernel_syms.lst
+
+kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
+ env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
+ partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
+ list.h handler.h command.h i18n.h env_private.h
+
+ifneq ($(platform), emu)
+kernel_img_HEADERS += machine/memory.h machine/loader.h machine/kernel.h
+endif
+
+symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
+ /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
+kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
+ /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+
# For the parser.
grub_script.tab.c grub_script.tab.h: script/parser.y
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index 85407b47e..3cef9313f 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -1,11 +1,6 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
-COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
-COMMON_LDFLAGS = -m32 -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS = -mrtd -mregparm=3
# Images.
@@ -29,25 +24,10 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- machine/boot.h machine/console.h machine/init.h \
- machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
- env_private.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,$(GRUB_KERNEL_MACHINE_LINK_ADDR),-Bstatic
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in
diff --git a/conf/i386-efi.rmk b/conf/i386-efi.rmk
index 345350406..e826cb333 100644
--- a/conf/i386-efi.rmk
+++ b/conf/i386-efi.rmk
@@ -1,135 +1,5 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
-COMMON_CFLAGS = -fno-builtin -m32
-COMMON_LDFLAGS = -melf_i386 -nostdlib
+COMMON_LDFLAGS = -melf_i386
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
-
-# Utilities.
-bin_UTILITIES = grub-mkimage
-
-# For grub-mkimage.
-grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
- util/misc.c util/resolve.c
-util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
-
-# For grub-setup.
-#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
-# util/misc.c util/getroot.c kern/device.c kern/disk.c \
-# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
-# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
-# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
-# kern/fs.c kern/env.c fs/fshelp.c
-
-# Scripts.
-sbin_SCRIPTS = grub-install
-
-# For grub-install.
-grub_install_SOURCES = util/i386/efi/grub-install.in
-
-# Modules.
-pkglib_PROGRAMS = kernel.img
-pkglib_MODULES = chain.mod appleldr.mod \
- linux.mod halt.mod \
- datetime.mod loadbios.mod \
- fixvideo.mod mmap.mod acpi.mod
-
-# For kernel.img.
-kernel_img_RELOCATABLE = yes
-kernel_img_SOURCES = kern/i386/efi/startup.S kern/main.c kern/device.c \
- kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
- kern/misc.c kern/mm.c kern/term.c \
- kern/rescue_parser.c kern/rescue_reader.c \
- kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
- kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
- term/efi/console.c disk/efi/efidisk.c \
- kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
- kern/i386/tsc.c kern/i386/pit.c \
- kern/generic/rtc_get_time_ms.c \
- kern/generic/millisleep.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- efi/efi.h efi/time.h efi/disk.h i386/pit.h list.h handler.h command.h \
- i18n.h env_private.h
-kernel_img_CFLAGS = $(COMMON_CFLAGS)
-kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
-kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
-
-MOSTLYCLEANFILES += symlist.c
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-# For acpi.mod.
-acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
-acpi_mod_CFLAGS = $(COMMON_CFLAGS)
-acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For mmap.mod.
-mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
- mmap/efi/mmap.c
-mmap_mod_CFLAGS = $(COMMON_CFLAGS)
-mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For chain.mod.
-chain_mod_SOURCES = loader/efi/chainloader.c
-chain_mod_CFLAGS = $(COMMON_CFLAGS)
-chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For appleldr.mod.
-appleldr_mod_SOURCES = loader/efi/appleloader.c
-appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
-appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For linux.mod.
-linux_mod_SOURCES = loader/i386/efi/linux.c
-linux_mod_CFLAGS = $(COMMON_CFLAGS)
-linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For halt.mod.
-halt_mod_SOURCES = commands/halt.c
-halt_mod_CFLAGS = $(COMMON_CFLAGS)
-halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For datetime.mod
-datetime_mod_SOURCES = lib/efi/datetime.c
-datetime_mod_CFLAGS = $(COMMON_CFLAGS)
-datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For loadbios.mod
-loadbios_mod_SOURCES = commands/efi/loadbios.c
-loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
-loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For fixvideo.mod
-fixvideo_mod_SOURCES = commands/efi/fixvideo.c
-fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
-fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += efi_uga.mod
-efi_uga_mod_SOURCES = video/efi_uga.c
-efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
-efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += efi_gop.mod
-efi_gop_mod_SOURCES = video/efi_gop.c
-efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
-efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += xnu.mod
-xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
- loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
-xnu_mod_CFLAGS = $(COMMON_CFLAGS)
-xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
-xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
-
-include $(srcdir)/conf/i386.mk
-include $(srcdir)/conf/common.mk
+include $(srcdir)/conf/x86-efi.mk
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index 6e5fd3055..d4a459b3e 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -1,11 +1,6 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -m32 -nostdinc -fno-builtin
-COMMON_CFLAGS = -ffreestanding -mrtd -mregparm=3
-COMMON_LDFLAGS = -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS = -mrtd -mregparm=3
# Images.
pkglib_PROGRAMS = kernel.img
@@ -29,24 +24,11 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \
term/ieee1275/ofconsole.c \
disk/ieee1275/ofdisk.c \
symlist.c
-kernel_img_HEADERS = cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- ieee1275/ieee1275.h machine/kernel.h machine/loader.h machine/memory.h \
- list.h handler.h command.h i18n.h env_private.h
+kernel_img_HEADERS += ieee1275/ieee1275.h
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-S,-Ttext,0x10000,-Bstatic
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
# Scripts.
sbin_SCRIPTS = grub-install
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index 9b01d6027..2bd0a3549 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -2,12 +2,7 @@
GRUB_KERNEL_MACHINE_LINK_ADDR = 0x8200
-COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
-COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
-COMMON_LDFLAGS = -m32 -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS = -mrtd -mregparm=3
# Images.
pkglib_IMAGES = boot.img cdboot.img diskboot.img kernel.img lnxboot.img \
@@ -59,27 +54,13 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \
kern/env.c \
term/i386/pc/console.c term/i386/vga_common.c \
symlist.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- machine/biosdisk.h machine/boot.h machine/console.h machine/init.h \
- machine/memory.h machine/loader.h machine/vga.h machine/vbe.h \
- machine/kernel.h machine/pxe.h i386/pit.h list.h handler.h command.h \
- i18n.h env_private.h
+kernel_img_HEADERS += machine/biosdisk.h machine/vga.h machine/vbe.h \
+ machine/pxe.h i386/pit.h machine/init.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) $(TARGET_IMG_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR) $(COMMON_CFLAGS)
kernel_img_FORMAT = binary
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
# Utilities.
bin_UTILITIES = grub-mkimage
sbin_UTILITIES = grub-setup
diff --git a/conf/i386-qemu.rmk b/conf/i386-qemu.rmk
index 17e4f1129..97273e1ce 100644
--- a/conf/i386-qemu.rmk
+++ b/conf/i386-qemu.rmk
@@ -1,11 +1,6 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -fno-builtin -m32
-COMMON_CFLAGS = -fno-builtin -mrtd -mregparm=3 -m32
-COMMON_LDFLAGS = -m32 -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS = -mrtd -mregparm=3
# Images.
@@ -42,26 +37,11 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
kern/env.c \
term/i386/pc/vga_text.c term/i386/vga_common.c \
symlist.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- machine/boot.h machine/console.h machine/init.h \
- machine/memory.h machine/loader.h list.h handler.h command.h i18n.h \
- env_private.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)$(GRUB_KERNEL_MACHINE_LINK_ADDR)
kernel_img_FORMAT = binary
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in
diff --git a/conf/mips-yeeloong.rmk b/conf/mips-yeeloong.rmk
index d5e1d1c5d..0d57a2884 100644
--- a/conf/mips-yeeloong.rmk
+++ b/conf/mips-yeeloong.rmk
@@ -3,6 +3,8 @@ LINK_BASE = 0x80200000
target_machine=yeeloong
COMMON_CFLAGS += -march=mips3
COMMON_ASFLAGS += -march=mips3
+
+kernel_img_HEADERS += pci.h
include $(srcdir)/conf/mips.mk
pkglib_IMAGES = kernel.img
@@ -63,4 +65,3 @@ datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
sbin_SCRIPTS += grub-install
grub_install_SOURCES = util/grub-install.in
-
diff --git a/conf/mips.rmk b/conf/mips.rmk
index e04b0adf2..b43edbf69 100644
--- a/conf/mips.rmk
+++ b/conf/mips.rmk
@@ -1,33 +1,10 @@
# -*- makefile -*-
-COMMON_ASFLAGS += -nostdinc
-COMMON_CFLAGS += -ffreestanding -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
-COMMON_LDFLAGS += -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS += -mexplicit-relocs -mflush-func=grub_cpu_flush_cache
# Images.
-
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
- symbol.h term.h time.h types.h loader.h partition.h \
- msdos_partition.h machine/kernel.h handler.h list.h \
- command.h machine/memory.h cpu/libgcc.h cpu/cache.h i18n.h env_private.h
-
-ifeq ($(platform), yeeloong)
-kernel_img_HEADERS += pci.h
-endif
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+kernel_img_HEADERS += cpu/libgcc.h cpu/cache.h
# Scripts.
sbin_SCRIPTS =
diff --git a/conf/powerpc-ieee1275.rmk b/conf/powerpc-ieee1275.rmk
index a22c38ec1..86f6ddcb3 100644
--- a/conf/powerpc-ieee1275.rmk
+++ b/conf/powerpc-ieee1275.rmk
@@ -1,29 +1,9 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -D__ASSEMBLY__
-COMMON_CFLAGS = -ffreestanding
-COMMON_LDFLAGS += -nostdlib
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
-
# Images.
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h misc.h mm.h net.h parser.h reader.h \
- symbol.h term.h time.h types.h powerpc/libgcc.h loader.h partition.h \
- msdos_partition.h ieee1275/ieee1275.h machine/kernel.h handler.h list.h \
- command.h i18n.h env_private.h
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
+kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h
# Programs
pkglib_PROGRAMS = kernel.img
diff --git a/conf/sparc64-ieee1275.rmk b/conf/sparc64-ieee1275.rmk
index d057c53d6..c5096ec33 100644
--- a/conf/sparc64-ieee1275.rmk
+++ b/conf/sparc64-ieee1275.rmk
@@ -1,12 +1,8 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -m64
-COMMON_CFLAGS = -ffreestanding -m64 -mno-app-regs
-COMMON_LDFLAGS = -melf64_sparc -nostdlib -mno-relax
-
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
+COMMON_CFLAGS = -mno-app-regs
+COMMON_LDFLAGS = -melf64_sparc -mno-relax
# Images.
pkglib_IMAGES = boot.img diskboot.img kernel.img
@@ -23,15 +19,7 @@ diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
diskboot_img_FORMAT = binary
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- list.h handler.h command.h i18n.h \
- sparc64/libgcc.h ieee1275/ieee1275.h machine/kernel.h \
- sparc64/ieee1275/ieee1275.h env_private.h
+kernel_img_HEADERS += cpu/libgcc.h ieee1275/ieee1275.h cpu/ieee1275/ieee1275.h
kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
@@ -48,15 +36,9 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
symlist.c kern/$(target_cpu)/cache.S
kernel_img_CFLAGS = $(COMMON_CFLAGS)
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
-kernel_img_LDFLAGS = -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
+kernel_img_LDFLAGS = -Wl,-N,-Ttext,0x200000,-Bstatic,-melf64_sparc -static-libgcc -lgcc
kernel_img_FORMAT = binary
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
# Utilities.
bin_UTILITIES = grub-mkimage
sbin_UTILITIES = grub-setup grub-ofpathname
diff --git a/conf/x86-efi.rmk b/conf/x86-efi.rmk
new file mode 100644
index 000000000..5cb472168
--- /dev/null
+++ b/conf/x86-efi.rmk
@@ -0,0 +1,113 @@
+# -*- makefile -*-
+
+# Utilities.
+bin_UTILITIES = grub-mkimage
+
+# For grub-mkimage.
+grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
+ util/misc.c util/resolve.c
+util/i386/efi/grub-mkimage.c_DEPENDENCIES = Makefile
+
+# Scripts.
+sbin_SCRIPTS = grub-install
+
+# For grub-install.
+grub_install_SOURCES = util/i386/efi/grub-install.in
+
+# Modules.
+pkglib_PROGRAMS = kernel.img
+pkglib_MODULES = chain.mod appleldr.mod \
+ linux.mod halt.mod \
+ datetime.mod loadbios.mod \
+ fixvideo.mod mmap.mod acpi.mod
+
+# For kernel.img.
+kernel_img_RELOCATABLE = yes
+kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c \
+ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
+ kern/misc.c kern/mm.c kern/term.c \
+ kern/rescue_parser.c kern/rescue_reader.c \
+ kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
+ kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
+ term/efi/console.c disk/efi/efidisk.c \
+ kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
+ kern/i386/tsc.c kern/i386/pit.c \
+ kern/generic/rtc_get_time_ms.c \
+ kern/generic/millisleep.c
+ifeq ($(target_cpu),x86_64)
+kernel_img_SOURCES += kern/x86_64/efi/callwrap.S
+endif
+kernel_img_HEADERS += efi/efi.h efi/time.h efi/disk.h i386/pit.h
+kernel_img_CFLAGS = $(COMMON_CFLAGS)
+kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
+kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For acpi.mod.
+acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
+acpi_mod_CFLAGS = $(COMMON_CFLAGS)
+acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For mmap.mod.
+mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
+ mmap/efi/mmap.c
+mmap_mod_CFLAGS = $(COMMON_CFLAGS)
+mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For chain.mod.
+chain_mod_SOURCES = loader/efi/chainloader.c
+chain_mod_CFLAGS = $(COMMON_CFLAGS)
+chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For appleldr.mod.
+appleldr_mod_SOURCES = loader/efi/appleloader.c
+appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
+appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For linux.mod.
+linux_mod_SOURCES = loader/i386/efi/linux.c
+ifeq ($(target_cpu), x86_64)
+linux_mod_SOURCES += loader/i386/linux_trampoline.S
+endif
+linux_mod_CFLAGS = $(COMMON_CFLAGS)
+linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
+linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For halt.mod.
+halt_mod_SOURCES = commands/halt.c
+halt_mod_CFLAGS = $(COMMON_CFLAGS)
+halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For datetime.mod
+datetime_mod_SOURCES = lib/efi/datetime.c
+datetime_mod_CFLAGS = $(COMMON_CFLAGS)
+datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For loadbios.mod
+loadbios_mod_SOURCES = commands/efi/loadbios.c
+loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
+loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+# For fixvideo.mod
+fixvideo_mod_SOURCES = commands/efi/fixvideo.c
+fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
+fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+pkglib_MODULES += efi_uga.mod
+efi_uga_mod_SOURCES = video/efi_uga.c
+efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
+efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+pkglib_MODULES += efi_gop.mod
+efi_gop_mod_SOURCES = video/efi_gop.c
+efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
+efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+pkglib_MODULES += xnu.mod
+xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
+ loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
+xnu_mod_CFLAGS = $(COMMON_CFLAGS)
+xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
+xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
+
+include $(srcdir)/conf/i386.mk
+include $(srcdir)/conf/common.mk
diff --git a/conf/x86_64-efi.rmk b/conf/x86_64-efi.rmk
index 4116894f4..200621280 100644
--- a/conf/x86_64-efi.rmk
+++ b/conf/x86_64-efi.rmk
@@ -1,135 +1,5 @@
# -*- makefile -*-
-COMMON_ASFLAGS = -nostdinc -fno-builtin -m64
-COMMON_CFLAGS = -fno-builtin -m64
-COMMON_LDFLAGS = -melf_x86_64 -nostdlib
+COMMON_LDFLAGS = -melf_x86_64
-# Used by various components. These rules need to precede them.
-script/lexer.c_DEPENDENCIES = grub_script.tab.h
-
-# Utilities.
-bin_UTILITIES = grub-mkimage
-
-# For grub-mkimage.
-grub_mkimage_SOURCES = gnulib/progname.c util/i386/efi/grub-mkimage.c \
- util/misc.c util/resolve.c
-
-# For grub-setup.
-#grub_setup_SOURCES = util/i386/pc/grub-setup.c util/hostdisk.c \
-# util/misc.c util/getroot.c kern/device.c kern/disk.c \
-# kern/err.c kern/misc.c fs/fat.c fs/ext2.c fs/xfs.c fs/affs.c \
-# fs/sfs.c kern/parser.c kern/partition.c partmap/msdos.c \
-# fs/ufs.c fs/ufs2.c fs/minix.c fs/hfs.c fs/jfs.c fs/hfsplus.c kern/file.c \
-# kern/fs.c kern/env.c fs/fshelp.c
-
-# Scripts.
-sbin_SCRIPTS = grub-install
-
-# For grub-install.
-grub_install_SOURCES = util/i386/efi/grub-install.in
-
-# Modules.
-pkglib_PROGRAMS = kernel.img
-pkglib_MODULES = chain.mod appleldr.mod \
- halt.mod linux.mod \
- datetime.mod loadbios.mod \
- fixvideo.mod mmap.mod acpi.mod
-
-# For kernel.img.
-kernel_img_RELOCATABLE = yes
-kernel_img_SOURCES = kern/x86_64/efi/startup.S kern/x86_64/efi/callwrap.S \
- kern/main.c kern/device.c \
- kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
- kern/misc.c kern/mm.c kern/term.c \
- kern/rescue_parser.c kern/rescue_reader.c \
- kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
- kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
- kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
- kern/i386/tsc.c kern/i386/pit.c \
- kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c \
- term/efi/console.c disk/efi/efidisk.c
-kernel_img_HEADERS = boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
- env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
- partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
- efi/efi.h efi/time.h efi/disk.h machine/loader.h i386/pit.h list.h \
- handler.h command.h i18n.h env_private.h
-kernel_img_CFLAGS = $(COMMON_CFLAGS)
-kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
-kernel_img_LDFLAGS = $(COMMON_LDFLAGS)
-
-MOSTLYCLEANFILES += symlist.c
-MOSTLYCLEANFILES += symlist.c kernel_syms.lst
-DEFSYMFILES += kernel_syms.lst
-
-symlist.c: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h gensymlist.sh
- /bin/sh gensymlist.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-kernel_syms.lst: $(addprefix include/grub/,$(kernel_img_HEADERS)) config.h genkernsyms.sh
- /bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
-
-# For acpi.mod.
-acpi_mod_SOURCES = commands/acpi.c commands/efi/acpi.c
-acpi_mod_CFLAGS = $(COMMON_CFLAGS)
-acpi_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For mmap.mod.
-mmap_mod_SOURCES = mmap/mmap.c mmap/i386/uppermem.c mmap/i386/mmap.c \
- mmap/efi/mmap.c
-mmap_mod_CFLAGS = $(COMMON_CFLAGS)
-mmap_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For chain.mod.
-chain_mod_SOURCES = loader/efi/chainloader.c
-chain_mod_CFLAGS = $(COMMON_CFLAGS)
-chain_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For appleldr.mod.
-appleldr_mod_SOURCES = loader/efi/appleloader.c
-appleldr_mod_CFLAGS = $(COMMON_CFLAGS)
-appleldr_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For linux.mod.
-linux_mod_SOURCES = loader/i386/efi/linux.c loader/i386/linux_trampoline.S
-linux_mod_CFLAGS = $(COMMON_CFLAGS)
-linux_mod_ASFLAGS = $(COMMON_ASFLAGS)
-linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For halt.mod.
-halt_mod_SOURCES = commands/halt.c
-halt_mod_CFLAGS = $(COMMON_CFLAGS)
-halt_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For datetime.mod
-datetime_mod_SOURCES = lib/efi/datetime.c
-datetime_mod_CFLAGS = $(COMMON_CFLAGS)
-datetime_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For loadbios.mod
-loadbios_mod_SOURCES = commands/efi/loadbios.c
-loadbios_mod_CFLAGS = $(COMMON_CFLAGS)
-loadbios_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# For fixvideo.mod
-fixvideo_mod_SOURCES = commands/efi/fixvideo.c
-fixvideo_mod_CFLAGS = $(COMMON_CFLAGS)
-fixvideo_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += efi_uga.mod
-efi_uga_mod_SOURCES = video/efi_uga.c
-efi_uga_mod_CFLAGS = $(COMMON_CFLAGS)
-efi_uga_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += efi_gop.mod
-efi_gop_mod_SOURCES = video/efi_gop.c
-efi_gop_mod_CFLAGS = $(COMMON_CFLAGS)
-efi_gop_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += xnu.mod
-xnu_mod_SOURCES = loader/xnu_resume.c loader/i386/xnu.c loader/i386/efi/xnu.c \
- loader/macho32.c loader/macho64.c loader/macho.c loader/xnu.c
-xnu_mod_CFLAGS = $(COMMON_CFLAGS)
-xnu_mod_LDFLAGS = $(COMMON_LDFLAGS)
-xnu_mod_ASFLAGS = $(COMMON_ASFLAGS)
-
-include $(srcdir)/conf/i386.mk
-include $(srcdir)/conf/common.mk
+include $(srcdir)/conf/x86-efi.mk
diff --git a/configure.ac b/configure.ac
index 7c8bdb62c..758a767ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -353,6 +353,7 @@ AC_MSG_RESULT([$TARGET_OBJ2ELF])
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
+ TARGET_ASFLAGS="$TARGET_CFLAGS -m32"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
TARGET_MODULE_FORMAT="elf32"
fi
@@ -360,6 +361,7 @@ fi
if test "x$target_m64" = x1; then
# Force 64-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m64"
+ TARGET_ASFLAGS="$TARGET_ASFLAGS -m64"
TARGET_LDFLAGS="$TARGET_LDFLAGS -m64"
TARGET_MODULE_FORMAT="elf64"
fi
diff --git a/gensymlist.sh.in b/gensymlist.sh.in
index 27fc5e61a..087d0072f 100644
--- a/gensymlist.sh.in
+++ b/gensymlist.sh.in
@@ -37,6 +37,7 @@ cat <.
*/
+#include
EOF
for i in $*; do