Skip to content

Commit 8c4d9b1

Browse files
committed
kbuild: doc: replace arch/$(ARCH)/ with arch/$(SRCARCH)/
Precisely speaking, the arch directory is specified by $(SRCARCH), not $(ARCH). In old days, $(ARCH) actually matched to the arch directory because 32-bit and 64-bit were supported as separate architectures. Most architectures (except arm/arm64) were unified like follows: arch/i386, arch/x86_64 -> arch/x86 arch/sh, arch/sh64 -> arch/sh arch/sparc, arch/sparc64 -> arch/sparc To not break the user interface, commit 6752ed9 ("Kbuild: allow arch/xxx to use a different source path") introduced SRCARCH to point to the arch directory, still allowing to pass in the former ARCH=i386 or ARCH=x86_64. Update the documents for preciseness, and add the explanation of SRCARCH. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Randy Dunlap <[email protected]>
1 parent b044a53 commit 8c4d9b1

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

Documentation/kbuild/makefiles.rst

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ This document describes the Linux kernel Makefiles.
6767

6868
The Makefiles have five parts::
6969

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
7575

7676
The top Makefile reads the .config file, which comes from the kernel
7777
configuration process.
@@ -82,7 +82,7 @@ It builds these goals by recursively descending into the subdirectories of
8282
the kernel source tree.
8383
The list of subdirectories which are visited depends upon the kernel
8484
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
8686
architecture-specific information to the top Makefile.
8787

8888
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,
933933
and clean as usual. The Makefile located in arch/x86/boot/ may use
934934
the subdir- trick to descend further down.
935935

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
937937
included in the top level makefile, and the kbuild infrastructure
938938
is not operational at that point.
939939

@@ -946,24 +946,24 @@ be visited during "make clean".
946946
The top level Makefile sets up the environment and does the preparation,
947947
before starting to descend down in the individual directories.
948948
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
950950
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
952952
a few targets.
953953

954954
When kbuild executes, the following steps are followed (roughly):
955955

956956
1) Configuration of the kernel => produce .config
957957
2) Store kernel version in include/linux/version.h
958958
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
960960
4) Recursively descend down in all directories listed in
961961
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.
963963
5) All object files are then linked and the resulting file vmlinux is
964964
located at the root of the obj tree.
965965
The very first objects linked are listed in head-y, assigned by
966-
arch/$(ARCH)/Makefile.
966+
arch/$(SRCARCH)/Makefile.
967967
6) Finally, the architecture-specific part does any required post processing
968968
and builds the final bootimage.
969969
- This includes building boot records
@@ -1169,7 +1169,7 @@ When kbuild executes, the following steps are followed (roughly):
11691169
$(core-y), $(libs-y), $(drivers-y) and $(net-y).
11701170

11711171
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
11731173
directories.
11741174

11751175
Example::
@@ -1189,15 +1189,15 @@ When kbuild executes, the following steps are followed (roughly):
11891189
The actual goals are not standardized across architectures.
11901190

11911191
It is common to locate any additional processing in a boot/
1192-
directory below arch/$(ARCH)/.
1192+
directory below arch/$(SRCARCH)/.
11931193

11941194
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
11961196
call make manually to build a target in boot/.
11971197

11981198
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.
12011201

12021202
Example::
12031203

@@ -1217,7 +1217,7 @@ When kbuild executes, the following steps are followed (roughly):
12171217

12181218
#arch/x86/Makefile
12191219
define archhelp
1220-
echo '* bzImage - Image (arch/$(ARCH)/boot/bzImage)'
1220+
echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)'
12211221
endif
12221222

12231223
When make is executed without arguments, the first goal encountered
@@ -1332,7 +1332,7 @@ When kbuild executes, the following steps are followed (roughly):
13321332

13331333
objcopy
13341334
Copy binary. Uses OBJCOPYFLAGS usually specified in
1335-
arch/$(ARCH)/Makefile.
1335+
arch/$(SRCARCH)/Makefile.
13361336
OBJCOPYFLAGS_$@ may be used to set additional options.
13371337

13381338
gzip
@@ -1395,7 +1395,7 @@ When kbuild executes, the following steps are followed (roughly):
13951395
--------------------------------
13961396

13971397
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.
13991399
The script is a preprocessed variant of the file vmlinux.lds.S
14001400
located in the same directory.
14011401
kbuild knows .lds files and includes a rule `*lds.S` -> `*lds`.
@@ -1405,9 +1405,6 @@ When kbuild executes, the following steps are followed (roughly):
14051405
#arch/x86/kernel/Makefile
14061406
extra-y := vmlinux.lds
14071407

1408-
#Makefile
1409-
export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
1410-
14111408
The assignment to extra-y is used to tell kbuild to build the
14121409
target vmlinux.lds.
14131410
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.
14811478

14821479
If an architecture uses a verbatim copy of a header from
14831480
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:
14851482

14861483
Example::
14871484

@@ -1492,7 +1489,7 @@ See subsequent chapter for the syntax of the Kbuild file.
14921489
During the prepare phase of the build a wrapper include
14931490
file is generated in the directory::
14941491

1495-
arch/$(ARCH)/include/generated/asm
1492+
arch/$(SRCARCH)/include/generated/asm
14961493

14971494
When a header is exported where the architecture uses
14981495
the generic header a similar wrapper is generated as part
@@ -1527,8 +1524,8 @@ See subsequent chapter for the syntax of the Kbuild file.
15271524
to define the minimum set of ASM headers that all architectures must have.
15281525

15291526
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.
15321529

15331530
9 Kbuild Variables
15341531
==================
@@ -1564,6 +1561,16 @@ The top Makefile exports the following variables:
15641561

15651562
make ARCH=m68k ...
15661563

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.
15671574

15681575
INSTALL_PATH
15691576
This variable defines a place for the arch Makefiles to install

Documentation/kbuild/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ according to the following rule:
332332
There are two notable exceptions to this rule: larger
333333
subsystems have their own directory under include/, such as
334334
include/scsi; and architecture specific headers are located
335-
under arch/$(ARCH)/include/.
335+
under arch/$(SRCARCH)/include/.
336336

337337
4.1 Kernel Includes
338338
-------------------

0 commit comments

Comments
 (0)