I am familiar with make and kbuild, and how the build system work. But I am having hard time understanding how the object goals are built!?
For example, in Kbuild, if you want to generate an object file in a directory you would have a makefile with something like:
obj-$(CONFIG_FOO) += foo.o
This evaluates to obj-y/m
and adds foo.o
to it, and I think that this build file is invoked using submake
, then the main makefile would generate all object goals using either obj-y
or obj-m
(depending how/what you are building),right?
My problem is that usually you can pass from the main makefile/build file to its submake (i.e. export
), but the obj-y
variable is defined in many places so how is its value being constructed or tracked among all these submake
invocations??
After digging into the whole build system for Busybox, I think I understand the logic behind it, so here is what I found out:
obj-$(CONFIG_FOO) += foo.o
)Makefile.build
, and passes a path/dir for the folder to be built (i.e. generate built-in.o
from) as a command line variable (obj
) Makefile.build
file creates generic rules used to compile object goal files and to link them into built-in.o
object-in.o
from the sub directories and link them together