提交 f7a5ed08 编写于 作者: M Masahiro Yamada 提交者: Greg Kroah-Hartman

kbuild: fix single target build for external module

[ Upstream commit e07db28eea38ed4e332b3a89f3995c86b713cb5b ]

Building a single target in an external module fails due to missing
.tmp_versions directory.

For example,

  $ make -C /lib/modules/$(uname -r)/build M=$PWD foo.o

will fail in the following way:

  CC [M]  /home/masahiro/foo/foo.o
/bin/sh: 1: cannot create /home/masahiro/foo/.tmp_versions/foo.mod: Directory nonexistent

This is because $(cmd_crmodverdir) is executed only before building
/, %/, %.ko single targets of external modules. Create .tmp_versions
in the 'prepare' target.
Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 f28d9308
...@@ -1507,9 +1507,6 @@ else # KBUILD_EXTMOD ...@@ -1507,9 +1507,6 @@ else # KBUILD_EXTMOD
# We are always building modules # We are always building modules
KBUILD_MODULES := 1 KBUILD_MODULES := 1
PHONY += crmodverdir
crmodverdir:
$(cmd_crmodverdir)
PHONY += $(objtree)/Module.symvers PHONY += $(objtree)/Module.symvers
$(objtree)/Module.symvers: $(objtree)/Module.symvers:
...@@ -1521,7 +1518,7 @@ $(objtree)/Module.symvers: ...@@ -1521,7 +1518,7 @@ $(objtree)/Module.symvers:
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
PHONY += $(module-dirs) modules PHONY += $(module-dirs) modules
$(module-dirs): crmodverdir $(objtree)/Module.symvers $(module-dirs): prepare $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
modules: $(module-dirs) modules: $(module-dirs)
...@@ -1562,7 +1559,8 @@ help: ...@@ -1562,7 +1559,8 @@ help:
# Dummies... # Dummies...
PHONY += prepare scripts PHONY += prepare scripts
prepare: ; prepare:
$(cmd_crmodverdir)
scripts: ; scripts: ;
endif # KBUILD_EXTMOD endif # KBUILD_EXTMOD
...@@ -1689,17 +1687,14 @@ endif ...@@ -1689,17 +1687,14 @@ endif
# Modules # Modules
/: prepare scripts FORCE /: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(build)=$(build-dir)
# Make sure the latest headers are built for Documentation # Make sure the latest headers are built for Documentation
Documentation/ samples/: headers_install Documentation/ samples/: headers_install
%/: prepare scripts FORCE %/: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(build)=$(build-dir)
%.ko: prepare scripts FORCE %.ko: prepare scripts FORCE
$(cmd_crmodverdir)
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
$(build)=$(build-dir) $(@:.ko=.o) $(build)=$(build-dir) $(@:.ko=.o)
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册