Skip to contentSkip to conversation

Move normal.mod to conf/common.rmk

PATCH In review phcoder 2 participants 4 messages Mar 23, 2009 Kbuild

lore
Share & tools
lore

phcoder

author
#0 lore raw

PATCH 1/1 Move normal.mod to conf/common.rmk

Hello. I propose to create a symlink normal/cpu. This way normal.mod can be moved to conf/common.rmk. Works fine on i386-pc. Can people having other platforms test?

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
Makefile.in +1 -1
index 28aa385..c4c641a 100644
@@ -120,7 +120,7 @@ SCRIPTS = $(bin_SCRIPTS) $(sbin_SCRIPTS) $(grub-mkconfig_SCRIPTS)
 CLEANFILES =
 MOSTLYCLEANFILES = 
 DISTCLEANFILES = config.status config.cache config.log config.h \
-	Makefile stamp-h include/grub/cpu include/grub/machine \
+	Makefile stamp-h include/grub/cpu include/grub/machine normal/cpu \
 	gensymlist.sh genkernsyms.sh build_env.mk
 MAINTAINER_CLEANFILES = $(srcdir)/configure $(addprefix $(srcdir)/,$(MKFILES))
 
conf/common.rmk +15 -0
index 43bc683..72a46bf 100644
@@ -54,6 +54,21 @@ grub_mkfont_CFLAGS = $(freetype_cflags)
 grub_mkfont_LDFLAGS = $(freetype_libs)
 endif
 
+pkglib_MODULES += normal.mod
+
+normal_mod_SOURCES = normal/cmdline.c normal/command.c	\
+	normal/completion.c normal/execute.c		 		\
+	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
+	normal/menu_text.c						\
+	normal/color.c							\
+	normal/menu_viewer.c normal/menu_entry.c			\
+	normal/misc.c grub_script.tab.c 				\
+	normal/script.c							\
+	normal/cpu/setjmp.S
+normal_mod_CFLAGS = $(COMMON_CFLAGS)
+normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
+normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
 # For the parser.
 grub_script.tab.c grub_script.tab.h: normal/parser.y
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/normal/parser.y
conf/i386-coreboot.rmk +1 -22
index 53595de..84d21e5 100644
@@ -96,7 +96,7 @@ sbin_SCRIPTS += grub-install
 grub_install_SOURCES = util/i386/pc/grub-install.in
 
 # Modules.
-pkglib_MODULES = linux.mod normal.mod multiboot.mod 	\
+pkglib_MODULES = linux.mod multiboot.mod 	\
 	aout.mod play.mod serial.mod ata.mod		\
 	memdisk.mod pci.mod lspci.mod reboot.mod	\
 	halt.mod datetime.mod date.mod datehook.mod	\
@@ -107,27 +107,6 @@ linux_mod_SOURCES = loader/i386/linux.c
 linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c			\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/i386/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For reboot.mod.
 reboot_mod_SOURCES = commands/reboot.c kern/i386/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
conf/i386-efi.rmk +1 -22
index 18a99df..6dd569e 100644
@@ -77,7 +77,7 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
+pkglib_MODULES = kernel.mod chain.mod appleldr.mod \
 	linux.mod halt.mod reboot.mod pci.mod lspci.mod \
 	datetime.mod date.mod datehook.mod
 
@@ -111,27 +111,6 @@ symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.
 kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c	\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/i386/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For chain.mod.
 chain_mod_SOURCES = loader/efi/chainloader.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
conf/i386-ieee1275.rmk +1 -22
index a84b5aa..b285d4f 100644
@@ -99,32 +99,11 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/ieee1275/grub-install.in
 
 # Modules.
-pkglib_MODULES = normal.mod halt.mod reboot.mod suspend.mod		\
+pkglib_MODULES = halt.mod reboot.mod suspend.mod		\
 	multiboot.mod aout.mod serial.mod linux.mod	\
 	nand.mod memdisk.mod pci.mod lspci.mod datetime.mod	\
 	date.mod datehook.mod lsmmap.mod
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c			\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/i386/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For multiboot.mod.
 multiboot_mod_SOURCES = loader/ieee1275/multiboot2.c \
 			loader/i386/multiboot_helper.S \
