diff mbox series

[1/2] kbuild: fix single target build for external module

Message ID 1542841915-19686-1-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit e07db28eea38ed4e332b3a89f3995c86b713cb5b
Headers show
Series [1/2] kbuild: fix single target build for external module | expand

Commit Message

Masahiro Yamada Nov. 21, 2018, 11:11 p.m. UTC
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 for /, %/, %.ko
single targets for external modules. Create .tmp_versions in the
'prepare' target.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 Makefile | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.7.4

Comments

Masahiro Yamada Nov. 26, 2018, 2:51 p.m. UTC | #1
On Thu, Nov 22, 2018 at 6:33 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>

> 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 for /, %/, %.ko

> single targets for external modules. Create .tmp_versions in the

> 'prepare' target.

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> ---



Applied to linux-kbuild.



>  Makefile | 11 +++--------

>  1 file changed, 3 insertions(+), 8 deletions(-)

>

> diff --git a/Makefile b/Makefile

> index d5da1df..36f3f0e 100644

> --- a/Makefile

> +++ b/Makefile

> @@ -1554,9 +1554,6 @@ else # KBUILD_EXTMOD

>

>  # We are always building modules

>  KBUILD_MODULES := 1

> -PHONY += crmodverdir

> -crmodverdir:

> -       $(cmd_crmodverdir)

>

>  PHONY += $(objtree)/Module.symvers

>  $(objtree)/Module.symvers:

> @@ -1568,7 +1565,7 @@ $(objtree)/Module.symvers:

>

>  module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))

>  PHONY += $(module-dirs) modules

> -$(module-dirs): crmodverdir $(objtree)/Module.symvers

> +$(module-dirs): prepare $(objtree)/Module.symvers

>         $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)

>

>  modules: $(module-dirs)

> @@ -1609,7 +1606,8 @@ help:

>

>  # Dummies...

>  PHONY += prepare scripts

> -prepare: ;

> +prepare:

> +       $(cmd_crmodverdir)

>  scripts: ;

>  endif # KBUILD_EXTMOD

>

> @@ -1733,17 +1731,14 @@ endif

>

>  # Modules

>  /: prepare scripts FORCE

> -       $(cmd_crmodverdir)

>         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \

>         $(build)=$(build-dir)

>  # Make sure the latest headers are built for Documentation

>  Documentation/ samples/: headers_install

>  %/: prepare scripts FORCE

> -       $(cmd_crmodverdir)

>         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \

>         $(build)=$(build-dir)

>  %.ko: prepare scripts FORCE

> -       $(cmd_crmodverdir)

>         $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)   \

>         $(build)=$(build-dir) $(@:.ko=.o)

>         $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost

> --

> 2.7.4

>



-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index d5da1df..36f3f0e 100644
--- a/Makefile
+++ b/Makefile
@@ -1554,9 +1554,6 @@  else # KBUILD_EXTMOD
 
 # We are always building modules
 KBUILD_MODULES := 1
-PHONY += crmodverdir
-crmodverdir:
-	$(cmd_crmodverdir)
 
 PHONY += $(objtree)/Module.symvers
 $(objtree)/Module.symvers:
@@ -1568,7 +1565,7 @@  $(objtree)/Module.symvers:
 
 module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
 PHONY += $(module-dirs) modules
-$(module-dirs): crmodverdir $(objtree)/Module.symvers
+$(module-dirs): prepare $(objtree)/Module.symvers
 	$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
 
 modules: $(module-dirs)
@@ -1609,7 +1606,8 @@  help:
 
 # Dummies...
 PHONY += prepare scripts
-prepare: ;
+prepare:
+	$(cmd_crmodverdir)
 scripts: ;
 endif # KBUILD_EXTMOD
 
@@ -1733,17 +1731,14 @@  endif
 
 # Modules
 /: prepare scripts FORCE
-	$(cmd_crmodverdir)
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
 	$(build)=$(build-dir)
 # Make sure the latest headers are built for Documentation
 Documentation/ samples/: headers_install
 %/: prepare scripts FORCE
-	$(cmd_crmodverdir)
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
 	$(build)=$(build-dir)
 %.ko: prepare scripts FORCE
-	$(cmd_crmodverdir)
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)   \
 	$(build)=$(build-dir) $(@:.ko=.o)
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost