tools/build/Documentation/Build.txt

Source file repositories/reference/linux-study-clean/tools/build/Documentation/Build.txt

File Facts

System
Linux kernel
Corpus path
tools/build/Documentation/Build.txt
Extension
.txt
Size
4269 bytes
Lines
169
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

Build Framework
===============

The perf build framework was adopted from the kernel build system, hence the
idea and the way how objects are built is the same.

Basically the user provides set of 'Build' files that list objects and
directories to nest for specific target to be build.

Unlike the kernel we don't have a single build object 'obj-y' list that where
we setup source objects, but we support more. This allows one 'Build' file to
carry a sources list for multiple build objects.


Build framework makefiles
-------------------------

The build framework consists of 2 Makefiles:

  Build.include
  Makefile.build

While the 'Build.include' file contains just some generic definitions, the
'Makefile.build' file is the makefile used from the outside. It's
interface/usage is following:

  $ make -f tools/build/Makefile.build srctree=$(KSRC) dir=$(DIR) obj=$(OBJECT)

where:

  KSRC   - is the path to kernel sources
  DIR    - is the path to the project to be built
  OBJECT - is the name of the build object

When succefully finished the $(DIR) directory contains the final object file
called $(OBJECT)-in.o:

  $ ls $(DIR)/$(OBJECT)-in.o

which includes all compiled sources described in 'Build' makefiles.


Build makefiles
---------------

The user supplies 'Build' makefiles that contains a objects list, and connects
the build to nested directories.

Assume we have the following project structure:

  ex/a.c
    /b.c
    /c.c
    /d.c
    /arch/e.c
    /arch/f.c

Out of which you build the 'ex' binary ' and the 'libex.a' library:

  'ex'      - consists of 'a.o', 'b.o' and libex.a
  'libex.a' - consists of 'c.o', 'd.o', 'e.o' and 'f.o'

The build framework does not create the 'ex' and 'libex.a' binaries for you, it
only prepares proper objects to be compiled and grouped together.

To follow the above example, the user provides following 'Build' files:

  ex/Build:
    ex-y += a.o
    ex-y += b.o

Annotation

Implementation Notes