Skip to content

Commit e07db28

Browse files
committed
kbuild: fix single target build for external module
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: Masahiro Yamada <[email protected]>
1 parent a4d26f1 commit e07db28

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Makefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,9 +1551,6 @@ else # KBUILD_EXTMOD
15511551

15521552
# We are always building modules
15531553
KBUILD_MODULES := 1
1554-
PHONY += crmodverdir
1555-
crmodverdir:
1556-
$(cmd_crmodverdir)
15571554

15581555
PHONY += $(objtree)/Module.symvers
15591556
$(objtree)/Module.symvers:
@@ -1565,7 +1562,7 @@ $(objtree)/Module.symvers:
15651562

15661563
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
15671564
PHONY += $(module-dirs) modules
1568-
$(module-dirs): crmodverdir $(objtree)/Module.symvers
1565+
$(module-dirs): prepare $(objtree)/Module.symvers
15691566
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
15701567

15711568
modules: $(module-dirs)
@@ -1606,7 +1603,8 @@ help:
16061603

16071604
# Dummies...
16081605
PHONY += prepare scripts
1609-
prepare: ;
1606+
prepare:
1607+
$(cmd_crmodverdir)
16101608
scripts: ;
16111609
endif # KBUILD_EXTMOD
16121610

@@ -1730,17 +1728,14 @@ endif
17301728

17311729
# Modules
17321730
/: prepare scripts FORCE
1733-
$(cmd_crmodverdir)
17341731
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
17351732
$(build)=$(build-dir)
17361733
# Make sure the latest headers are built for Documentation
17371734
Documentation/ samples/: headers_install
17381735
%/: prepare scripts FORCE
1739-
$(cmd_crmodverdir)
17401736
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
17411737
$(build)=$(build-dir)
17421738
%.ko: prepare scripts FORCE
1743-
$(cmd_crmodverdir)
17441739
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
17451740
$(build)=$(build-dir) $(@:.ko=.o)
17461741
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost

0 commit comments

Comments
 (0)