After digging into the whole build system for Busybox, I think I understand the logic behind it, so here is what I found out:
- There are shared makefiles in the scripts directory (e.g. makefile.build, kbuild.include…etc) that contains common rules, build configurations, and other things.
- These shared makefiles are the ones that build the Kbuild makefiles (e.g. the ones that usually hold code like
obj-$(CONFIG_FOO) += foo.o
) - How it works:
- The main makefile do a submake invocation to
Makefile.build
, and passes a path/dir for the folder to be built (i.e. generatebuilt-in.o
from) as a command line variable (obj
) - The
Makefile.build
file creates generic rules used to compile object goal files and to link them intobuilt-in.o
- Then the main makefile collects all
object-in.o
from the sub directories and link them together
- The main makefile do a submake invocation to