Commit Message

Currently, KBUILD_MODNAME is defined only when $(modname) contains
just one word. If an object is shared between multiple modules,
undefined KBUILD_MODNAME causes a build error.
A simple test case is as follows:
obj-m += foo.o
obj-m += bar.o
foo-objs := foo-bar-common.o foo-main.o
bar-objs := foo-bar-common.o bar-main.o
In this case, we do not know what to define for KBUILD_MODNAME when
compiling foo-bar-common.o ("foo" or "bar" ?), so one reasonable
solution is let it fall back to $(basetarget) (= "foo-bar-common").
It would be better to avoid such a design where possible, but we
already have such a case, for example,
drivers/net/ethernet/cavium/liquidio/Makefile
I slightly refactored implementation; we can check $(word 2, $(modname))
instead of $(filter 1,$(words $(modname))).
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
scripts/Makefile.lib | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)