diff --git a/conf/common.rmk b/conf/common.rmk
index 4133e7c97..b97de8e22 100644
--- a/conf/common.rmk
+++ b/conf/common.rmk
@@ -103,6 +103,12 @@ grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.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 \
+ machine/memory.h machine/loader.h machine/kernel.h \
+ list.h handler.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)
diff --git a/conf/i386-coreboot.rmk b/conf/i386-coreboot.rmk
index dbcba7f6b..44b80761e 100644
--- a/conf/i386-coreboot.rmk
+++ b/conf/i386-coreboot.rmk
@@ -29,12 +29,6 @@ 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
diff --git a/conf/i386-ieee1275.rmk b/conf/i386-ieee1275.rmk
index ebcde000c..d23ba4c0e 100644
--- a/conf/i386-ieee1275.rmk
+++ b/conf/i386-ieee1275.rmk
@@ -29,11 +29,7 @@ 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
diff --git a/conf/i386-pc.rmk b/conf/i386-pc.rmk
index 535c91109..b620c43af 100644
--- a/conf/i386-pc.rmk
+++ b/conf/i386-pc.rmk
@@ -59,13 +59,8 @@ 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)
diff --git a/conf/i386-qemu.rmk b/conf/i386-qemu.rmk
index af150932f..355870c89 100644
--- a/conf/i386-qemu.rmk
+++ b/conf/i386-qemu.rmk
@@ -42,12 +42,6 @@ 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)
diff --git a/conf/mips-yeeloong.rmk b/conf/mips-yeeloong.rmk
index d5e1d1c5d..8b6c0426a 100644
--- a/conf/mips-yeeloong.rmk
+++ b/conf/mips-yeeloong.rmk
@@ -24,6 +24,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
video/bitmap_scale.c video/sm712.c bus/pci.c bus/bonito.c \
term/gfxterm.c commands/extcmd.c lib/arg.c \
symlist.c
+kernel_img_HEADERS += pci.h
kernel_img_CFLAGS = $(COMMON_CFLAGS) -DUSE_ASCII_FAILBACK
kernel_img_ASFLAGS = $(COMMON_ASFLAGS)
kernel_img_LDFLAGS = $(COMMON_LDFLAGS) -static-libgcc -lgcc \
diff --git a/conf/mips.rmk b/conf/mips.rmk
index 32d945734..6948d8d66 100644
--- a/conf/mips.rmk
+++ b/conf/mips.rmk
@@ -9,15 +9,7 @@ COMMON_LDFLAGS += -nostdlib
script/lexer.c_DEPENDENCIES = grub_script.tab.h
# Images.
-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
+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 d5d6d3bd2..59cde4efe 100644
--- a/conf/powerpc-ieee1275.rmk
+++ b/conf/powerpc-ieee1275.rmk
@@ -10,11 +10,7 @@ script/lexer.c_DEPENDENCIES = grub_script.tab.h
# Images.
-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
+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 2668f1060..dbca42e58 100644
--- a/conf/sparc64-ieee1275.rmk
+++ b/conf/sparc64-ieee1275.rmk
@@ -23,12 +23,7 @@ diskboot_img_ASFLAGS = $(COMMON_ASFLAGS)
diskboot_img_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-N,-Ttext,0x4200
diskboot_img_FORMAT = binary
-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 \
diff --git a/conf/x86-efi.rmk b/conf/x86-efi.rmk
index 58918e145..94f305506 100644
--- a/conf/x86-efi.rmk
+++ b/conf/x86-efi.rmk
@@ -48,11 +48,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c
ifeq ($(target_cpu),x86_64)
kernel_img_SOURCES += kern/x86_64/efi/callwrap.S
endif
-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_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)
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