4 The perf build framework was adopted from the kernel build system, hence the
5 idea and the way how objects are built is the same.
7 Basically the user provides set of 'Build' files that list objects and
8 directories to nest for specific target to be build.
10 Unlike the kernel we don't have a single build object 'obj-y' list that where
11 we setup source objects, but we support more. This allows one 'Build' file to
12 carry a sources list for multiple build objects.
14 a) Build framework makefiles
15 ----------------------------
17 The build framework consists of 2 Makefiles:
22 While the 'Build.include' file contains just some generic definitions, the
23 'Makefile.build' file is the makefile used from the outside. It's
24 interface/usage is following:
26 $ make -f tools/build/Makefile srctree=$(KSRC) dir=$(DIR) obj=$(OBJECT)
30 KSRC - is the path to kernel sources
31 DIR - is the path to the project to be built
32 OBJECT - is the name of the build object
34 When succefully finished the $(DIR) directory contains the final object file
35 called $(OBJECT)-in.o:
37 $ ls $(DIR)/$(OBJECT)-in.o
39 which includes all compiled sources described in 'Build' makefiles.
44 The user supplies 'Build' makefiles that contains a objects list, and connects
45 the build to nested directories.
47 Assume we have the following project structure:
56 Out of which you build the 'ex' binary ' and the 'libex.a' library:
58 'ex' - consists of 'a.o', 'b.o' and libex.a
59 'libex.a' - consists of 'c.o', 'd.o', 'e.o' and 'f.o'
61 The build framework does not create the 'ex' and 'libex.a' binaries for you, it
62 only prepares proper objects to be compiled and grouped together.
64 To follow the above example, the user provides following 'Build' files:
80 $ make -f tools/build/Makefile.build dir=. obj=ex
81 $ make -f tools/build/Makefile.build dir=. obj=libex
83 which creates the following objects:
88 that contain request objects names in Build files.
90 It's only a matter of 2 single commands to create the final binaries:
92 $ ar rcs libex.a libex-in.o
93 $ gcc -o ex ex-in.o libex.a
95 You can check the 'ex' example in 'tools/build/tests/ex' for more details.
100 The build framework provides standard compilation rules to handle .S and .c
103 It's possible to include special rule if needed (like we do for flex or bison
109 It's possible to alter the standard object C flags in the following way:
111 CFLAGS_perf.o += '...' - alters CFLAGS for perf.o object
112 CFLAGS_gtk += '...' - alters CFLAGS for gtk build object
114 This C flags changes has the scope of the Build makefile they are defined in.
120 For each built object file 'a.o' the '.a.cmd' is created and holds:
122 - Command line used to built that object
125 - Dependency rules generated by 'gcc -Wp,-MD,...'
126 (for compiled object)
128 All existing '.cmd' files are included in the Build process to follow properly
129 the dependencies and trigger a rebuild when necessary.
135 It's possible to build single object file by choice, like:
137 $ make util/map.o # objects
138 $ make util/map.i # preprocessor
139 $ make util/map.s # assembly