kbuild: fix single target build for external module
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 21 Nov 2018 23:11:54 +0000 (08:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:52:21 +0000 (08:52 +0100)
commitf7a5ed083e71b700ee9a5c89fcb37cfc22e3731a
tree0963e586cdf60857c626b658a7b51bff0bd0e03c
parentf28d930810ee3b4483a76712478279370b7f0281
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Makefile