Skip to content

Commit 8ae071f

Browse files
committed
kbuild: make modules_install copy modules.builtin(.modinfo)
Josh Triplett reports that initramfs-tools needs modules.builtin and modules.builtin.modinfo to create a working initramfs for a non-modular kernel. If this is a general tooling issue not limited to Debian, I think it makes sense to change modules_install. This commit changes the targets as follows when CONFIG_MODULES=n. In-tree builds: make modules -> no-op make modules_install -> install modules.builtin(.modinfo) External module builds: make modules -> show error message like before make modules_install -> show error message like before Link: https://lore.kernel.org/lkml/36a4014c73a52af27d930d3ca31d362b60f4461c.1686356364.git.josh@joshtriplett.org/ Reported-by: Josh Triplett <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Nicolas Schier <[email protected]> Tested-by: Nicolas Schier <[email protected]> Reviewed-by: Josh Triplett <[email protected]> Tested-by: Josh Triplett <[email protected]>
1 parent 8ed7e33 commit 8ae071f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Makefile

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,8 @@ modules_sign_only := y
15451545
endif
15461546
endif
15471547

1548+
endif # CONFIG_MODULES
1549+
15481550
modinst_pre :=
15491551
ifneq ($(filter modules_install,$(MAKECMDGOALS)),)
15501552
modinst_pre := __modinst_pre
@@ -1555,18 +1557,18 @@ PHONY += __modinst_pre
15551557
__modinst_pre:
15561558
@rm -rf $(MODLIB)/kernel
15571559
@rm -f $(MODLIB)/source
1558-
@mkdir -p $(MODLIB)/kernel
1560+
@mkdir -p $(MODLIB)
1561+
ifdef CONFIG_MODULES
15591562
@ln -s $(abspath $(srctree)) $(MODLIB)/source
15601563
@if [ ! $(objtree) -ef $(MODLIB)/build ]; then \
15611564
rm -f $(MODLIB)/build ; \
15621565
ln -s $(CURDIR) $(MODLIB)/build ; \
15631566
fi
15641567
@sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
1568+
endif
15651569
@cp -f modules.builtin $(MODLIB)/
15661570
@cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
15671571

1568-
endif # CONFIG_MODULES
1569-
15701572
###
15711573
# Cleaning is done on three levels.
15721574
# make clean Delete most generated files
@@ -1908,6 +1910,13 @@ help:
19081910
@echo ' clean - remove generated files in module directory only'
19091911
@echo ''
19101912

1913+
__external_modules_error:
1914+
@echo >&2 '***'
1915+
@echo >&2 '*** The present kernel disabled CONFIG_MODULES.'
1916+
@echo >&2 '*** You cannot build or install external modules.'
1917+
@echo >&2 '***'
1918+
@false
1919+
19111920
endif # KBUILD_EXTMOD
19121921

19131922
# ---------------------------------------------------------------------------
@@ -1944,13 +1953,10 @@ else # CONFIG_MODULES
19441953
# Modules not configured
19451954
# ---------------------------------------------------------------------------
19461955

1947-
modules modules_install:
1948-
@echo >&2 '***'
1949-
@echo >&2 '*** The present kernel configuration has modules disabled.'
1950-
@echo >&2 '*** To use the module feature, please run "make menuconfig" etc.'
1951-
@echo >&2 '*** to enable CONFIG_MODULES.'
1952-
@echo >&2 '***'
1953-
@exit 1
1956+
PHONY += __external_modules_error
1957+
1958+
modules modules_install: __external_modules_error
1959+
@:
19541960

19551961
KBUILD_MODULES :=
19561962

0 commit comments

Comments
 (0)