linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] kbuild: fix single target build for external module
@ 2018-11-21 23:11 Masahiro Yamada
  2018-11-21 23:11 ` [PATCH 2/2] kbuild: remove 'scripts' dummy target for external module build Masahiro Yamada
  2018-11-26 14:51 ` [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada
  0 siblings, 2 replies; 3+ messages in thread
From: Masahiro Yamada @ 2018-11-21 23:11 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

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(-)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] kbuild: remove 'scripts' dummy target for external module build
  2018-11-21 23:11 [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada
@ 2018-11-21 23:11 ` Masahiro Yamada
  2018-11-26 14:51 ` [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2018-11-21 23:11 UTC (permalink / raw)
  To: linux-kbuild; +Cc: Masahiro Yamada, Michal Marek, linux-kernel

Make simply skips a missing rule as long as it is marked as PHONY.
Remove the dummy target.

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

 Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Makefile b/Makefile
index 36f3f0e..269a9bf 100644
--- a/Makefile
+++ b/Makefile
@@ -1604,11 +1604,9 @@ help:
 	@echo  '  clean           - remove generated files in module directory only'
 	@echo  ''
 
-# Dummies...
 PHONY += prepare scripts
 prepare:
 	$(cmd_crmodverdir)
-scripts: ;
 endif # KBUILD_EXTMOD
 
 clean: $(clean-dirs)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] kbuild: fix single target build for external module
  2018-11-21 23:11 [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada
  2018-11-21 23:11 ` [PATCH 2/2] kbuild: remove 'scripts' dummy target for external module build Masahiro Yamada
@ 2018-11-26 14:51 ` Masahiro Yamada
  1 sibling, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2018-11-26 14:51 UTC (permalink / raw)
  To: Linux Kbuild mailing list; +Cc: Michal Marek, Linux Kernel Mailing List

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-26 14:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-21 23:11 [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada
2018-11-21 23:11 ` [PATCH 2/2] kbuild: remove 'scripts' dummy target for external module build Masahiro Yamada
2018-11-26 14:51 ` [PATCH 1/2] kbuild: fix single target build for external module Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).