[U-Boot] [PATCH] kbuild,tegra124: add dummy obj- for Kbuild

Masahiro Yamada yamada.m at jp.panasonic.com
Fri Feb 21 12:45:06 CET 2014


Hello Stefen,


On Thu, 20 Feb 2014 09:15:21 -0700
Stephen Warren <swarren at wwwdotorg.org> wrote:

> On 02/20/2014 01:24 AM, Masahiro Yamada wrote:
> > Hello Stephen,
> > 
> > 
> > On Wed, 19 Feb 2014 09:36:14 -0700
> > Stephen Warren <swarren at wwwdotorg.org> wrote:
> > 
> >> On 02/19/2014 07:46 AM, Albert ARIBAUD wrote:
> >>> Hi Masahiro,
> >>>
> >>> On Wed, 19 Feb 2014 22:26:43 +0900, Masahiro Yamada
> >>> <yamada.m at jp.panasonic.com> wrote:
> >>>
> >>>> In Kbuild, every makefile must have non-empty obj- or obj-y.
> >>>> Otherwise, built-in.o will not be created and the link stage
> >>>> will fail.
> >> ...
> >>>> diff --git a/arch/arm/cpu/armv7/tegra124/Makefile b/arch/arm/cpu/armv7/tegra124/Makefile
> >> ...
> >>>> +# necessary to create built-in.o
> >>>> +obj- := __dummy__.o
> >>
> >> obj- or obj-y?
> > 
> > Definitely obj-.
> 
> Really? Why would such a variable even exist or be used. Only obj-n or
> obj-y should exist; "" isn't a valid y/n value.

All defined CONFIG macros are included in
include/autoconf.mk  (and include/spl-autoconf.mk,
include/tpl-autoconf.mk  for SPL, TPL, respectively)

If CONFIG_FOO is defined in your  config header, 
CONFIG_FOO=y  will apear in include/autoconf.mk
Otherwise, it does not appear in include/autoconf.mk.

As a result,
obj-$(CONFIG_FOO) += foo.o
   becomes
obj-y += foo.o     (if CONFIG_FOO is defined)
    or 
obj- += foo.o       (if CONFIG_FOO is not defined)


Kbuild  checks  $(obj-) as well as  $(obj-y).

Let me explain shortly how Kbuild works.


For example,  assume we have a Makefile like this

obj-$(CONFIG_FOO) += foo.o
obj-$(CONFIG_BAR) += bar.o



[1] 
Let's say  CONFIG_FOO is set, but CONFIG_BAR isn't.

In this case, 
 $(obj-y)  is  "foo.o"
 $(obj-)  is   "bar.o"

Then Kbuild builds only "foo.o" and links it  into built-in.o

[2]
Next, let's say neither CONFIG_FOO nor CONFIG_BAR is set.

In this case, 
 $(obj-y)  is  empty.
  $(obj-)  is "foo.o  bar.o"

Kbuild creates empty built-in.o
if   $(obj-y) is empty but $(obj-) is not empty.

[3]
Last,  let's say Makefile does not have  obj-$(...) lines.

In this case,
  $(obj-y) is empty
  $(obj-) is empty too.

Kbuild does not create built-in.o  when both $(obj-y) and $(obj-)
are empty.
This is the case of tools/Makefile or example/standalone/Makefile.


Is this clearer now?


Best Regards
Masahiro Yamada



More information about the U-Boot mailing list