conf/i386-pc.rmk +1 -22
index 60d5182..6e3bcf1 100644
@@ -167,7 +167,7 @@ grub_install_SOURCES = util/i386/pc/grub-install.in
 # For grub-mkrescue.
 grub_mkrescue_SOURCES = util/i386/pc/grub-mkrescue.in
 
-pkglib_MODULES = biosdisk.mod chain.mod linux.mod normal.mod \
+pkglib_MODULES = biosdisk.mod chain.mod linux.mod  \
 	multiboot.mod reboot.mod halt.mod	\
 	vbe.mod vbetest.mod vbeinfo.mod play.mod serial.mod	\
 	ata.mod vga.mod memdisk.mod pci.mod lspci.mod	\
@@ -190,27 +190,6 @@ linux_mod_SOURCES = loader/i386/pc/linux.c
 linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c	\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/i386/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For reboot.mod.
 reboot_mod_SOURCES = commands/reboot.c
 reboot_mod_CFLAGS = $(COMMON_CFLAGS)
conf/powerpc-ieee1275.rmk +0 -22
index 5aaaf56..01df91c 100644
@@ -107,7 +107,6 @@ grub_mkrescue_SOURCES = util/powerpc/ieee1275/grub-mkrescue.in
 # Modules.
 pkglib_MODULES = halt.mod \
 	linux.mod \
-	normal.mod \
 	reboot.mod \
 	suspend.mod \
         multiboot.mod \
@@ -119,27 +118,6 @@ linux_mod_SOURCES = loader/powerpc/ieee1275/linux.c
 linux_mod_CFLAGS = $(COMMON_CFLAGS)
 linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c			\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/powerpc/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For suspend.mod
 suspend_mod_SOURCES = commands/ieee1275/suspend.c
 suspend_mod_CFLAGS = $(COMMON_CFLAGS)
conf/sparc64-ieee1275.rmk +1 -22
index 1658a66..7fc8f7d 100644
@@ -86,7 +86,7 @@ kernel_elf_LDFLAGS = -mno-app-regs -nostdlib -Wl,-N,-Ttext,0x200000,-Bstatic,-me
 # Modules.
 #_linux.mod linux.mod
 pkglib_MODULES = fat.mod ufs.mod ext2.mod minix.mod \
-	hfs.mod jfs.mod normal.mod hello.mod font.mod ls.mod \
+	hfs.mod jfs.mod hello.mod font.mod ls.mod \
 	boot.mod cmp.mod cat.mod terminal.mod fshelp.mod amiga.mod apple.mod \
 	pc.mod suspend.mod loopback.mod help.mod reboot.mod halt.mod sun.mod \
 	configfile.mod search.mod gzio.mod xfs.mod \
@@ -157,27 +157,6 @@ sfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
 #linux_mod_CFLAGS = $(COMMON_CFLAGS)
 #linux_mod_LDFLAGS = $(COMMON_LDFLAGS)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/arg.c normal/cmdline.c normal/command.c	\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/sparc64/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For hello.mod.
 hello_mod_SOURCES = hello/hello.c
 hello_mod_CFLAGS = $(COMMON_CFLAGS)
conf/x86_64-efi.rmk +1 -22
index faa59fb..e7338a1 100644
@@ -79,7 +79,7 @@ sbin_SCRIPTS = grub-install
 grub_install_SOURCES = util/i386/efi/grub-install.in
 
 # Modules.
-pkglib_MODULES = kernel.mod normal.mod chain.mod appleldr.mod \
+pkglib_MODULES = kernel.mod chain.mod appleldr.mod \
 	halt.mod reboot.mod linux.mod pci.mod lspci.mod \
 	datetime.mod date.mod datehook.mod
 
@@ -114,27 +114,6 @@ symlist.c: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h gensymlist.
 kernel_syms.lst: $(addprefix include/grub/,$(kernel_mod_HEADERS)) config.h genkernsyms.sh
 	/bin/sh genkernsyms.sh $(filter %.h,$^) > $@ || (rm -f $@; exit 1)
 
