kbuild: generate modules.builtin
PATCH 1/3 kbuild: generate modules.builtin
From: Michal Marek <[email protected]>
To make it easier for tools like mkinitrd to detect whether a needed module is missing or whether it is compiled into the kernel, install a modules.builtin file listing all modules built into the kernel. This is done by generating an alternate config file with all tristate =y options set to =Y and reading the makefiles with this config included. The built in modules then appear in obj-Y.
Signed-off-by Michal Marek <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Sam Ravnborg <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
.gitignore | 1 Makefile | 14 +++++++-- scripts/Kbuild.include | 6 ++++ scripts/Makefile.lib | 5 ++- scripts/Makefile.modbuiltin | 48 ++++++++++++++++++++++++++++++++++ scripts/kconfig/confdata.c | 48 +++++++++++++++++++++++++++++----- 6 files changed, 110 insertions(+), 12 deletions(-)
.gitignore renamed from .gitignore~kbuild-generate-modulesbuiltin +1 -0
@@ -22,6 +22,7 @@ *.lst *.symtypes *.order +modules.builtin *.elf *.bin *.gz
Makefile renamed from Makefile~kbuild-generate-modulesbuiltin +10 -4
@@ -887,6 +887,9 @@ $(sort $(vmlinux-init) $(vmlinux-main)) PHONY += $(vmlinux-dirs) $(vmlinux-dirs): prepare scripts $(Q)$(MAKE) $(build)=$@ +ifdef CONFIG_MODULES + $(Q)$(MAKE) $(modbuiltin)=$@ +endif # Build the kernel release string #
@@ -1091,6 +1094,7 @@ all: modules PHONY += modules modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order + $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.builtin) > $(objtree)/modules.builtin @$(kecho) ' Building modules, stage 2.'; $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
@@ -1119,7 +1123,7 @@ _modinst_: rm -f $(MODLIB)/build ; \ ln -s $(objtree) $(MODLIB)/build ; \ fi - @cp -f $(objtree)/modules.order $(MODLIB)/ + @cp -f $(objtree)/modules.{order,builtin} $(MODLIB)/ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst # This depmod is only for convenience to give the initial
@@ -1181,8 +1185,9 @@ clean: archclean $(clean-dirs) \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ -o -name '*.symtypes' -o -name 'modules.order' \ - -o -name 'Module.markers' -o -name '.tmp_*.o.*' \ - -o -name '*.gcno' \) -type f -print | xargs rm -f + -o -name 'modules.builtin' -o -name 'Module.markers' \ + -o -name '.tmp_*.o.*' -o -name '*.gcno' \) \ + -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config #
@@ -1380,7 +1385,8 @@ $(clean-dirs): clean: rm-dirs := $(MODVERDIR) clean: rm-files := $(KBUILD_EXTMOD)/Module.symvers \ $(KBUILD_EXTMOD)/Module.markers \ - $(KBUILD_EXTMOD)/modules.order + $(KBUILD_EXTMOD)/modules.order \ + $(KBUILD_EXTMOD)/modules.builtin clean: $(clean-dirs) $(call cmd,rmdirs) $(call cmd,rmfiles)
scripts/Kbuild.include renamed from scripts/Kbuild.include~kbuild-generate-modulesbuiltin +6 -0
@@ -149,6 +149,12 @@ ld-option = $(call try-run,\ # $(Q)$(MAKE) $(build)=dir build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj +### +# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.modbuiltin obj= +# Usage: +# $(Q)$(MAKE) $(modbuiltin)=dir +modbuiltin := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.modbuiltin obj + # Prefix -I with $(srctree) if it is not an absolute path. # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \
scripts/Makefile.lib renamed from scripts/Makefile.lib~kbuild-generate-modulesbuiltin +4 -1
@@ -37,6 +37,8 @@ modorder := $(patsubst %/,%/modules.orde __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) subdir-y += $(__subdir-y) +__subdir-Y := $(patsubst %/,%,$(filter %/, $(obj-Y))) +subdir-Y += $(__subdir-Y) __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) subdir-m += $(__subdir-m) obj-y := $(patsubst %/, %/built-in.o, $(obj-y))
@@ -44,7 +46,7 @@ obj-m := $(filter-out %/, $(obj-m)) # Subdirectories we need to descend into -subdir-ym := $(sort $(subdir-y) $(subdir-m)) +subdir-ym := $(sort $(subdir-y) $(subdir-Y) $(subdir-m)) # if $(foo-objs) exists, foo.o is a composite object multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
@@ -76,6 +78,7 @@ always := $(addprefix $(obj)/,$(always) targets := $(addprefix $(obj)/,$(targets)) modorder := $(addprefix $(obj)/,$(modorder)) obj-y := $(addprefix $(obj)/,$(obj-y)) +obj-Y := $(addprefix $(obj)/,$(obj-Y)) obj-m := $(addprefix $(obj)/,$(obj-m)) lib-y := $(addprefix $(obj)/,$(lib-y)) subdir-obj-y := $(addprefix $(obj)/,$(subdir-obj-y))
scripts/Makefile.modbuiltin new file +48 -0
48 lines not on this page · raw message
scripts/kconfig/confdata.c renamed from scripts/kconfig/confdata.c~kbuild-generate-modulesbuiltin +41 -7
126 lines not on this page · raw message
_