Domanda

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??

È stato utile?

Soluzione

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. generate built-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 into built-in.o
    • Then the main makefile collects all object-in.o from the sub directories and link them together
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top