-#
-# Only arch dependant part of normal.mod will be here. Common part for
-# all architecures of normal.mod is at start and should be kept at sync
-# with other makefiles.
-# 
-# Please put arch dependant part of normal.mod at the end of list to
-# keep it simpler to update to different architectures.
-#
-normal_mod_SOURCES = normal/cmdline.c normal/command.c			\
-	normal/completion.c normal/execute.c		 		\
-	normal/function.c normal/lexer.c normal/main.c normal/menu.c	\
-	normal/menu_text.c						\
-	normal/color.c							\
-	normal/menu_viewer.c normal/menu_entry.c			\
-	normal/misc.c grub_script.tab.c 				\
-	normal/script.c							\
-	normal/x86_64/setjmp.S
-normal_mod_CFLAGS = $(COMMON_CFLAGS)
-normal_mod_ASFLAGS = $(COMMON_ASFLAGS)
-normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
 # For chain.mod.
 chain_mod_SOURCES = loader/efi/chainloader.c
 chain_mod_CFLAGS = $(COMMON_CFLAGS)
configure.ac +4 -1
index 80b499c..65a9c4f 100644
@@ -476,13 +476,16 @@ AC_SUBST([freetype_libs])
 grub_CHECK_LINK_DIR
 if test x"$link_dir" = xyes ; then
   AC_CONFIG_LINKS([include/grub/cpu:include/grub/$target_cpu
-	include/grub/machine:include/grub/$target_cpu/$platform])
+	include/grub/machine:include/grub/$target_cpu/$platform
+	normal/cpu:normal/$target_cpu])
 else
   mkdir -p include/grub 2>/dev/null
   rm -rf include/grub/cpu
   cp -rp $srcdir/include/grub/$target_cpu include/grub/cpu 2>/dev/null
   rm -rf include/grub/machine
   cp -rp $srcdir/include/grub/$target_cpu/$platform include/grub/machine 2>/dev/null
+  rm -rf normal/cpu
+  cp -rp $srcdir/normal/$target_cpu normal/cpu 2>/dev/null
 fi
 AC_CONFIG_FILES([Makefile gensymlist.sh genkernsyms.sh])
 AC_CONFIG_FILES([stamp-h], [echo timestamp > stamp-h])
#1 lore raw
Quoted 3 lines · phcoder

Hello. I propose to create a symlink normal/cpu. This way normal.mod can be moved to conf/common.rmk. Works fine on i386-pc. Can people having other platforms test?

I do not like the fact that you hardcoded filenames what can be on platform dependant parts.

I have also though this issue some times and I think the best option would be:

## common.rmk ##

normal.mod: <common files> normal_arch.lib

## arch.rmk ##

normal_arch.lib: setjmp.S <or what ever is needed for the platform.>

author
#2 lore raw

Actually if it was up to me I would have removed setjmp altogether. IMHO it's a bad programming technique. It's used only to launch rescue mode. I would just call the rescue mode interpreter by function. Perhaps Bean who is working on normal.mod splitting has even better idea.
Also IMO normal.mod should have no arch-dependent parts and setjmp.S is an unfortunate example. If some platforms need a special service then it could be provided by drivers and/or commands. I see no reason why additional cpu or platform-dependent would appear in normal.mod setjmp could even be put in a separate module but it's quite a waste because ELF overhead is much bigger then the module itself. Another possibility is ot compile it like

## common.rmk ##

normal.mod: <common files> setjmp.lib

normal_arch.lib: setjmp.S

Quoted 25 lines · Vesa Jääskeläinen
Quoted 3 lines · phcoder

Hello. I propose to create a symlink normal/cpu. This way normal.mod can be moved to conf/common.rmk. Works fine on i386-pc. Can people having other platforms test?

I do not like the fact that you hardcoded filenames what can be on platform dependant parts.

I have also though this issue some times and I think the best option would be:

## common.rmk ##

normal.mod: <common files> normal_arch.lib

## arch.rmk ##

normal_arch.lib: setjmp.S <or what ever is needed for the platform.>

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#3 lore raw
Quoted 11 lines · phcoder

Actually if it was up to me I would have removed setjmp altogether. IMHO it's a bad programming technique. It's used only to launch rescue mode. I would just call the rescue mode interpreter by function. Perhaps Bean who is working on normal.mod splitting has even better idea. Also IMO normal.mod should have no arch-dependent parts and setjmp.S is an unfortunate example. If some platforms need a special service then it could be provided by drivers and/or commands. I see no reason why additional cpu or platform-dependent would appear in normal.mod setjmp could even be put in a separate module but it's quite a waste because ELF overhead is much bigger then the module itself. Another possibility is ot compile it like

Or.. one could move it to kernel. But that is not as such a kernel component. More like a system library functionality.

Actually setjmp might be used in bitmap loaders.