@@ -67,11 +67,11 @@ This document describes the Linux kernel Makefiles.
67
67
68
68
The Makefiles have five parts::
69
69
70
- Makefile the top Makefile.
71
- .config the kernel configuration file.
72
- arch/$(ARCH )/Makefile the arch Makefile.
73
- scripts/Makefile.* common rules etc. for all kbuild Makefiles.
74
- kbuild Makefiles exist in every subdirectory
70
+ Makefile the top Makefile.
71
+ .config the kernel configuration file.
72
+ arch/$(SRCARCH )/Makefile the arch Makefile.
73
+ scripts/Makefile.* common rules etc. for all kbuild Makefiles.
74
+ kbuild Makefiles exist in every subdirectory
75
75
76
76
The top Makefile reads the .config file, which comes from the kernel
77
77
configuration process.
@@ -82,7 +82,7 @@ It builds these goals by recursively descending into the subdirectories of
82
82
the kernel source tree.
83
83
The list of subdirectories which are visited depends upon the kernel
84
84
configuration. The top Makefile textually includes an arch Makefile
85
- with the name arch/$(ARCH )/Makefile. The arch Makefile supplies
85
+ with the name arch/$(SRCARCH )/Makefile. The arch Makefile supplies
86
86
architecture-specific information to the top Makefile.
87
87
88
88
Each subdirectory has a kbuild Makefile which carries out the commands
@@ -933,7 +933,7 @@ When "make clean" is executed, make will descend down in arch/x86/boot,
933
933
and clean as usual. The Makefile located in arch/x86/boot/ may use
934
934
the subdir- trick to descend further down.
935
935
936
- Note 1: arch/$(ARCH )/Makefile cannot use "subdir-", because that file is
936
+ Note 1: arch/$(SRCARCH )/Makefile cannot use "subdir-", because that file is
937
937
included in the top level makefile, and the kbuild infrastructure
938
938
is not operational at that point.
939
939
@@ -946,24 +946,24 @@ be visited during "make clean".
946
946
The top level Makefile sets up the environment and does the preparation,
947
947
before starting to descend down in the individual directories.
948
948
The top level makefile contains the generic part, whereas
949
- arch/$(ARCH )/Makefile contains what is required to set up kbuild
949
+ arch/$(SRCARCH )/Makefile contains what is required to set up kbuild
950
950
for said architecture.
951
- To do so, arch/$(ARCH )/Makefile sets up a number of variables and defines
951
+ To do so, arch/$(SRCARCH )/Makefile sets up a number of variables and defines
952
952
a few targets.
953
953
954
954
When kbuild executes, the following steps are followed (roughly):
955
955
956
956
1) Configuration of the kernel => produce .config
957
957
2) Store kernel version in include/linux/version.h
958
958
3) Updating all other prerequisites to the target prepare:
959
- - Additional prerequisites are specified in arch/$(ARCH )/Makefile
959
+ - Additional prerequisites are specified in arch/$(SRCARCH )/Makefile
960
960
4) Recursively descend down in all directories listed in
961
961
init-* core* drivers-* net-* libs-* and build all targets.
962
- - The values of the above variables are expanded in arch/$(ARCH )/Makefile.
962
+ - The values of the above variables are expanded in arch/$(SRCARCH )/Makefile.
963
963
5) All object files are then linked and the resulting file vmlinux is
964
964
located at the root of the obj tree.
965
965
The very first objects linked are listed in head-y, assigned by
966
- arch/$(ARCH )/Makefile.
966
+ arch/$(SRCARCH )/Makefile.
967
967
6) Finally, the architecture-specific part does any required post processing
968
968
and builds the final bootimage.
969
969
- This includes building boot records
@@ -1169,7 +1169,7 @@ When kbuild executes, the following steps are followed (roughly):
1169
1169
$(core-y), $(libs-y), $(drivers-y) and $(net-y).
1170
1170
1171
1171
The top level Makefile defines values for all generic directories,
1172
- and arch/$(ARCH )/Makefile only adds architecture-specific
1172
+ and arch/$(SRCARCH )/Makefile only adds architecture-specific
1173
1173
directories.
1174
1174
1175
1175
Example::
@@ -1189,15 +1189,15 @@ When kbuild executes, the following steps are followed (roughly):
1189
1189
The actual goals are not standardized across architectures.
1190
1190
1191
1191
It is common to locate any additional processing in a boot/
1192
- directory below arch/$(ARCH )/.
1192
+ directory below arch/$(SRCARCH )/.
1193
1193
1194
1194
Kbuild does not provide any smart way to support building a
1195
- target specified in boot/. Therefore arch/$(ARCH )/Makefile shall
1195
+ target specified in boot/. Therefore arch/$(SRCARCH )/Makefile shall
1196
1196
call make manually to build a target in boot/.
1197
1197
1198
1198
The recommended approach is to include shortcuts in
1199
- arch/$(ARCH )/Makefile, and use the full path when calling down
1200
- into the arch/$(ARCH )/boot/Makefile.
1199
+ arch/$(SRCARCH )/Makefile, and use the full path when calling down
1200
+ into the arch/$(SRCARCH )/boot/Makefile.
1201
1201
1202
1202
Example::
1203
1203
@@ -1217,7 +1217,7 @@ When kbuild executes, the following steps are followed (roughly):
1217
1217
1218
1218
#arch/x86/Makefile
1219
1219
define archhelp
1220
- echo '* bzImage - Image (arch/$(ARCH) /boot/bzImage)'
1220
+ echo '* bzImage - Compressed kernel image (arch/x86 /boot/bzImage)'
1221
1221
endif
1222
1222
1223
1223
When make is executed without arguments, the first goal encountered
@@ -1332,7 +1332,7 @@ When kbuild executes, the following steps are followed (roughly):
1332
1332
1333
1333
objcopy
1334
1334
Copy binary. Uses OBJCOPYFLAGS usually specified in
1335
- arch/$(ARCH )/Makefile.
1335
+ arch/$(SRCARCH )/Makefile.
1336
1336
OBJCOPYFLAGS_$@ may be used to set additional options.
1337
1337
1338
1338
gzip
@@ -1395,7 +1395,7 @@ When kbuild executes, the following steps are followed (roughly):
1395
1395
--------------------------------
1396
1396
1397
1397
When the vmlinux image is built, the linker script
1398
- arch/$(ARCH )/kernel/vmlinux.lds is used.
1398
+ arch/$(SRCARCH )/kernel/vmlinux.lds is used.
1399
1399
The script is a preprocessed variant of the file vmlinux.lds.S
1400
1400
located in the same directory.
1401
1401
kbuild knows .lds files and includes a rule `*lds.S ` -> `*lds `.
@@ -1405,9 +1405,6 @@ When kbuild executes, the following steps are followed (roughly):
1405
1405
#arch/x86/kernel/Makefile
1406
1406
extra-y := vmlinux.lds
1407
1407
1408
- #Makefile
1409
- export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
1410
-
1411
1408
The assignment to extra-y is used to tell kbuild to build the
1412
1409
target vmlinux.lds.
1413
1410
The assignment to $(CPPFLAGS_vmlinux.lds) tells kbuild to use the
@@ -1481,7 +1478,7 @@ See subsequent chapter for the syntax of the Kbuild file.
1481
1478
1482
1479
If an architecture uses a verbatim copy of a header from
1483
1480
include/asm-generic then this is listed in the file
1484
- arch/$(ARCH )/include/asm/Kbuild like this:
1481
+ arch/$(SRCARCH )/include/asm/Kbuild like this:
1485
1482
1486
1483
Example::
1487
1484
@@ -1492,7 +1489,7 @@ See subsequent chapter for the syntax of the Kbuild file.
1492
1489
During the prepare phase of the build a wrapper include
1493
1490
file is generated in the directory::
1494
1491
1495
- arch/$(ARCH )/include/generated/asm
1492
+ arch/$(SRCARCH )/include/generated/asm
1496
1493
1497
1494
When a header is exported where the architecture uses
1498
1495
the generic header a similar wrapper is generated as part
@@ -1527,8 +1524,8 @@ See subsequent chapter for the syntax of the Kbuild file.
1527
1524
to define the minimum set of ASM headers that all architectures must have.
1528
1525
1529
1526
This works like optional generic-y. If a mandatory header is missing
1530
- in arch/$(ARCH )/include/(uapi/)/asm, Kbuild will automatically generate
1531
- a wrapper of the asm-generic one.
1527
+ in arch/$(SRCARCH )/include/(uapi/)/asm, Kbuild will automatically
1528
+ generate a wrapper of the asm-generic one.
1532
1529
1533
1530
9 Kbuild Variables
1534
1531
==================
@@ -1564,6 +1561,16 @@ The top Makefile exports the following variables:
1564
1561
1565
1562
make ARCH=m68k ...
1566
1563
1564
+ SRCARCH
1565
+ This variable specifies the directory in arch/ to build.
1566
+
1567
+ ARCH and SRCARCH may not necessarily match. A couple of arch
1568
+ directories are biarch, that is, a single `arch/*/ ` directory supports
1569
+ both 32-bit and 64-bit.
1570
+
1571
+ For example, you can pass in ARCH=i386, ARCH=x86_64, or ARCH=x86.
1572
+ For all of them, SRCARCH=x86 because arch/x86/ supports both i386 and
1573
+ x86_64.
1567
1574
1568
1575
INSTALL_PATH
1569
1576
This variable defines a place for the arch Makefiles to install
0 commit comments