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>
Sat, 21 Dec 2019 09:41:18 +0000 (10:41 +0100)
commitb1335cdef44252f5fd20837defaae09762181c58
treee30d325daa658644f42c8cb6fba0aa2956b78693
parent53a7d908b4730f599b4b0f9476e900b88d2a871f
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