sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget$/translations/zh_CN/kbuild/makefilesmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/zh_TW/kbuild/makefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/it_IT/kbuild/makefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ja_JP/kbuild/makefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/ko_KR/kbuild/makefilesmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget$/translations/sp_SP/kbuild/makefilesmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hLinux Kernel Makefilesh]hLinux Kernel Makefiles}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhh>/var/lib/git/docbuild/linux/Documentation/kbuild/makefiles.rsthKubh paragraph)}(h3This document describes the Linux kernel Makefiles.h]h3This document describes the Linux kernel Makefiles.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(hOverviewh]hOverview}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh)}(hThe Makefiles have five parts::h]hThe Makefiles have five parts:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh literal_block)}(hXMakefile the top Makefile. .config the kernel configuration file. arch/$(SRCARCH)/Makefile the arch Makefile. scripts/Makefile.* common rules etc. for all kbuild Makefiles. kbuild Makefiles exist in every subdirectoryh]hXMakefile the top Makefile. .config the kernel configuration file. arch/$(SRCARCH)/Makefile the arch Makefile. scripts/Makefile.* common rules etc. for all kbuild Makefiles. kbuild Makefiles exist in every subdirectory}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhK hhhhubh)}(h[The top Makefile reads the .config file, which comes from the kernel configuration process.h]h[The top Makefile reads the .config file, which comes from the kernel configuration process.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hThe top Makefile is responsible for building two major products: vmlinux (the resident kernel image) and modules (any module files). It builds these goals by recursively descending into the subdirectories of the kernel source tree.h]hThe top Makefile is responsible for building two major products: vmlinux (the resident kernel image) and modules (any module files). It builds these goals by recursively descending into the subdirectories of the kernel source tree.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hXThe list of subdirectories which are visited depends upon the kernel configuration. The top Makefile textually includes an arch Makefile with the name arch/$(SRCARCH)/Makefile. The arch Makefile supplies architecture-specific information to the top Makefile.h]hXThe list of subdirectories which are visited depends upon the kernel configuration. The top Makefile textually includes an arch Makefile with the name arch/$(SRCARCH)/Makefile. The arch Makefile supplies architecture-specific information to the top Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hEach subdirectory has a kbuild Makefile which carries out the commands passed down from above. The kbuild Makefile uses information from the .config file to construct various file lists used by kbuild to build any built-in or modular targets.h]hEach subdirectory has a kbuild Makefile which carries out the commands passed down from above. The kbuild Makefile uses information from the .config file to construct various file lists used by kbuild to build any built-in or modular targets.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h{scripts/Makefile.* contains all the definitions/rules etc. that are used to build the kernel based on the kbuild makefiles.h]h{scripts/Makefile.* contains all the definitions/rules etc. that are used to build the kernel based on the kbuild makefiles.}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK$hhhhubeh}(h]overviewah ]h"]overviewah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Who does whath]h Who does what}(hjIhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjFhhhhhK(ubh)}(hCPeople have four different relationships with the kernel Makefiles.h]hCPeople have four different relationships with the kernel Makefiles.}(hjWhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK*hjFhhubh)}(h*Users* are people who build kernels. These people type commands such as ``make menuconfig`` or ``make``. They usually do not read or edit any kernel Makefiles (or any other source files).h](hemphasis)}(h*Users*h]hUsers}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1jihjeubhC are people who build kernels. These people type commands such as }(hjehhhNhNubhliteral)}(h``make menuconfig``h]hmake menuconfig}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjeubh or }(hjehhhNhNubj~)}(h``make``h]hmake}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjeubhU. They usually do not read or edit any kernel Makefiles (or any other source files).}(hjehhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK,hjFhhubh)}(hXi*Normal developers* are people who work on features such as device drivers, file systems, and network protocols. These people need to maintain the kbuild Makefiles for the subsystem they are working on. In order to do this effectively, they need some overall knowledge about the kernel Makefiles, plus detailed knowledge about the public interface for kbuild.h](jj)}(h*Normal developers*h]hNormal developers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jihjubhXV are people who work on features such as device drivers, file systems, and network protocols. These people need to maintain the kbuild Makefiles for the subsystem they are working on. In order to do this effectively, they need some overall knowledge about the kernel Makefiles, plus detailed knowledge about the public interface for kbuild.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK0hjFhhubh)}(h*Arch developers* are people who work on an entire architecture, such as sparc or x86. Arch developers need to know about the arch Makefile as well as kbuild Makefiles.h](jj)}(h*Arch developers*h]hArch developers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jihjubh are people who work on an entire architecture, such as sparc or x86. Arch developers need to know about the arch Makefile as well as kbuild Makefiles.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK7hjFhhubh)}(h*Kbuild developers* are people who work on the kernel build system itself. These people need to know about all aspects of the kernel Makefiles.h](jj)}(h*Kbuild developers*h]hKbuild developers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jihjubh| are people who work on the kernel build system itself. These people need to know about all aspects of the kernel Makefiles.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK;hjFhhubh)}(hEThis document is aimed towards normal developers and arch developers.h]hEThis document is aimed towards normal developers and arch developers.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjFhhubeh}(h] who-does-whatah ]h"] who does whatah$]h&]uh1hhhhhhhhK(ubh)}(hhh](h)}(hThe kbuild filesh]hThe kbuild files}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKBubh)}(hMost Makefiles within the kernel are kbuild Makefiles that use the kbuild infrastructure. This chapter introduces the syntax used in the kbuild makefiles.h]hMost Makefiles within the kernel are kbuild Makefiles that use the kbuild infrastructure. This chapter introduces the syntax used in the kbuild makefiles.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKDhjhhubh)}(hThe preferred name for the kbuild files are ``Makefile`` but ``Kbuild`` can be used and if both a ``Makefile`` and a ``Kbuild`` file exists, then the ``Kbuild`` file will be used.h](h,The preferred name for the kbuild files are }(hj2hhhNhNubj~)}(h ``Makefile``h]hMakefile}(hj:hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj2ubh but }(hj2hhhNhNubj~)}(h ``Kbuild``h]hKbuild}(hjLhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj2ubh can be used and if both a }(hj2hhhNhNubj~)}(h ``Makefile``h]hMakefile}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj2ubh and a }(hj2hhhNhNubj~)}(h ``Kbuild``h]hKbuild}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj2ubh file exists, then the }(hj2hhhNhNubj~)}(h ``Kbuild``h]hKbuild}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj2ubh file will be used.}(hj2hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKHhjhhubh)}(hhSection `Goal definitions`_ is a quick intro; further chapters provide more details, with real examples.h](hSection }(hjhhhNhNubh reference)}(h`Goal definitions`_h]hGoal definitions}(hjhhhNhNubah}(h]h ]h"]h$]h&]nameGoal definitionsrefidgoal-definitionsuh1jhjresolvedKubhM is a quick intro; further chapters provide more details, with real examples.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKLhjhhubh)}(hhh](h)}(hGoal definitionsh]hGoal definitions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKPubh)}(hGoal definitions are the main part (heart) of the kbuild Makefile. These lines define the files to be built, any special compilation options, and any subdirectories to be entered recursively.h]hGoal definitions are the main part (heart) of the kbuild Makefile. These lines define the files to be built, any special compilation options, and any subdirectories to be entered recursively.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKRhjhhubh)}(h2The most simple kbuild makefile contains one line:h]h2The most simple kbuild makefile contains one line:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjhhubh)}(hobj-y += foo.oh]hobj-y += foo.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKZhjhhubh)}(hsThis tells kbuild that there is one object in that directory, named foo.o. foo.o will be built from foo.c or foo.S.h]hsThis tells kbuild that there is one object in that directory, named foo.o. foo.o will be built from foo.c or foo.S.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjhhubh)}(hoIf foo.o shall be built as a module, the variable obj-m is used. Therefore the following pattern is often used:h]hoIf foo.o shall be built as a module, the variable obj-m is used. Therefore the following pattern is often used:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjhhubh)}(h Example::h]hExample:}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjhhubh)}(hobj-$(CONFIG_FOO) += foo.oh]hobj-$(CONFIG_FOO) += foo.o}hj4sbah}(h]h ]h"]h$]h&]hhuh1hhhhKdhjhhubh)}(h$(CONFIG_FOO) evaluates to either y (for built-in) or m (for module). If CONFIG_FOO is neither y nor m, then the file will not be compiled nor linked.h]h$(CONFIG_FOO) evaluates to either y (for built-in) or m (for module). If CONFIG_FOO is neither y nor m, then the file will not be compiled nor linked.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjhhubeh}(h]jah ]h"]goal definitionsah$]h&]uh1hhjhhhhhKP referencedKubh)}(hhh](h)}(hBuilt-in object goals - obj-yh]hBuilt-in object goals - obj-y}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjXhhhhhKkubh)}(h~The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration.h]h~The kbuild Makefile specifies object files for vmlinux in the $(obj-y) lists. These lists depend on the kernel configuration.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKmhjXhhubh)}(hKbuild compiles all the $(obj-y) files. It then calls ``$(AR) rcSTP`` to merge these files into one built-in.a file. This is a thin archive without a symbol table. It will be later linked into vmlinux by scripts/link-vmlinux.shh](h7Kbuild compiles all the $(obj-y) files. It then calls }(hjwhhhNhNubj~)}(h``$(AR) rcSTP``h]h $(AR) rcSTP}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjwubh to merge these files into one built-in.a file. This is a thin archive without a symbol table. It will be later linked into vmlinux by scripts/link-vmlinux.sh}(hjwhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKqhjXhhubh)}(hThe order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into built-in.a and succeeding instances will be ignored.h]hThe order of files in $(obj-y) is significant. Duplicates in the lists are allowed: the first instance will be linked into built-in.a and succeeding instances will be ignored.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKvhjXhhubh)}(hXLink order is significant, because certain functions (module_init() / __initcall) will be called during boot in the order they appear. So keep in mind that changing the link order may e.g. change the order in which your SCSI controllers are detected, and thus your disks are renumbered.h]hXLink order is significant, because certain functions (module_init() / __initcall) will be called during boot in the order they appear. So keep in mind that changing the link order may e.g. change the order in which your SCSI controllers are detected, and thus your disks are renumbered.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKzhjXhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjXhhubh)}(h#drivers/isdn/i4l/Makefile # Makefile for the kernel ISDN subsystem and device drivers. # Each configuration option enables a list of files. obj-$(CONFIG_ISDN_I4L) += isdn.o obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.oh]h#drivers/isdn/i4l/Makefile # Makefile for the kernel ISDN subsystem and device drivers. # Each configuration option enables a list of files. obj-$(CONFIG_ISDN_I4L) += isdn.o obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjXhhubeh}(h]built-in-object-goals-obj-yah ]h"]built-in object goals - obj-yah$]h&]uh1hhjhhhhhKkubh)}(hhh](h)}(hLoadable module goals - obj-mh]hLoadable module goals - obj-m}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hK$(obj-m) specifies object files which are built as loadable kernel modules.h]hK$(obj-m) specifies object files which are built as loadable kernel modules.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hA module may be built from one source file or several source files. In the case of one source file, the kbuild makefile simply adds the file to $(obj-m).h]hA module may be built from one source file or several source files. In the case of one source file, the kbuild makefile simply adds the file to $(obj-m).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hK#drivers/isdn/i4l/Makefile obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.oh]hK#drivers/isdn/i4l/Makefile obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hANote: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to "m"h]hENote: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to “m”}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXIf a kernel module is built from several source files, you specify that you want to build a module in the same way as above; however, kbuild needs to know which object files you want to build your module from, so you have to tell it by setting a $(-y) variable.h]hXIf a kernel module is built from several source files, you specify that you want to build a module in the same way as above; however, kbuild needs to know which object files you want to build your module from, so you have to tell it by setting a $(-y) variable.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hn#drivers/isdn/i4l/Makefile obj-$(CONFIG_ISDN_I4L) += isdn.o isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.oh]hn#drivers/isdn/i4l/Makefile obj-$(CONFIG_ISDN_I4L) += isdn.o isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o}hjJsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hIn this example, the module name will be isdn.o. Kbuild will compile the objects listed in $(isdn-y) and then run ``$(LD) -r`` on the list of these files to generate isdn.o.h](hrIn this example, the module name will be isdn.o. Kbuild will compile the objects listed in $(isdn-y) and then run }(hjXhhhNhNubj~)}(h ``$(LD) -r``h]h$(LD) -r}(hj`hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjXubh/ on the list of these files to generate isdn.o.}(hjXhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hDue to kbuild recognizing $(-y) for composite objects, you can use the value of a ``CONFIG_`` symbol to optionally include an object file as part of a composite object.h](h_Due to kbuild recognizing $(-y) for composite objects, you can use the value of a }(hjxhhhNhNubj~)}(h ``CONFIG_``h]hCONFIG_}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjxubhK symbol to optionally include an object file as part of a composite object.}(hjxhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h#fs/ext2/Makefile obj-$(CONFIG_EXT2_FS) += ext2.o ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \ namei.o super.o symlink.o ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \ xattr_trusted.oh]h#fs/ext2/Makefile obj-$(CONFIG_EXT2_FS) += ext2.o ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \ namei.o super.o symlink.o ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \ xattr_trusted.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hIn this example, xattr.o, xattr_user.o and xattr_trusted.o are only part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to "y".h]hIn this example, xattr.o, xattr_user.o and xattr_trusted.o are only part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to “y”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXNote: Of course, when you are building objects into the kernel, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, kbuild will build an ext2.o file for you out of the individual parts and then link this into built-in.a, as you would expect.h]hXNote: Of course, when you are building objects into the kernel, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, kbuild will build an ext2.o file for you out of the individual parts and then link this into built-in.a, as you would expect.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]loadable-module-goals-obj-mah ]h"]loadable module goals - obj-mah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hLibrary file goals - lib-yh]hLibrary file goals - lib-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXObjects listed with obj-* are used for modules, or combined in a built-in.a for that specific directory. There is also the possibility to list objects that will be included in a library, lib.a. All objects listed with lib-y are combined in a single library for that directory. Objects that are listed in obj-y and additionally listed in lib-y will not be included in the library, since they will be accessible anyway. For consistency, objects listed in lib-m will be included in lib.a.h]hXObjects listed with obj-* are used for modules, or combined in a built-in.a for that specific directory. There is also the possibility to list objects that will be included in a library, lib.a. All objects listed with lib-y are combined in a single library for that directory. Objects that are listed in obj-y and additionally listed in lib-y will not be included in the library, since they will be accessible anyway. For consistency, objects listed in lib-m will be included in lib.a.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hNote that the same kbuild makefile may list files to be built-in and to be part of a library. Therefore the same directory may contain both a built-in.a and a lib.a file.h]hNote that the same kbuild makefile may list files to be built-in and to be part of a library. Therefore the same directory may contain both a built-in.a and a lib.a file.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h*#arch/x86/lib/Makefile lib-y := delay.oh]h*#arch/x86/lib/Makefile lib-y := delay.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hThis will create a library lib.a based on delay.o. For kbuild to actually recognize that there is a lib.a being built, the directory shall be listed in libs-y.h]hThis will create a library lib.a based on delay.o. For kbuild to actually recognize that there is a lib.a being built, the directory shall be listed in libs-y.}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h6See also `List directories to visit when descending`_.h](h See also }(hj/hhhNhNubj)}(h,`List directories to visit when descending`_h]h)List directories to visit when descending}(hj7hhhNhNubah}(h]h ]h"]h$]h&]name)List directories to visit when descendingj)list-directories-to-visit-when-descendinguh1jhj/jKubh.}(hj/hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hCUse of lib-y is normally restricted to ``lib/`` and ``arch/*/lib``.h](h'Use of lib-y is normally restricted to }(hjRhhhNhNubj~)}(h``lib/``h]hlib/}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjRubh and }(hjRhhhNhNubj~)}(h``arch/*/lib``h]h arch/*/lib}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjRubh.}(hjRhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]library-file-goals-lib-yah ]h"]library file goals - lib-yah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(hDescending down in directoriesh]hDescending down in directories}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hX A Makefile is only responsible for building objects in its own directory. Files in subdirectories should be taken care of by Makefiles in these subdirs. The build system will automatically invoke make recursively in subdirectories, provided you let it know of them.h]hX A Makefile is only responsible for building objects in its own directory. Files in subdirectories should be taken care of by Makefiles in these subdirs. The build system will automatically invoke make recursively in subdirectories, provided you let it know of them.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hTo do so, obj-y and obj-m are used. ext2 lives in a separate directory, and the Makefile present in fs/ tells kbuild to descend down using the following assignment.h]hTo do so, obj-y and obj-m are used. ext2 lives in a separate directory, and the Makefile present in fs/ tells kbuild to descend down using the following assignment.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(h+#fs/Makefile obj-$(CONFIG_EXT2_FS) += ext2/h]h+#fs/Makefile obj-$(CONFIG_EXT2_FS) += ext2/}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhjhhubh)}(hIf CONFIG_EXT2_FS is set to either "y" (built-in) or "m" (modular) the corresponding obj- variable will be set, and kbuild will descend down in the ext2 directory.h]hIf CONFIG_EXT2_FS is set to either “y” (built-in) or “m” (modular) the corresponding obj- variable will be set, and kbuild will descend down in the ext2 directory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hKbuild uses this information not only to decide that it needs to visit the directory, but also to decide whether or not to link objects from the directory into vmlinux.h]hKbuild uses this information not only to decide that it needs to visit the directory, but also to decide whether or not to link objects from the directory into vmlinux.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hWhen Kbuild descends into the directory with "y", all built-in objects from that directory are combined into the built-in.a, which will be eventually linked into vmlinux.h]hWhen Kbuild descends into the directory with “y”, all built-in objects from that directory are combined into the built-in.a, which will be eventually linked into vmlinux.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hXWhen Kbuild descends into the directory with "m", in contrast, nothing from that directory will be linked into vmlinux. If the Makefile in that directory specifies obj-y, those objects will be left orphan. It is very likely a bug of the Makefile or of dependencies in Kconfig.h]hXWhen Kbuild descends into the directory with “m”, in contrast, nothing from that directory will be linked into vmlinux. If the Makefile in that directory specifies obj-y, those objects will be left orphan. It is very likely a bug of the Makefile or of dependencies in Kconfig.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hKbuild also supports dedicated syntax, subdir-y and subdir-m, for descending into subdirectories. It is a good fit when you know they do not contain kernel-space objects at all. A typical usage is to let Kbuild descend into subdirectories to build tools.h]hKbuild also supports dedicated syntax, subdir-y and subdir-m, for descending into subdirectories. It is a good fit when you know they do not contain kernel-space objects at all. A typical usage is to let Kbuild descend into subdirectories to build tools.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Examples::h]h Examples:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h# scripts/Makefile subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_SECURITY_SELINUX) += selinuxh]h# scripts/Makefile subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_SECURITY_SELINUX) += selinux}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubh)}(hmUnlike obj-y/m, subdir-y/m does not need the trailing slash since this syntax is always used for directories.h]hmUnlike obj-y/m, subdir-y/m does not need the trailing slash since this syntax is always used for directories.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjhhubh)}(hIt is good practice to use a ``CONFIG_`` variable when assigning directory names. This allows kbuild to totally skip the directory if the corresponding ``CONFIG_`` option is neither "y" nor "m".h](hIt is good practice to use a }(hjEhhhNhNubj~)}(h ``CONFIG_``h]hCONFIG_}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjEubhp variable when assigning directory names. This allows kbuild to totally skip the directory if the corresponding }(hjEhhhNhNubj~)}(h ``CONFIG_``h]hCONFIG_}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjEubh' option is neither “y” nor “m”.}(hjEhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]descending-down-in-directoriesah ]h"]descending down in directoriesah$]h&]uh1hhjhhhhhKubh)}(hhh](h)}(h%Non-builtin vmlinux targets - extra-yh]h%Non-builtin vmlinux targets - extra-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hbextra-y specifies targets which are needed for building vmlinux, but not combined into built-in.a.h]hbextra-y specifies targets which are needed for building vmlinux, but not combined into built-in.a.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Examples are:h]h Examples are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubhenumerated_list)}(hhh]h list_item)}(hfvmlinux linker script The linker script for vmlinux is located at arch/$(SRCARCH)/kernel/vmlinux.lds h](h)}(hvmlinux linker scripth]hvmlinux linker script}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hNThe linker script for vmlinux is located at arch/$(SRCARCH)/kernel/vmlinux.ldsh]hNThe linker script for vmlinux is located at arch/$(SRCARCH)/kernel/vmlinux.lds}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubah}(h]h ]h"]h$]h&]enumtypearabicprefixhsuffix)uh1jhjhhhhhMubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM!hjhhubh)}(h7# arch/x86/kernel/Makefile extra-y += vmlinux.ldsh]h7# arch/x86/kernel/Makefile extra-y += vmlinux.lds}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhM#hjhhubh)}(h:$(extra-y) should only contain targets needed for vmlinux.h]h:$(extra-y) should only contain targets needed for vmlinux.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM&hjhhubh)}(hwKbuild skips extra-y when vmlinux is apparently not a final goal. (e.g. ``make modules``, or building external modules)h](hHKbuild skips extra-y when vmlinux is apparently not a final goal. (e.g. }(hjhhhNhNubj~)}(h``make modules``h]h make modules}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh, or building external modules)}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM(hjhhubh)}(hvIf you intend to build targets unconditionally, always-y (explained in the next section) is the correct syntax to use.h]hvIf you intend to build targets unconditionally, always-y (explained in the next section) is the correct syntax to use.}(hj.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM+hjhhubeh}(h]#non-builtin-vmlinux-targets-extra-yah ]h"]%non-builtin vmlinux targets - extra-yah$]h&]uh1hhjhhhhhMjWKubh)}(hhh](h)}(hAlways built goals - always-yh]hAlways built goals - always-y}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjDhhhhhM/ubh)}(h\always-y specifies targets which are literally always built when Kbuild visits the Makefile.h]h\always-y specifies targets which are literally always built when Kbuild visits the Makefile.}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM1hjDhhubh)}(h Example::h]hExample:}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM4hjDhhubh)}(hV# ./Kbuild offsets-file := include/generated/asm-offsets.h always-y += $(offsets-file)h]hV# ./Kbuild offsets-file := include/generated/asm-offsets.h always-y += $(offsets-file)}hjqsbah}(h]h ]h"]h$]h&]hhuh1hhhhM6hjDhhubeh}(h]always-built-goals-always-yah ]h"]always built goals - always-yah$]h&]uh1hhjhhhhhM/ubh)}(hhh](h)}(hCompilation flagsh]hCompilation flags}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM;ubhdefinition_list)}(hhh](hdefinition_list_item)}(hXJccflags-y, asflags-y and ldflags-y These three flags apply only to the kbuild makefile in which they are assigned. They are used for all the normal cc, as and ld invocations happening during a recursive build. ccflags-y specifies options for compiling with $(CC). Example:: # drivers/acpi/acpica/Makefile ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT This variable is necessary because the top Makefile owns the variable $(KBUILD_CFLAGS) and uses it for compilation flags for the entire tree. asflags-y specifies assembler options. Example:: #arch/sparc/kernel/Makefile asflags-y := -ansi ldflags-y specifies options for linking with $(LD). Example:: #arch/cris/boot/compressed/Makefile ldflags-y += -T $(src)/decompress_$(arch-y).lds h](hterm)}(h"ccflags-y, asflags-y and ldflags-yh]h"ccflags-y, asflags-y and ldflags-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMZhjubh definition)}(hhh](h)}(hThese three flags apply only to the kbuild makefile in which they are assigned. They are used for all the normal cc, as and ld invocations happening during a recursive build.h]hThese three flags apply only to the kbuild makefile in which they are assigned. They are used for all the normal cc, as and ld invocations happening during a recursive build.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM>hjubh)}(h5ccflags-y specifies options for compiling with $(CC).h]h5ccflags-y specifies options for compiling with $(CC).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhjubh)}(h# drivers/acpi/acpica/Makefile ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUTh]h# drivers/acpi/acpica/Makefile ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMFhjubh)}(hThis variable is necessary because the top Makefile owns the variable $(KBUILD_CFLAGS) and uses it for compilation flags for the entire tree.h]hThis variable is necessary because the top Makefile owns the variable $(KBUILD_CFLAGS) and uses it for compilation flags for the entire tree.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhjubh)}(h&asflags-y specifies assembler options.h]h&asflags-y specifies assembler options.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMNhjubh)}(h Example::h]hExample:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhjubh)}(h.#arch/sparc/kernel/Makefile asflags-y := -ansih]h.#arch/sparc/kernel/Makefile asflags-y := -ansi}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMRhjubh)}(h3ldflags-y specifies options for linking with $(LD).h]h3ldflags-y specifies options for linking with $(LD).}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMUhjubh)}(h Example::h]hExample:}(hj6hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMWhjubh)}(hS#arch/cris/boot/compressed/Makefile ldflags-y += -T $(src)/decompress_$(arch-y).ldsh]hS#arch/cris/boot/compressed/Makefile ldflags-y += -T $(src)/decompress_$(arch-y).lds}hjDsbah}(h]h ]h"]h$]h&]hhuh1hhhhMYhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMZhjubj)}(hXsubdir-ccflags-y, subdir-asflags-y The two flags listed above are similar to ccflags-y and asflags-y. The difference is that the subdir- variants have effect for the kbuild file where they are present and all subdirectories. Options specified using subdir-* are added to the commandline before the options specified using the non-subdir variants. Example:: subdir-ccflags-y := -Werror h](j)}(h"subdir-ccflags-y, subdir-asflags-yh]h"subdir-ccflags-y, subdir-asflags-y}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMehj^ubj)}(hhh](h)}(hX7The two flags listed above are similar to ccflags-y and asflags-y. The difference is that the subdir- variants have effect for the kbuild file where they are present and all subdirectories. Options specified using subdir-* are added to the commandline before the options specified using the non-subdir variants.h]hX7The two flags listed above are similar to ccflags-y and asflags-y. The difference is that the subdir- variants have effect for the kbuild file where they are present and all subdirectories. Options specified using subdir-* are added to the commandline before the options specified using the non-subdir variants.}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM]hjpubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchjpubh)}(hsubdir-ccflags-y := -Werrorh]hsubdir-ccflags-y := -Werror}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMehjpubeh}(h]h ]h"]h$]h&]uh1jhj^ubeh}(h]h ]h"]h$]h&]uh1jhhhMehjhhubj)}(hccflags-remove-y, asflags-remove-y These flags are used to remove particular flags for the compiler, assembler invocations. Example:: ccflags-remove-$(CONFIG_MCOUNT) += -pg h](j)}(h"ccflags-remove-y, asflags-remove-yh]h"ccflags-remove-y, asflags-remove-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMmhjubj)}(hhh](h)}(hXThese flags are used to remove particular flags for the compiler, assembler invocations.h]hXThese flags are used to remove particular flags for the compiler, assembler invocations.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMkhjubh)}(h&ccflags-remove-$(CONFIG_MCOUNT) += -pgh]h&ccflags-remove-$(CONFIG_MCOUNT) += -pg}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMmhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMmhjhhubj)}(hXuCFLAGS_$@, AFLAGS_$@ CFLAGS_$@ and AFLAGS_$@ only apply to commands in current kbuild makefile. $(CFLAGS_$@) specifies per-file options for $(CC). The $@ part has a literal value which specifies the file that it is for. CFLAGS_$@ has the higher priority than ccflags-remove-y; CFLAGS_$@ can re-add compiler flags that were removed by ccflags-remove-y. Example:: # drivers/scsi/Makefile CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF This line specify compilation flags for aha152x.o. $(AFLAGS_$@) is a similar feature for source files in assembly languages. AFLAGS_$@ has the higher priority than asflags-remove-y; AFLAGS_$@ can re-add assembler flags that were removed by asflags-remove-y. Example:: # arch/arm/kernel/Makefile AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt h](j)}(hCFLAGS_$@, AFLAGS_$@h]hCFLAGS_$@, AFLAGS_$@}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(hJCFLAGS_$@ and AFLAGS_$@ only apply to commands in current kbuild makefile.h]hJCFLAGS_$@ and AFLAGS_$@ only apply to commands in current kbuild makefile.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMphj ubh)}(h|$(CFLAGS_$@) specifies per-file options for $(CC). The $@ part has a literal value which specifies the file that it is for.h]h|$(CFLAGS_$@) specifies per-file options for $(CC). The $@ part has a literal value which specifies the file that it is for.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMshj ubh)}(hCFLAGS_$@ has the higher priority than ccflags-remove-y; CFLAGS_$@ can re-add compiler flags that were removed by ccflags-remove-y.h]hCFLAGS_$@ has the higher priority than ccflags-remove-y; CFLAGS_$@ can re-add compiler flags that were removed by ccflags-remove-y.}(hj% hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhj ubh)}(h Example::h]hExample:}(hj3 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMyhj ubh)}(hF# drivers/scsi/Makefile CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONFh]hF# drivers/scsi/Makefile CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF}hjA sbah}(h]h ]h"]h$]h&]hhuh1hhhhM{hj ubh)}(h2This line specify compilation flags for aha152x.o.h]h2This line specify compilation flags for aha152x.o.}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hj ubh)}(hI$(AFLAGS_$@) is a similar feature for source files in assembly languages.h]hI$(AFLAGS_$@) is a similar feature for source files in assembly languages.}(hj] hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hAFLAGS_$@ has the higher priority than asflags-remove-y; AFLAGS_$@ can re-add assembler flags that were removed by asflags-remove-y.h]hAFLAGS_$@ has the higher priority than asflags-remove-y; AFLAGS_$@ can re-add assembler flags that were removed by asflags-remove-y.}(hjk hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h Example::h]hExample:}(hjy hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h# arch/arm/kernel/Makefile AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxth]h# arch/arm/kernel/Makefile AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjhhubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]compilation-flagsah ]h"]compilation flagsah$]h&]uh1hhjhhhhhM;ubh)}(hhh](h)}(hDependency trackingh]hDependency tracking}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(h,Kbuild tracks dependencies on the following:h]h,Kbuild tracks dependencies on the following:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hhh](j)}(h1All prerequisite files (both ``*.c`` and ``*.h``)h]h)}(hj h](hAll prerequisite files (both }(hj hhhNhNubj~)}(h``*.c``h]h*.c}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh and }(hj hhhNhNubj~)}(h``*.h``h]h*.h}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh)}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubj)}(h2``CONFIG_`` options used in all prerequisite filesh]h)}(hj h](j~)}(h ``CONFIG_``h]hCONFIG_}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh' options used in all prerequisite files}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubj)}(h$Command-line used to compile target h]h)}(h#Command-line used to compile targeth]h#Command-line used to compile target}(hj5 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj1 ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhj hhhhhMubh)}(hNThus, if you change an option to $(CC) all affected files will be re-compiled.h]hNThus, if you change an option to $(CC) all affected files will be re-compiled.}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubeh}(h]dependency-trackingah ]h"]dependency trackingah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h Custom Rulesh]h Custom Rules}(hjh hhhNhNubah}(h]h ]h"]h$]h&]uh1hhje hhhhhMubh)}(hX Custom rules are used when the kbuild infrastructure does not provide the required support. A typical example is header files generated during the build process. Another example are the architecture-specific Makefiles which need custom rules to prepare boot images etc.h]hX Custom rules are used when the kbuild infrastructure does not provide the required support. A typical example is header files generated during the build process. Another example are the architecture-specific Makefiles which need custom rules to prepare boot images etc.}(hjv hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhje hhubh)}(hCustom rules are written as normal Make rules. Kbuild is not executing in the directory where the Makefile is located, so all custom rules shall use a relative path to prerequisite files and target files.h]hCustom rules are written as normal Make rules. Kbuild is not executing in the directory where the Makefile is located, so all custom rules shall use a relative path to prerequisite files and target files.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhje hhubh)}(h2Two variables are used when defining custom rules:h]h2Two variables are used when defining custom rules:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhje hhubj)}(hhh](j)}(h$(src) $(src) is the directory where the Makefile is located. Always use $(src) when referring to files located in the src tree. h](j)}(h$(src)h]h$(src)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(hy$(src) is the directory where the Makefile is located. Always use $(src) when referring to files located in the src tree.h]hy$(src) is the directory where the Makefile is located. Always use $(src) when referring to files located in the src tree.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hX$(obj) $(obj) is the directory where the target is saved. Always use $(obj) when referring to generated files. Use $(obj) for pattern rules that need to work for both generated files and real sources (VPATH will help to find the prerequisites not only in the object tree but also in the source tree). Example:: #drivers/scsi/Makefile $(obj)/53c8xx_d.h: $(src)/53c7,8xx.scr $(src)/script_asm.pl $(CPP) -DCHIP=810 - < $< | ... $(src)/script_asm.pl This is a custom rule, following the normal syntax required by make. The target file depends on two prerequisite files. References to the target file are prefixed with $(obj), references to prerequisites are referenced with $(src) (because they are not generated files). h](j)}(h$(obj)h]h$(obj)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh](h)}(hX%$(obj) is the directory where the target is saved. Always use $(obj) when referring to generated files. Use $(obj) for pattern rules that need to work for both generated files and real sources (VPATH will help to find the prerequisites not only in the object tree but also in the source tree).h]hX%$(obj) is the directory where the target is saved. Always use $(obj) when referring to generated files. Use $(obj) for pattern rules that need to work for both generated files and real sources (VPATH will help to find the prerequisites not only in the object tree but also in the source tree).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h Example::h]hExample:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h#drivers/scsi/Makefile $(obj)/53c8xx_d.h: $(src)/53c7,8xx.scr $(src)/script_asm.pl $(CPP) -DCHIP=810 - < $< | ... $(src)/script_asm.plh]h#drivers/scsi/Makefile $(obj)/53c8xx_d.h: $(src)/53c7,8xx.scr $(src)/script_asm.pl $(CPP) -DCHIP=810 - < $< | ... $(src)/script_asm.pl}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(hDThis is a custom rule, following the normal syntax required by make.h]hDThis is a custom rule, following the normal syntax required by make.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hThe target file depends on two prerequisite files. References to the target file are prefixed with $(obj), references to prerequisites are referenced with $(src) (because they are not generated files).h]hThe target file depends on two prerequisite files. References to the target file are prefixed with $(obj), references to prerequisites are referenced with $(src) (because they are not generated files).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubj)}(hX0$(srcroot) $(srcroot) refers to the root of the source you are building, which can be either the kernel source or the external modules source, depending on whether KBUILD_EXTMOD is set. This can be either a relative or an absolute path, but if KBUILD_ABS_SRCTREE=1 is set, it is always an absolute path. h](j)}(h $(srcroot)h]h $(srcroot)}(hj= hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj9 ubj)}(hhh]h)}(hX$$(srcroot) refers to the root of the source you are building, which can be either the kernel source or the external modules source, depending on whether KBUILD_EXTMOD is set. This can be either a relative or an absolute path, but if KBUILD_ABS_SRCTREE=1 is set, it is always an absolute path.h]hX$$(srcroot) refers to the root of the source you are building, which can be either the kernel source or the external modules source, depending on whether KBUILD_EXTMOD is set. This can be either a relative or an absolute path, but if KBUILD_ABS_SRCTREE=1 is set, it is always an absolute path.}(hjN hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjK ubah}(h]h ]h"]h$]h&]uh1jhj9 ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubj)}(h~$(srctree) $(srctree) refers to the root of the kernel source tree. When building the kernel, this is the same as $(srcroot). h](j)}(h $(srctree)h]h $(srctree)}(hjl hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjh ubj)}(hhh]h)}(hr$(srctree) refers to the root of the kernel source tree. When building the kernel, this is the same as $(srcroot).h]hr$(srctree) refers to the root of the kernel source tree. When building the kernel, this is the same as $(srcroot).}(hj} hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjz ubah}(h]h ]h"]h$]h&]uh1jhjh ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubj)}(h$(objtree) $(objtree) refers to the root of the kernel object tree. It is ``.`` when building the kernel, but it is different when building external modules. h](j)}(h $(objtree)h]h $(objtree)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(h$(objtree) refers to the root of the kernel object tree. It is ``.`` when building the kernel, but it is different when building external modules.h](h?$(objtree) refers to the root of the kernel object tree. It is }(hj hhhNhNubj~)}(h``.``h]h.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubhN when building the kernel, but it is different when building external modules.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubj)}(hX-$(kecho) echoing information to user in a rule is often a good practice but when execution ``make -s`` one does not expect to see any output except for warnings/errors. To support this kbuild defines $(kecho) which will echo out the text following $(kecho) to stdout except if ``make -s`` is used. Example:: # arch/arm/Makefile $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ @$(kecho) ' Kernel: $(boot)/$@ is ready' When kbuild is executing with KBUILD_VERBOSE unset, then only a shorthand of a command is normally displayed. To enable this behaviour for custom commands kbuild requires two variables to be set:: quiet_cmd_ - what shall be echoed cmd_ - the command to execute Example:: # lib/Makefile quiet_cmd_crc32 = GEN $@ cmd_crc32 = $< > $@ $(obj)/crc32table.h: $(obj)/gen_crc32table $(call cmd,crc32) When updating the $(obj)/crc32table.h target, the line:: GEN lib/crc32table.h will be displayed with ``make KBUILD_VERBOSE=``. h](j)}(h$(kecho)h]h$(kecho)}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh](h)}(hX echoing information to user in a rule is often a good practice but when execution ``make -s`` one does not expect to see any output except for warnings/errors. To support this kbuild defines $(kecho) which will echo out the text following $(kecho) to stdout except if ``make -s`` is used.h](hRechoing information to user in a rule is often a good practice but when execution }(hj hhhNhNubj~)}(h ``make -s``h]hmake -s}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh one does not expect to see any output except for warnings/errors. To support this kbuild defines $(kecho) which will echo out the text following $(kecho) to stdout except if }(hj hhhNhNubj~)}(h ``make -s``h]hmake -s}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh is used.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h Example::h]hExample:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h# arch/arm/Makefile $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ @$(kecho) ' Kernel: $(boot)/$@ is ready'h]h# arch/arm/Makefile $(BOOT_TARGETS): vmlinux $(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@ @$(kecho) ' Kernel: $(boot)/$@ is ready'}hj- sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(hWhen kbuild is executing with KBUILD_VERBOSE unset, then only a shorthand of a command is normally displayed. To enable this behaviour for custom commands kbuild requires two variables to be set::h]hWhen kbuild is executing with KBUILD_VERBOSE unset, then only a shorthand of a command is normally displayed. To enable this behaviour for custom commands kbuild requires two variables to be set:}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hWquiet_cmd_ - what shall be echoed cmd_ - the command to executeh]hWquiet_cmd_ - what shall be echoed cmd_ - the command to execute}hjI sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(h Example::h]hExample:}(hjW hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h# lib/Makefile quiet_cmd_crc32 = GEN $@ cmd_crc32 = $< > $@ $(obj)/crc32table.h: $(obj)/gen_crc32table $(call cmd,crc32)h]h# lib/Makefile quiet_cmd_crc32 = GEN $@ cmd_crc32 = $< > $@ $(obj)/crc32table.h: $(obj)/gen_crc32table $(call cmd,crc32)}hje sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(h8When updating the $(obj)/crc32table.h target, the line::h]h7When updating the $(obj)/crc32table.h target, the line:}(hjs hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hGEN lib/crc32table.hh]hGEN lib/crc32table.h}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(h0will be displayed with ``make KBUILD_VERBOSE=``.h](hwill be displayed with }(hj hhhNhNubj~)}(h``make KBUILD_VERBOSE=``h]hmake KBUILD_VERBOSE=}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj ubh.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubeh}(h]h ]h"]h$]h&]uh1jhje hhhhhNubeh}(h] custom-rulesah ]h"] custom rulesah$]h&]uh1hhjhhhhhMjWKubh)}(hhh](h)}(hCommand change detectionh]hCommand change detection}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhMubh)}(hWhen the rule is evaluated, timestamps are compared between the target and its prerequisite files. GNU Make updates the target when any of the prerequisites is newer than that.h]hWhen the rule is evaluated, timestamps are compared between the target and its prerequisite files. GNU Make updates the target when any of the prerequisites is newer than that.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hThe target should be rebuilt also when the command line has changed since the last invocation. This is not supported by Make itself, so Kbuild achieves this by a kind of meta-programming.h]hThe target should be rebuilt also when the command line has changed since the last invocation. This is not supported by Make itself, so Kbuild achieves this by a kind of meta-programming.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hFif_changed is the macro used for this purpose, in the following form::h]hEif_changed is the macro used for this purpose, in the following form:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(huquiet_cmd_ = ... cmd_ = ... : FORCE $(call if_changed,)h]huquiet_cmd_ = ... cmd_ = ... : FORCE $(call if_changed,)}hj sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj hhubh)}(hAny target that utilizes if_changed must be listed in $(targets), otherwise the command line check will fail, and the target will always be built.h]hAny target that utilizes if_changed must be listed in $(targets), otherwise the command line check will fail, and the target will always be built.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hIf the target is already listed in the recognized syntax such as obj-y/m, lib-y/m, extra-y/m, always-y/m, hostprogs, userprogs, Kbuild automatically adds it to $(targets). Otherwise, the target must be explicitly added to $(targets).h]hIf the target is already listed in the recognized syntax such as obj-y/m, lib-y/m, extra-y/m, always-y/m, hostprogs, userprogs, Kbuild automatically adds it to $(targets). Otherwise, the target must be explicitly added to $(targets).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj hhubh)}(hAssignments to $(targets) are without $(obj)/ prefix. if_changed may be used in conjunction with custom rules as defined in `Custom Rules`_.h](h|Assignments to $(targets) are without $(obj)/ prefix. if_changed may be used in conjunction with custom rules as defined in }(hj. hhhNhNubj)}(h`Custom Rules`_h]h Custom Rules}(hj6 hhhNhNubah}(h]h ]h"]h$]h&]name Custom Rulesjj uh1jhj. jKubh.}(hj. hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(hNote: It is a typical mistake to forget the FORCE prerequisite. Another common pitfall is that whitespace is sometimes significant; for instance, the below will fail (note the extra space after the comma)::h]hNote: It is a typical mistake to forget the FORCE prerequisite. Another common pitfall is that whitespace is sometimes significant; for instance, the below will fail (note the extra space after the comma):}(hjP hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj hhubh)}(htarget: source(s) FORCEh]htarget: source(s) FORCE}hj^ sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj hhubh)}(h+**WRONG!** $(call if_changed, objcopy)h](hstrong)}(h **WRONG!**h]hWRONG!}(hjr hhhNhNubah}(h]h ]h"]h$]h&]uh1jp hjl ubh! $(call if_changed, objcopy)}(hjl hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj hhubj)}(hhh]j)}(hX"Note: if_changed should not be used more than once per target. It stores the executed command in a corresponding .cmd file and multiple calls would result in overwrites and unwanted results when the target is up to date and only the tests on changed commands trigger execution of commands. h](j)}(hNote:h]hNote:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM hj ubj)}(hhh]h)}(hXif_changed should not be used more than once per target. It stores the executed command in a corresponding .cmd file and multiple calls would result in overwrites and unwanted results when the target is up to date and only the tests on changed commands trigger execution of commands.h]hXif_changed should not be used more than once per target. It stores the executed command in a corresponding .cmd file and multiple calls would result in overwrites and unwanted results when the target is up to date and only the tests on changed commands trigger execution of commands.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM hj ubah}(h]h ]h"]h$]h&]uh1jhj hhhhhNubeh}(h]command-change-detectionah ]h"]command change detectionah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h$(CC) support functionsh]h$(CC) support functions}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj hhhhhM#ubh)}(hXThe kernel may be built with several different versions of $(CC), each supporting a unique set of features and options. kbuild provides basic support to check for valid options for $(CC). $(CC) is usually the gcc compiler, but other alternatives are available.h]hXThe kernel may be built with several different versions of $(CC), each supporting a unique set of features and options. kbuild provides basic support to check for valid options for $(CC). $(CC) is usually the gcc compiler, but other alternatives are available.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hj hhubj)}(hhh](j)}(hXas-option as-option is used to check if $(CC) -- when used to compile assembler (``*.S``) files -- supports the given option. An optional second option may be specified if the first option is not supported. Example:: #arch/sh/Makefile cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),) In the above example, cflags-y will be assigned the option -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC). The second argument is optional, and if supplied will be used if first argument is not supported. h](j)}(h as-optionh]h as-option}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM8hj ubj)}(hhh](h)}(has-option is used to check if $(CC) -- when used to compile assembler (``*.S``) files -- supports the given option. An optional second option may be specified if the first option is not supported.h](hGas-option is used to check if $(CC) -- when used to compile assembler (}(hjhhhNhNubj~)}(h``*.S``h]h*.S}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubhv) files -- supports the given option. An optional second option may be specified if the first option is not supported.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM,hj ubh)}(h Example::h]hExample:}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM0hj ubh)}(hI#arch/sh/Makefile cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)h]hI#arch/sh/Makefile cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)}hj/sbah}(h]h ]h"]h$]h&]hhuh1hhhhM2hj ubh)}(hIn the above example, cflags-y will be assigned the option -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC). The second argument is optional, and if supplied will be used if first argument is not supported.h]hIn the above example, cflags-y will be assigned the option -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC). The second argument is optional, and if supplied will be used if first argument is not supported.}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM5hj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhM8hj ubj)}(has-instr as-instr checks if the assembler reports a specific instruction and then outputs either option1 or option2 C escapes are supported in the test instruction Note: as-instr-option uses KBUILD_AFLAGS for assembler options h](j)}(has-instrh]has-instr}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM>hjWubj)}(hhh]h)}(has-instr checks if the assembler reports a specific instruction and then outputs either option1 or option2 C escapes are supported in the test instruction Note: as-instr-option uses KBUILD_AFLAGS for assembler optionsh]has-instr checks if the assembler reports a specific instruction and then outputs either option1 or option2 C escapes are supported in the test instruction Note: as-instr-option uses KBUILD_AFLAGS for assembler options}(hjlhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM;hjiubah}(h]h ]h"]h$]h&]uh1jhjWubeh}(h]h ]h"]h$]h&]uh1jhhhM>hj hhubj)}(hXcc-option cc-option is used to check if $(CC) supports a given option, and if not supported to use an optional second option. Example:: #arch/x86/Makefile cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586) In the above example, cflags-y will be assigned the option -march=pentium-mmx if supported by $(CC), otherwise -march=i586. The second argument to cc-option is optional, and if omitted, cflags-y will be assigned no value if first option is not supported. Note: cc-option uses KBUILD_CFLAGS for $(CC) options h](j)}(h cc-optionh]h cc-option}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMMhjubj)}(hhh](h)}(hscc-option is used to check if $(CC) supports a given option, and if not supported to use an optional second option.h]hscc-option is used to check if $(CC) supports a given option, and if not supported to use an optional second option.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMAhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhjubh)}(hO#arch/x86/Makefile cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)h]hO#arch/x86/Makefile cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMFhjubh)}(hX3In the above example, cflags-y will be assigned the option -march=pentium-mmx if supported by $(CC), otherwise -march=i586. The second argument to cc-option is optional, and if omitted, cflags-y will be assigned no value if first option is not supported. Note: cc-option uses KBUILD_CFLAGS for $(CC) optionsh]hX3In the above example, cflags-y will be assigned the option -march=pentium-mmx if supported by $(CC), otherwise -march=i586. The second argument to cc-option is optional, and if omitted, cflags-y will be assigned no value if first option is not supported. Note: cc-option uses KBUILD_CFLAGS for $(CC) options}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMIhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMMhj hhubj)}(hXcc-option-yn cc-option-yn is used to check if $(CC) supports a given option and return "y" if supported, otherwise "n". Example:: #arch/ppc/Makefile biarch := $(call cc-option-yn, -m32) aflags-$(biarch) += -a32 cflags-$(biarch) += -m32 In the above example, $(biarch) is set to y if $(CC) supports the -m32 option. When $(biarch) equals "y", the expanded variables $(aflags-y) and $(cflags-y) will be assigned the values -a32 and -m32, respectively. Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options h](j)}(h cc-option-ynh]h cc-option-yn}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM_hjubj)}(hhh](h)}(hjcc-option-yn is used to check if $(CC) supports a given option and return "y" if supported, otherwise "n".h]hrcc-option-yn is used to check if $(CC) supports a given option and return “y” if supported, otherwise “n”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMShjubh)}(hi#arch/ppc/Makefile biarch := $(call cc-option-yn, -m32) aflags-$(biarch) += -a32 cflags-$(biarch) += -m32h]hi#arch/ppc/Makefile biarch := $(call cc-option-yn, -m32) aflags-$(biarch) += -a32 cflags-$(biarch) += -m32}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMUhjubh)}(hIn the above example, $(biarch) is set to y if $(CC) supports the -m32 option. When $(biarch) equals "y", the expanded variables $(aflags-y) and $(cflags-y) will be assigned the values -a32 and -m32, respectively.h]hIn the above example, $(biarch) is set to y if $(CC) supports the -m32 option. When $(biarch) equals “y”, the expanded variables $(aflags-y) and $(cflags-y) will be assigned the values -a32 and -m32, respectively.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhjubh)}(h7Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) optionsh]h7Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM_hjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhM_hj hhubj)}(hXcc-disable-warning cc-disable-warning checks if $(CC) supports a given warning and returns the commandline switch to disable it. This special function is needed, because gcc 4.4 and later accept any unknown -Wno-* option and only warn about it if there is another warning in the source file. Example:: KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) In the above example, -Wno-unused-but-set-variable will be added to KBUILD_CFLAGS only if $(CC) really accepts it. h](j)}(hcc-disable-warningh]hcc-disable-warning}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMlhjFubj)}(hhh](h)}(hXcc-disable-warning checks if $(CC) supports a given warning and returns the commandline switch to disable it. This special function is needed, because gcc 4.4 and later accept any unknown -Wno-* option and only warn about it if there is another warning in the source file.h]hXcc-disable-warning checks if $(CC) supports a given warning and returns the commandline switch to disable it. This special function is needed, because gcc 4.4 and later accept any unknown -Wno-* option and only warn about it if there is another warning in the source file.}(hj[hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhjXubh)}(h Example::h]hExample:}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghjXubh)}(hDKBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)h]hDKBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)}hjwsbah}(h]h ]h"]h$]h&]hhuh1hhhhMihjXubh)}(hrIn the above example, -Wno-unused-but-set-variable will be added to KBUILD_CFLAGS only if $(CC) really accepts it.h]hrIn the above example, -Wno-unused-but-set-variable will be added to KBUILD_CFLAGS only if $(CC) really accepts it.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMkhjXubeh}(h]h ]h"]h$]h&]uh1jhjFubeh}(h]h ]h"]h$]h&]uh1jhhhMlhj hhubj)}(hXAgcc-min-version gcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than or equal to the provided value and evaluates to y if so. Example:: cflags-$(call gcc-min-version, 70100) := -foo In this example, cflags-y will be assigned the value -foo if $(CC) is gcc and $(CONFIG_GCC_VERSION) is >= 7.1. h](j)}(hgcc-min-versionh]hgcc-min-version}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMwhjubj)}(hhh](h)}(hgcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than or equal to the provided value and evaluates to y if so.h]hgcc-min-version tests if the value of $(CONFIG_GCC_VERSION) is greater than or equal to the provided value and evaluates to y if so.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMohjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMrhjubh)}(h-cflags-$(call gcc-min-version, 70100) := -fooh]h-cflags-$(call gcc-min-version, 70100) := -foo}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMthjubh)}(hnIn this example, cflags-y will be assigned the value -foo if $(CC) is gcc and $(CONFIG_GCC_VERSION) is >= 7.1.h]hnIn this example, cflags-y will be assigned the value -foo if $(CC) is gcc and $(CONFIG_GCC_VERSION) is >= 7.1.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMwhj hhubj)}(hXQclang-min-version clang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater than or equal to the provided value and evaluates to y if so. Example:: cflags-$(call clang-min-version, 110000) := -foo In this example, cflags-y will be assigned the value -foo if $(CC) is clang and $(CONFIG_CLANG_VERSION) is >= 11.0.0. h](j)}(hclang-min-versionh]hclang-min-version}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(hclang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater than or equal to the provided value and evaluates to y if so.h]hclang-min-version tests if the value of $(CONFIG_CLANG_VERSION) is greater than or equal to the provided value and evaluates to y if so.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMzhj ubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM}hj ubh)}(h0cflags-$(call clang-min-version, 110000) := -fooh]h0cflags-$(call clang-min-version, 110000) := -foo}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj ubh)}(huIn this example, cflags-y will be assigned the value -foo if $(CC) is clang and $(CONFIG_CLANG_VERSION) is >= 11.0.0.h]huIn this example, cflags-y will be assigned the value -foo if $(CC) is clang and $(CONFIG_CLANG_VERSION) is >= 11.0.0.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubj)}(hXhcc-cross-prefix cc-cross-prefix is used to check if there exists a $(CC) in path with one of the listed prefixes. The first prefix where there exist a prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found then nothing is returned. Additional prefixes are separated by a single space in the call of cc-cross-prefix. This functionality is useful for architecture Makefiles that try to set CROSS_COMPILE to well-known values but may have several values to select between. It is recommended only to try to set CROSS_COMPILE if it is a cross build (host arch is different from target arch). And if CROSS_COMPILE is already set then leave it with the old value. Example:: #arch/m68k/Makefile ifneq ($(SUBARCH),$(ARCH)) ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) endif endif h](j)}(hcc-cross-prefixh]hcc-cross-prefix}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjQubj)}(hhh](h)}(hcc-cross-prefix is used to check if there exists a $(CC) in path with one of the listed prefixes. The first prefix where there exist a prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found then nothing is returned.h]hcc-cross-prefix is used to check if there exists a $(CC) in path with one of the listed prefixes. The first prefix where there exist a prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found then nothing is returned.}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(hSAdditional prefixes are separated by a single space in the call of cc-cross-prefix.h]hSAdditional prefixes are separated by a single space in the call of cc-cross-prefix.}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(hThis functionality is useful for architecture Makefiles that try to set CROSS_COMPILE to well-known values but may have several values to select between.h]hThis functionality is useful for architecture Makefiles that try to set CROSS_COMPILE to well-known values but may have several values to select between.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(hIt is recommended only to try to set CROSS_COMPILE if it is a cross build (host arch is different from target arch). And if CROSS_COMPILE is already set then leave it with the old value.h]hIt is recommended only to try to set CROSS_COMPILE if it is a cross build (host arch is different from target arch). And if CROSS_COMPILE is already set then leave it with the old value.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(h#arch/m68k/Makefile ifneq ($(SUBARCH),$(ARCH)) ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) endif endifh]h#arch/m68k/Makefile ifneq ($(SUBARCH),$(ARCH)) ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) endif endif}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjcubeh}(h]h ]h"]h$]h&]uh1jhjQubeh}(h]h ]h"]h$]h&]uh1jhhhMhj hhubeh}(h]h ]h"]h$]h&]uh1jhj hhhhhNubeh}(h]cc-support-functionsah ]h"]$(cc) support functionsah$]h&]uh1hhjhhhhhM#ubh)}(hhh](h)}(h$(RUSTC) support functionsh]h$(RUSTC) support functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubj)}(hhh]j)}(hXFrustc-min-version rustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater than or equal to the provided value and evaluates to y if so. Example:: rustflags-$(call rustc-min-version, 108500) := -Cfoo In this example, rustflags-y will be assigned the value -Cfoo if $(CONFIG_RUSTC_VERSION) is >= 1.85.0. h](j)}(hrustc-min-versionh]hrustc-min-version}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(hrustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater than or equal to the provided value and evaluates to y if so.h]hrustc-min-version tests if the value of $(CONFIG_RUSTC_VERSION) is greater than or equal to the provided value and evaluates to y if so.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h Example::h]hExample:}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h4rustflags-$(call rustc-min-version, 108500) := -Cfooh]h4rustflags-$(call rustc-min-version, 108500) := -Cfoo}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjubh)}(hfIn this example, rustflags-y will be assigned the value -Cfoo if $(CONFIG_RUSTC_VERSION) is >= 1.85.0.h]hfIn this example, rustflags-y will be assigned the value -Cfoo if $(CONFIG_RUSTC_VERSION) is >= 1.85.0.}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]rustc-support-functionsah ]h"]$(rustc) support functionsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h$(LD) support functionsh]h$(LD) support functions}(hjRhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjOhhhhhMubj)}(hhh]j)}(hX$ld-option ld-option is used to check if $(LD) supports the supplied option. ld-option takes two options as arguments. The second argument is an optional option that can be used if the first option is not supported by $(LD). Example:: #Makefile LDFLAGS_vmlinux += $(call ld-option, -X) h](j)}(h ld-optionh]h ld-option}(hjghhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjcubj)}(hhh](h)}(hkld-option is used to check if $(LD) supports the supplied option. ld-option takes two options as arguments.h]hkld-option is used to check if $(LD) supports the supplied option. ld-option takes two options as arguments.}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjuubh)}(hiThe second argument is an optional option that can be used if the first option is not supported by $(LD).h]hiThe second argument is an optional option that can be used if the first option is not supported by $(LD).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjuubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjuubh)}(h2#Makefile LDFLAGS_vmlinux += $(call ld-option, -X)h]h2#Makefile LDFLAGS_vmlinux += $(call ld-option, -X)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjuubeh}(h]h ]h"]h$]h&]uh1jhjcubeh}(h]h ]h"]h$]h&]uh1jhhhMhj`ubah}(h]h ]h"]h$]h&]uh1jhjOhhhhhNubeh}(h]ld-support-functionsah ]h"]$(ld) support functionsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hScript invocationh]hScript invocation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hX~Make rules may invoke scripts to build the kernel. The rules shall always provide the appropriate interpreter to execute the script. They shall not rely on the execute bits being set, and shall not invoke the script directly. For the convenience of manual script invocation, such as invoking ./scripts/checkpatch.pl, it is recommended to set execute bits on the scripts nonetheless.h]hX~Make rules may invoke scripts to build the kernel. The rules shall always provide the appropriate interpreter to execute the script. They shall not rely on the execute bits being set, and shall not invoke the script directly. For the convenience of manual script invocation, such as invoking ./scripts/checkpatch.pl, it is recommended to set execute bits on the scripts nonetheless.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hKbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), and $(PYTHON3) to refer to interpreters for the respective scripts.h]hKbuild provides variables $(CONFIG_SHELL), $(AWK), $(PERL), and $(PYTHON3) to refer to interpreters for the respective scripts.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hh#Makefile cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ $(KERNELRELEASE)h]hh#Makefile cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ $(KERNELRELEASE)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubeh}(h]script-invocationah ]h"]script invocationah$]h&]uh1hhjhhhhhMubeh}(h]the-kbuild-filesah ]h"]the kbuild filesah$]h&]uh1hhhhhhhhKBubh)}(hhh](h)}(hHost Program supporth]hHost Program support}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj#hhhhhMubh)}(hVKbuild supports building executables on the host for use during the compilation stage.h]hVKbuild supports building executables on the host for use during the compilation stage.}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h9Two steps are required in order to use a host executable.h]h9Two steps are required in order to use a host executable.}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hoThe first step is to tell kbuild that a host program exists. This is done utilising the variable ``hostprogs``.h](haThe first step is to tell kbuild that a host program exists. This is done utilising the variable }(hjPhhhNhNubj~)}(h ``hostprogs``h]h hostprogs}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjPubh.}(hjPhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hThe second step is to add an explicit dependency to the executable. This can be done in two ways. Either add the dependency in a rule, or utilise the variable ``always-y``. Both possibilities are described in the following.h](hThe second step is to add an explicit dependency to the executable. This can be done in two ways. Either add the dependency in a rule, or utilise the variable }(hjphhhNhNubj~)}(h ``always-y``h]halways-y}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjpubh4. Both possibilities are described in the following.}(hjphhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hhh](h)}(hSimple Host Programh]hSimple Host Program}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hfIn some cases there is a need to compile and run a program on the computer where the build is running.h]hfIn some cases there is a need to compile and run a program on the computer where the build is running.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hZThe following line tells kbuild that the program bin2hex shall be built on the build host.h]hZThe following line tells kbuild that the program bin2hex shall be built on the build host.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hhostprogs := bin2hexh]hhostprogs := bin2hex}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubh)}(hKbuild assumes in the above example that bin2hex is made from a single c-source file named bin2hex.c located in the same directory as the Makefile.h]hKbuild assumes in the above example that bin2hex is made from a single c-source file named bin2hex.c located in the same directory as the Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]simple-host-programah ]h"]simple host programah$]h&]uh1hhj#hhhhhMubh)}(hhh](h)}(hComposite Host Programsh]hComposite Host Programs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hHost programs can be made up based on composite objects. The syntax used to define composite objects for host programs is similar to the syntax used for kernel objects. $(-objs) lists all objects used to link the final executable.h]hHost programs can be made up based on composite objects. The syntax used to define composite objects for host programs is similar to the syntax used for kernel objects. $(-objs) lists all objects used to link the final executable.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h\#scripts/lxdialog/Makefile hostprogs := lxdialog lxdialog-objs := checklist.o lxdialog.oh]h\#scripts/lxdialog/Makefile hostprogs := lxdialog lxdialog-objs := checklist.o lxdialog.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubh)}(hObjects with extension .o are compiled from the corresponding .c files. In the above example, checklist.c is compiled to checklist.o and lxdialog.c is compiled to lxdialog.o.h]hObjects with extension .o are compiled from the corresponding .c files. In the above example, checklist.c is compiled to checklist.o and lxdialog.c is compiled to lxdialog.o.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hFinally, the two .o files are linked to the executable, lxdialog. Note: The syntax -y is not permitted for host-programs.h]hFinally, the two .o files are linked to the executable, lxdialog. Note: The syntax -y is not permitted for host-programs.}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]composite-host-programsah ]h"]composite host programsah$]h&]uh1hhj#hhhhhMubh)}(hhh](h)}(hUsing C++ for host programsh]hUsing C++ for host programs}(hjQhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjNhhhhhMubh)}(hkbuild offers support for host programs written in C++. This was introduced solely to support kconfig, and is not recommended for general use.h]hkbuild offers support for host programs written in C++. This was introduced solely to support kconfig, and is not recommended for general use.}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjNhhubh)}(h Example::h]hExample:}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjNhhubh)}(hI#scripts/kconfig/Makefile hostprogs := qconf qconf-cxxobjs := qconf.oh]hI#scripts/kconfig/Makefile hostprogs := qconf qconf-cxxobjs := qconf.o}hj{sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjNhhubh)}(hjIn the example above the executable is composed of the C++ file qconf.cc - identified by $(qconf-cxxobjs).h]hjIn the example above the executable is composed of the C++ file qconf.cc - identified by $(qconf-cxxobjs).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjNhhubh)}(hlIf qconf is composed of a mixture of .c and .cc files, then an additional line can be used to identify this.h]hlIf qconf is composed of a mixture of .c and .cc files, then an additional line can be used to identify this.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjNhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjNhhubh)}(hb#scripts/kconfig/Makefile hostprogs := qconf qconf-cxxobjs := qconf.o qconf-objs := check.oh]hb#scripts/kconfig/Makefile hostprogs := qconf qconf-cxxobjs := qconf.o qconf-objs := check.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjNhhubeh}(h]using-c-for-host-programsah ]h"]using c++ for host programsah$]h&]uh1hhj#hhhhhMubh)}(hhh](h)}(hUsing Rust for host programsh]hUsing Rust for host programs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM!ubh)}(hKbuild offers support for host programs written in Rust. However, since a Rust toolchain is not mandatory for kernel compilation, it may only be used in scenarios where Rust is required to be available (e.g. when ``CONFIG_RUST`` is enabled).h](hKbuild offers support for host programs written in Rust. However, since a Rust toolchain is not mandatory for kernel compilation, it may only be used in scenarios where Rust is required to be available (e.g. when }(hjhhhNhNubj~)}(h``CONFIG_RUST``h]h CONFIG_RUST}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh is enabled).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM#hjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM(hjhhubh)}(h*hostprogs := target target-rust := yh]h*hostprogs := target target-rust := y}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhM*hjhhubh)}(hKbuild will compile ``target`` using ``target.rs`` as the crate root, located in the same directory as the ``Makefile``. The crate may consist of several source files (see ``samples/rust/hostprogs``).h](hKbuild will compile }(hjhhhNhNubj~)}(h ``target``h]htarget}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh using }(hjhhhNhNubj~)}(h ``target.rs``h]h target.rs}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh9 as the crate root, located in the same directory as the }(hjhhhNhNubj~)}(h ``Makefile``h]hMakefile}(hjBhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh5. The crate may consist of several source files (see }(hjhhhNhNubj~)}(h``samples/rust/hostprogs``h]hsamples/rust/hostprogs}(hjThhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM-hjhhubeh}(h]using-rust-for-host-programsah ]h"]using rust for host programsah$]h&]uh1hhj#hhhhhM!ubh)}(hhh](h)}(h.Controlling compiler options for host programsh]h.Controlling compiler options for host programs}(hjwhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjthhhhhM2ubh)}(hWhen compiling host programs, it is possible to set specific flags. The programs will always be compiled utilising $(HOSTCC) passed the options specified in $(KBUILD_HOSTCFLAGS).h]hWhen compiling host programs, it is possible to set specific flags. The programs will always be compiled utilising $(HOSTCC) passed the options specified in $(KBUILD_HOSTCFLAGS).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM4hjthhubh)}(huTo set flags that will take effect for all host programs created in that Makefile, use the variable HOST_EXTRACFLAGS.h]huTo set flags that will take effect for all host programs created in that Makefile, use the variable HOST_EXTRACFLAGS.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM8hjthhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM;hjthhubh)}(hE#scripts/lxdialog/Makefile HOST_EXTRACFLAGS += -I/usr/include/ncursesh]hE#scripts/lxdialog/Makefile HOST_EXTRACFLAGS += -I/usr/include/ncurses}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhM=hjthhubh)}(hKTo set specific flags for a single file the following construction is used:h]hKTo set specific flags for a single file the following construction is used:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM@hjthhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMChjthhubh)}(hN#arch/ppc64/boot/Makefile HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)h]hN#arch/ppc64/boot/Makefile HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMEhjthhubh)}(h@It is also possible to specify additional options to the linker.h]h@It is also possible to specify additional options to the linker.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhjthhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMJhjthhubh)}(h<#scripts/kconfig/Makefile HOSTLDLIBS_qconf := -L$(QTDIR)/libh]h<#scripts/kconfig/Makefile HOSTLDLIBS_qconf := -L$(QTDIR)/lib}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMLhjthhubh)}(hJWhen linking qconf, it will be passed the extra option ``-L$(QTDIR)/lib``.h](h7When linking qconf, it will be passed the extra option }(hjhhhNhNubj~)}(h``-L$(QTDIR)/lib``h]h-L$(QTDIR)/lib}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMOhjthhubeh}(h].controlling-compiler-options-for-host-programsah ]h"].controlling compiler options for host programsah$]h&]uh1hhj#hhhhhM2ubh)}(hhh](h)}(h%When host programs are actually builth]h%When host programs are actually built}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj9hhhhhMSubh)}(hPKbuild will only build host-programs when they are referenced as a prerequisite.h]hPKbuild will only build host-programs when they are referenced as a prerequisite.}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMUhj9hhubh)}(hThis is possible in two ways:h]hThis is possible in two ways:}(hjXhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMXhj9hhubj)}(hhh](j)}(hXyList the prerequisite explicitly in a custom rule. Example:: #drivers/pci/Makefile hostprogs := gen-devlist $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist ( cd $(obj); ./gen-devlist ) < $< The target $(obj)/devlist.h will not be built before $(obj)/gen-devlist is updated. Note that references to the host programs in custom rules must be prefixed with $(obj). h](h)}(h2List the prerequisite explicitly in a custom rule.h]h2List the prerequisite explicitly in a custom rule.}(hjmhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMZhjiubh)}(h Example::h]hExample:}(hj{hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM\hjiubh)}(h#drivers/pci/Makefile hostprogs := gen-devlist $(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist ( cd $(obj); ./gen-devlist ) < $-objs) lists all objects used to link the final executable.h]hUserspace programs can be made up based on composite objects. The syntax used to define composite objects for userspace programs is similar to the syntax used for kernel objects. $(-objs) lists all objects used to link the final executable.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h`#samples/seccomp/Makefile userprogs := bpf-fancy bpf-fancy-objs := bpf-fancy.o bpf-helper.oh]h`#samples/seccomp/Makefile userprogs := bpf-fancy bpf-fancy-objs := bpf-fancy.o bpf-helper.o}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjhhubh)}(hObjects with extension .o are compiled from the corresponding .c files. In the above example, bpf-fancy.c is compiled to bpf-fancy.o and bpf-helper.c is compiled to bpf-helper.o.h]hObjects with extension .o are compiled from the corresponding .c files. In the above example, bpf-fancy.c is compiled to bpf-fancy.o and bpf-helper.c is compiled to bpf-helper.o.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hFinally, the two .o files are linked to the executable, bpf-fancy. Note: The syntax -y is not permitted for userspace programs.h]hFinally, the two .o files are linked to the executable, bpf-fancy. Note: The syntax -y is not permitted for userspace programs.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubeh}(h]composite-userspace-programsah ]h"]composite userspace programsah$]h&]uh1hhj.hhhhhMubh)}(hhh](h)}(h3Controlling compiler options for userspace programsh]h3Controlling compiler options for userspace programs}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj/hhhhhMubh)}(hWhen compiling userspace programs, it is possible to set specific flags. The programs will always be compiled utilising $(CC) passed the options specified in $(KBUILD_USERCFLAGS).h]hWhen compiling userspace programs, it is possible to set specific flags. The programs will always be compiled utilising $(CC) passed the options specified in $(KBUILD_USERCFLAGS).}(hj@hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(huTo set flags that will take effect for all userspace programs created in that Makefile, use the variable userccflags.h]huTo set flags that will take effect for all userspace programs created in that Makefile, use the variable userccflags.}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h Example::h]hExample:}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h8# samples/seccomp/Makefile userccflags += -I usr/includeh]h8# samples/seccomp/Makefile userccflags += -I usr/include}hjjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj/hhubh)}(hKTo set specific flags for a single file the following construction is used:h]hKTo set specific flags for a single file the following construction is used:}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h)bpf-helper-userccflags += -I user/includeh]h)bpf-helper-userccflags += -I user/include}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj/hhubh)}(h@It is also possible to specify additional options to the linker.h]h@It is also possible to specify additional options to the linker.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(h;# net/bpfilter/Makefile bpfilter_umh-userldflags += -statich]h;# net/bpfilter/Makefile bpfilter_umh-userldflags += -static}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj/hhubh)}(hTo specify libraries linked to a userspace program, you can use ``-userldlibs``. The ``userldlibs`` syntax specifies libraries linked to all userspace programs created in the current Makefile.h](h@To specify libraries linked to a userspace program, you can use }(hjhhhNhNubj~)}(h``-userldlibs``h]h-userldlibs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh. The }(hjhhhNhNubj~)}(h``userldlibs``h]h userldlibs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh] syntax specifies libraries linked to all userspace programs created in the current Makefile.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(hFWhen linking bpfilter_umh, it will be passed the extra option -static.h]hFWhen linking bpfilter_umh, it will be passed the extra option -static.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubh)}(hYFrom command line, :ref:`USERCFLAGS and USERLDFLAGS ` will also be used.h](hFrom command line, }(hj hhhNhNubh)}(h3:ref:`USERCFLAGS and USERLDFLAGS `h]hinline)}(hjh]hUSERCFLAGS and USERLDFLAGS}(hjhhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]refdockbuild/makefiles refdomainj%reftyperef refexplicitrefwarn reftargetuserkbuildflagsuh1hhhhMhj ubh will also be used.}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj/hhubeh}(h]3controlling-compiler-options-for-userspace-programsah ]h"]3controlling compiler options for userspace programsah$]h&]uh1hhj.hhhhhMubh)}(hhh](h)}(h*When userspace programs are actually builth]h*When userspace programs are actually built}(hjNhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjKhhhhhMubh)}(hXKbuild builds userspace programs only when told to do so. There are two ways to do this.h]hXKbuild builds userspace programs only when told to do so. There are two ways to do this.}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjKhhubj)}(hhh](j)}(hAdd it as the prerequisite of another file Example:: #net/bpfilter/Makefile userprogs := bpfilter_umh $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh $(obj)/bpfilter_umh is built before $(obj)/bpfilter_umh_blob.o h](h)}(h*Add it as the prerequisite of another fileh]h*Add it as the prerequisite of another file}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjmubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjmubh)}(h`#net/bpfilter/Makefile userprogs := bpfilter_umh $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umhh]h`#net/bpfilter/Makefile userprogs := bpfilter_umh $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjmubh)}(h>$(obj)/bpfilter_umh is built before $(obj)/bpfilter_umh_blob.oh]h>$(obj)/bpfilter_umh is built before $(obj)/bpfilter_umh_blob.o}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjmubeh}(h]h ]h"]h$]h&]uh1jhjjhhhhhNubj)}(hXUse always-y Example:: userprogs := binderfs_example always-y := $(userprogs) Kbuild provides the following shorthand for this:: userprogs-always-y := binderfs_example This will tell Kbuild to build binderfs_example when it visits this Makefile. h](h)}(h Use always-yh]h Use always-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h6userprogs := binderfs_example always-y := $(userprogs)h]h6userprogs := binderfs_example always-y := $(userprogs)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjubh)}(h2Kbuild provides the following shorthand for this::h]h1Kbuild provides the following shorthand for this:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h&userprogs-always-y := binderfs_exampleh]h&userprogs-always-y := binderfs_example}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjubh)}(hMThis will tell Kbuild to build binderfs_example when it visits this Makefile.h]hMThis will tell Kbuild to build binderfs_example when it visits this Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjjhhhhhNubeh}(h]h ]h"]h$]h&]jjjjjjuh1jhjKhhhhhMubeh}(h]*when-userspace-programs-are-actually-builtah ]h"]*when userspace programs are actually builtah$]h&]uh1hhj.hhhhhMubeh}(h]userspace-program-supportah ]h"]userspace program supportah$]h&]uh1hhhhhhhhM{ubh)}(hhh](h)}(hKbuild clean infrastructureh]hKbuild clean infrastructure}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj#hhhhhMubh)}(hX``make clean`` deletes most generated files in the obj tree where the kernel is compiled. This includes generated files such as host programs. Kbuild knows targets listed in $(hostprogs), $(always-y), $(always-m), $(always-), $(extra-y), $(extra-) and $(targets). They are all deleted during ``make clean``. Files matching the patterns ``*.[oas]``, ``*.ko``, plus some additional files generated by kbuild are deleted all over the kernel source tree when ``make clean`` is executed.h](j~)}(h``make clean``h]h make clean}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj4ubhX deletes most generated files in the obj tree where the kernel is compiled. This includes generated files such as host programs. Kbuild knows targets listed in $(hostprogs), $(always-y), $(always-m), $(always-), $(extra-y), $(extra-) and $(targets). They are all deleted during }(hj4hhhNhNubj~)}(h``make clean``h]h make clean}(hjJhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj4ubh. Files matching the patterns }(hj4hhhNhNubj~)}(h ``*.[oas]``h]h*.[oas]}(hj\hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj4ubh, }(hj4hhhNhNubj~)}(h``*.ko``h]h*.ko}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj4ubhb, plus some additional files generated by kbuild are deleted all over the kernel source tree when }(hj4hhhNhNubj~)}(h``make clean``h]h make clean}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj4ubh is executed.}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h^Additional files or directories can be specified in kbuild makefiles by use of $(clean-files).h]h^Additional files or directories can be specified in kbuild makefiles by use of $(clean-files).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h)#lib/Makefile clean-files := crc32table.hh]h)#lib/Makefile clean-files := crc32table.h}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj#hhubh)}(hWhen executing ``make clean``, the file ``crc32table.h`` will be deleted. Kbuild will assume files to be in the same relative directory as the Makefile.h](hWhen executing }(hjhhhNhNubj~)}(h``make clean``h]h make clean}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh , the file }(hjhhhNhNubj~)}(h``crc32table.h``h]h crc32table.h}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh` will be deleted. Kbuild will assume files to be in the same relative directory as the Makefile.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h\To exclude certain files or directories from make clean, use the $(no-clean-files) variable.h]h\To exclude certain files or directories from make clean, use the $(no-clean-files) variable.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hUsually kbuild descends down in subdirectories due to ``obj-* := dir/``, but in the architecture makefiles where the kbuild infrastructure is not sufficient this sometimes needs to be explicit.h](h6Usually kbuild descends down in subdirectories due to }(hjhhhNhNubj~)}(h``obj-* := dir/``h]h obj-* := dir/}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubhz, but in the architecture makefiles where the kbuild infrastructure is not sufficient this sometimes needs to be explicit.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(h Example::h]hExample:}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hj#hhubh)}(h-#arch/x86/boot/Makefile subdir- := compressedh]h-#arch/x86/boot/Makefile subdir- := compressed}hj0sbah}(h]h ]h"]h$]h&]hhuh1hhhhM hj#hhubh)}(hsThe above assignment instructs kbuild to descend down in the directory compressed/ when ``make clean`` is executed.h](hXThe above assignment instructs kbuild to descend down in the directory compressed/ when }(hj>hhhNhNubj~)}(h``make clean``h]h make clean}(hjFhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj>ubh is executed.}(hj>hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hNote 1: arch/$(SRCARCH)/Makefile cannot use ``subdir-``, because that file is included in the top level makefile. Instead, arch/$(SRCARCH)/Kbuild can use ``subdir-``.h](h,Note 1: arch/$(SRCARCH)/Makefile cannot use }(hj^hhhNhNubj~)}(h ``subdir-``h]hsubdir-}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj^ubhc, because that file is included in the top level makefile. Instead, arch/$(SRCARCH)/Kbuild can use }(hj^hhhNhNubj~)}(h ``subdir-``h]hsubdir-}(hjxhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj^ubh.}(hj^hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubh)}(hlNote 2: All directories listed in core-y, libs-y, drivers-y and net-y will be visited during ``make clean``.h](h]Note 2: All directories listed in core-y, libs-y, drivers-y and net-y will be visited during }(hjhhhNhNubj~)}(h``make clean``h]h make clean}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj#hhubeh}(h]kbuild-clean-infrastructureah ]h"]kbuild clean infrastructureah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hArchitecture Makefilesh]hArchitecture Makefiles}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhMubh)}(hThe top level Makefile sets up the environment and does the preparation, before starting to descend down in the individual directories.h]hThe top level Makefile sets up the environment and does the preparation, before starting to descend down in the individual directories.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(hThe top level makefile contains the generic part, whereas arch/$(SRCARCH)/Makefile contains what is required to set up kbuild for said architecture.h]hThe top level makefile contains the generic part, whereas arch/$(SRCARCH)/Makefile contains what is required to set up kbuild for said architecture.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjhhubh)}(h[To do so, arch/$(SRCARCH)/Makefile sets up a number of variables and defines a few targets.h]h[To do so, arch/$(SRCARCH)/Makefile sets up a number of variables and defines a few targets.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hjhhubh)}(hAWhen kbuild executes, the following steps are followed (roughly):h]hAWhen kbuild executes, the following steps are followed (roughly):}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hjhhubj)}(hhh](j)}(h/Configuration of the kernel => produce .config h]h)}(h.Configuration of the kernel => produce .configh]h.Configuration of the kernel => produce .config}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM'hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h0Store kernel version in include/linux/version.h h]h)}(h/Store kernel version in include/linux/version.hh]h/Store kernel version in include/linux/version.h}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM)hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(h~Updating all other prerequisites to the target prepare: - Additional prerequisites are specified in arch/$(SRCARCH)/Makefile h](h)}(h7Updating all other prerequisites to the target prepare:h]h7Updating all other prerequisites to the target prepare:}(hj8hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM+hj4ubh bullet_list)}(hhh]j)}(hCAdditional prerequisites are specified in arch/$(SRCARCH)/Makefile h]h)}(hBAdditional prerequisites are specified in arch/$(SRCARCH)/Makefileh]hBAdditional prerequisites are specified in arch/$(SRCARCH)/Makefile}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM-hjKubah}(h]h ]h"]h$]h&]uh1jhjHubah}(h]h ]h"]h$]h&]bullet-uh1jFhhhM-hj4ubeh}(h]h ]h"]h$]h&]uh1jhjhhhNhNubj)}(hRecursively descend down in all directories listed in init-* core* drivers-* net-* libs-* and build all targets. - The values of the above variables are expanded in arch/$(SRCARCH)/Makefile. h](h)}(hpRecursively descend down in all directories listed in init-* core* drivers-* net-* libs-* and build all targets.h]hpRecursively descend down in all directories listed in init-* core* drivers-* net-* libs-* and build all targets.}(hjuhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM/hjqubjG)}(hhh]j)}(hLThe values of the above variables are expanded in arch/$(SRCARCH)/Makefile. h]h)}(hKThe values of the above variables are expanded in arch/$(SRCARCH)/Makefile.h]hKThe values of the above variables are expanded in arch/$(SRCARCH)/Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM2hjubah}(h]h ]h"]h$]h&]uh1jhjubah}(h]h ]h"]h$]h&]jijjuh1jFhhhM2hjqubeh}(h]h ]h"]h$]h&]uh1jhjhhhNhNubj)}(hAll object files are then linked and the resulting file vmlinux is located at the root of the obj tree. The very first objects linked are listed in scripts/head-object-list.txt. h]h)}(hAll object files are then linked and the resulting file vmlinux is located at the root of the obj tree. The very first objects linked are listed in scripts/head-object-list.txt.h]hAll object files are then linked and the resulting file vmlinux is located at the root of the obj tree. The very first objects linked are listed in scripts/head-object-list.txt.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM4hjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubj)}(hFinally, the architecture-specific part does any required post processing and builds the final bootimage. - This includes building boot records - Preparing initrd images and the like h](h)}(hiFinally, the architecture-specific part does any required post processing and builds the final bootimage.h]hiFinally, the architecture-specific part does any required post processing and builds the final bootimage.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM8hjubjG)}(hhh](j)}(h#This includes building boot recordsh]h)}(hjh]h#This includes building boot records}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM;hjubah}(h]h ]h"]h$]h&]uh1jhjubj)}(h%Preparing initrd images and the like h]h)}(h$Preparing initrd images and the likeh]h$Preparing initrd images and the like}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM<hjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]jijjuh1jFhhhM;hjubeh}(h]h ]h"]h$]h&]uh1jhjhhhNhNubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhjhhhhhM'ubh)}(hhh](h)}(h4Set variables to tweak the build to the architectureh]h4Set variables to tweak the build to the architecture}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhM?ubj)}(hhh](j)}(hX<KBUILD_LDFLAGS Generic $(LD) options Flags used for all invocations of the linker. Often specifying the emulation is sufficient. Example:: #arch/s390/Makefile KBUILD_LDFLAGS := -m elf_s390 Note: ldflags-y can be used to further customise the flags used. See `Non-builtin vmlinux targets - extra-y`_. h](j)}(hKBUILD_LDFLAGSh]hKBUILD_LDFLAGS}(hj0hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMMhj,ubj)}(hhh](h)}(hGeneric $(LD) optionsh]hGeneric $(LD) options}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhj>ubh)}(h[Flags used for all invocations of the linker. Often specifying the emulation is sufficient.h]h[Flags used for all invocations of the linker. Often specifying the emulation is sufficient.}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMDhj>ubh)}(h Example::h]hExample:}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj>ubh)}(h9#arch/s390/Makefile KBUILD_LDFLAGS := -m elf_s390h]h9#arch/s390/Makefile KBUILD_LDFLAGS := -m elf_s390}hjksbah}(h]h ]h"]h$]h&]hhuh1hhhhMIhj>ubh)}(hnNote: ldflags-y can be used to further customise the flags used. See `Non-builtin vmlinux targets - extra-y`_.h](hENote: ldflags-y can be used to further customise the flags used. See }(hjyhhhNhNubj)}(h(`Non-builtin vmlinux targets - extra-y`_h]h%Non-builtin vmlinux targets - extra-y}(hjhhhNhNubah}(h]h ]h"]h$]h&]name%Non-builtin vmlinux targets - extra-yjj>uh1jhjyjKubh.}(hjyhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMLhj>ubeh}(h]h ]h"]h$]h&]uh1jhj,ubeh}(h]h ]h"]h$]h&]uh1jhhhMMhj)ubj)}(hXLDFLAGS_vmlinux Options for $(LD) when linking vmlinux LDFLAGS_vmlinux is used to specify additional flags to pass to the linker when linking the final vmlinux image. LDFLAGS_vmlinux uses the LDFLAGS_$@ support. Example:: #arch/x86/Makefile LDFLAGS_vmlinux := -e stext h](j)}(hLDFLAGS_vmlinuxh]hLDFLAGS_vmlinux}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMZhjubj)}(hhh](h)}(h&Options for $(LD) when linking vmlinuxh]h&Options for $(LD) when linking vmlinux}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhjubh)}(hoLDFLAGS_vmlinux is used to specify additional flags to pass to the linker when linking the final vmlinux image.h]hoLDFLAGS_vmlinux is used to specify additional flags to pass to the linker when linking the final vmlinux image.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMRhjubh)}(h,LDFLAGS_vmlinux uses the LDFLAGS_$@ support.h]h,LDFLAGS_vmlinux uses the LDFLAGS_$@ support.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMUhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMWhjubh)}(h.#arch/x86/Makefile LDFLAGS_vmlinux := -e stexth]h.#arch/x86/Makefile LDFLAGS_vmlinux := -e stext}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMYhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMZhj)hhubj)}(hXOBJCOPYFLAGS objcopy flags When $(call if_changed,objcopy) is used to translate a .o file, the flags specified in OBJCOPYFLAGS will be used. $(call if_changed,objcopy) is often used to generate raw binaries on vmlinux. Example:: #arch/s390/Makefile OBJCOPYFLAGS := -O binary #arch/s390/boot/Makefile $(obj)/image: vmlinux FORCE $(call if_changed,objcopy) In this example, the binary $(obj)/image is a binary version of vmlinux. The usage of $(call if_changed,xxx) will be described later. h](j)}(h OBJCOPYFLAGSh]h OBJCOPYFLAGS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMohjubj)}(hhh](h)}(h objcopy flagsh]h objcopy flags}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM]hj ubh)}(hqWhen $(call if_changed,objcopy) is used to translate a .o file, the flags specified in OBJCOPYFLAGS will be used.h]hqWhen $(call if_changed,objcopy) is used to translate a .o file, the flags specified in OBJCOPYFLAGS will be used.}(hj1hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM_hj ubh)}(hM$(call if_changed,objcopy) is often used to generate raw binaries on vmlinux.h]hM$(call if_changed,objcopy) is often used to generate raw binaries on vmlinux.}(hj?hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhj ubh)}(h Example::h]hExample:}(hjMhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMehj ubh)}(h#arch/s390/Makefile OBJCOPYFLAGS := -O binary #arch/s390/boot/Makefile $(obj)/image: vmlinux FORCE $(call if_changed,objcopy)h]h#arch/s390/Makefile OBJCOPYFLAGS := -O binary #arch/s390/boot/Makefile $(obj)/image: vmlinux FORCE $(call if_changed,objcopy)}hj[sbah}(h]h ]h"]h$]h&]hhuh1hhhhMghj ubh)}(hIn this example, the binary $(obj)/image is a binary version of vmlinux. The usage of $(call if_changed,xxx) will be described later.h]hIn this example, the binary $(obj)/image is a binary version of vmlinux. The usage of $(call if_changed,xxx) will be described later.}(hjihhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMnhj ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMohj)hhubj)}(hKBUILD_AFLAGS Assembler flags Default value - see top level Makefile. Append or modify as required per architecture. Example:: #arch/sparc64/Makefile KBUILD_AFLAGS += -m64 -mcpu=ultrasparc h](j)}(h KBUILD_AFLAGSh]h KBUILD_AFLAGS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM{hjubj)}(hhh](h)}(hAssembler flagsh]hAssembler flags}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMrhjubh)}(h'Default value - see top level Makefile.h]h'Default value - see top level Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMthjubh)}(h.Append or modify as required per architecture.h]h.Append or modify as required per architecture.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMvhjubh)}(h Example::h]hExample:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMxhjubh)}(h=#arch/sparc64/Makefile KBUILD_AFLAGS += -m64 -mcpu=ultrasparch]h=#arch/sparc64/Makefile KBUILD_AFLAGS += -m64 -mcpu=ultrasparc}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhMzhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhM{hj)hhubj)}(hXKBUILD_CFLAGS $(CC) compiler flags Default value - see top level Makefile. Append or modify as required per architecture. Often, the KBUILD_CFLAGS variable depends on the configuration. Example:: #arch/x86/boot/compressed/Makefile cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small KBUILD_CFLAGS += $(cflags-y) Many arch Makefiles dynamically run the target C compiler to probe supported options:: #arch/x86/Makefile ... cflags-$(CONFIG_MPENTIUMII) += $(call cc-option,\ -march=pentium2,-march=i686) ... # Disable unit-at-a-time mode ... KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time) ... The first example utilises the trick that a config option expands to "y" when selected. h](j)}(h KBUILD_CFLAGSh]h KBUILD_CFLAGS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(h$(CC) compiler flagsh]h$(CC) compiler flags}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM~hjubh)}(h'Default value - see top level Makefile.h]h'Default value - see top level Makefile.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h.Append or modify as required per architecture.h]h.Append or modify as required per architecture.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h?Often, the KBUILD_CFLAGS variable depends on the configuration.h]h?Often, the KBUILD_CFLAGS variable depends on the configuration.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h Example::h]hExample:}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h#arch/x86/boot/compressed/Makefile cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small KBUILD_CFLAGS += $(cflags-y)h]h#arch/x86/boot/compressed/Makefile cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small KBUILD_CFLAGS += $(cflags-y)}hjEsbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjubh)}(hVMany arch Makefiles dynamically run the target C compiler to probe supported options::h]hUMany arch Makefiles dynamically run the target C compiler to probe supported options:}(hjShhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h#arch/x86/Makefile ... cflags-$(CONFIG_MPENTIUMII) += $(call cc-option,\ -march=pentium2,-march=i686) ... # Disable unit-at-a-time mode ... KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time) ...h]h#arch/x86/Makefile ... cflags-$(CONFIG_MPENTIUMII) += $(call cc-option,\ -march=pentium2,-march=i686) ... # Disable unit-at-a-time mode ... KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time) ...}hjasbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjubh)}(hWThe first example utilises the trick that a config option expands to "y" when selected.h]h[The first example utilises the trick that a config option expands to “y” when selected.}(hjohhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hX<KBUILD_RUSTFLAGS $(RUSTC) compiler flags Default value - see top level Makefile. Append or modify as required per architecture. Often, the KBUILD_RUSTFLAGS variable depends on the configuration. Note that target specification file generation (for ``--target``) is handled in ``scripts/generate_rust_target.rs``. h](j)}(hKBUILD_RUSTFLAGSh]hKBUILD_RUSTFLAGS}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(h$(RUSTC) compiler flagsh]h$(RUSTC) compiler flags}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h'Default value - see top level Makefile.h]h'Default value - see top level Makefile.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h.Append or modify as required per architecture.h]h.Append or modify as required per architecture.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hBOften, the KBUILD_RUSTFLAGS variable depends on the configuration.h]hBOften, the KBUILD_RUSTFLAGS variable depends on the configuration.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(htNote that target specification file generation (for ``--target``) is handled in ``scripts/generate_rust_target.rs``.h](h4Note that target specification file generation (for }(hjhhhNhNubj~)}(h ``--target``h]h--target}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh) is handled in }(hjhhhNhNubj~)}(h#``scripts/generate_rust_target.rs``h]hscripts/generate_rust_target.rs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjubh.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_AFLAGS_KERNEL Assembler options specific for built-in $(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code. h](j)}(hKBUILD_AFLAGS_KERNELh]hKBUILD_AFLAGS_KERNEL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(h'Assembler options specific for built-inh]h'Assembler options specific for built-in}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&ubh)}(h]$(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code.h]h]$(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&ubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_AFLAGS_MODULE Assembler options specific for modules $(KBUILD_AFLAGS_MODULE) is used to add arch-specific options that are used for assembler. From commandline AFLAGS_MODULE shall be used (see kbuild.rst). h](j)}(hKBUILD_AFLAGS_MODULEh]hKBUILD_AFLAGS_MODULE}(hjUhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjQubj)}(hhh](h)}(h&Assembler options specific for modulesh]h&Assembler options specific for modules}(hjfhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(hY$(KBUILD_AFLAGS_MODULE) is used to add arch-specific options that are used for assembler.h]hY$(KBUILD_AFLAGS_MODULE) is used to add arch-specific options that are used for assembler.}(hjthhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubh)}(h>From commandline AFLAGS_MODULE shall be used (see kbuild.rst).h]h>From commandline AFLAGS_MODULE shall be used (see kbuild.rst).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjcubeh}(h]h ]h"]h$]h&]uh1jhjQubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_CFLAGS_KERNEL $(CC) options specific for built-in $(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code. h](j)}(hKBUILD_CFLAGS_KERNELh]hKBUILD_CFLAGS_KERNEL}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(h#$(CC) options specific for built-inh]h#$(CC) options specific for built-in}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h]$(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code.h]h]$(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_CFLAGS_MODULE Options for $(CC) when building modules $(KBUILD_CFLAGS_MODULE) is used to add arch-specific options that are used for $(CC). From commandline CFLAGS_MODULE shall be used (see kbuild.rst). h](j)}(hKBUILD_CFLAGS_MODULEh]hKBUILD_CFLAGS_MODULE}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjubj)}(hhh](h)}(h'Options for $(CC) when building modulesh]h'Options for $(CC) when building modules}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(hU$(KBUILD_CFLAGS_MODULE) is used to add arch-specific options that are used for $(CC).h]hU$(KBUILD_CFLAGS_MODULE) is used to add arch-specific options that are used for $(CC).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubh)}(h>From commandline CFLAGS_MODULE shall be used (see kbuild.rst).h]h>From commandline CFLAGS_MODULE shall be used (see kbuild.rst).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjubeh}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_RUSTFLAGS_KERNEL $(RUSTC) options specific for built-in $(KBUILD_RUSTFLAGS_KERNEL) contains extra Rust compiler flags used to compile resident kernel code. h](j)}(hKBUILD_RUSTFLAGS_KERNELh]hKBUILD_RUSTFLAGS_KERNEL}(hj( hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj$ ubj)}(hhh](h)}(h&$(RUSTC) options specific for built-inh]h&$(RUSTC) options specific for built-in}(hj9 hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj6 ubh)}(hc$(KBUILD_RUSTFLAGS_KERNEL) contains extra Rust compiler flags used to compile resident kernel code.h]hc$(KBUILD_RUSTFLAGS_KERNEL) contains extra Rust compiler flags used to compile resident kernel code.}(hjG hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj6 ubeh}(h]h ]h"]h$]h&]uh1jhj$ ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_RUSTFLAGS_MODULE Options for $(RUSTC) when building modules $(KBUILD_RUSTFLAGS_MODULE) is used to add arch-specific options that are used for $(RUSTC). From commandline RUSTFLAGS_MODULE shall be used (see kbuild.rst). h](j)}(hKBUILD_RUSTFLAGS_MODULEh]hKBUILD_RUSTFLAGS_MODULE}(hje hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhja ubj)}(hhh](h)}(h*Options for $(RUSTC) when building modulesh]h*Options for $(RUSTC) when building modules}(hjv hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjs ubh)}(h[$(KBUILD_RUSTFLAGS_MODULE) is used to add arch-specific options that are used for $(RUSTC).h]h[$(KBUILD_RUSTFLAGS_MODULE) is used to add arch-specific options that are used for $(RUSTC).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjs ubh)}(hAFrom commandline RUSTFLAGS_MODULE shall be used (see kbuild.rst).h]hAFrom commandline RUSTFLAGS_MODULE shall be used (see kbuild.rst).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjs ubeh}(h]h ]h"]h$]h&]uh1jhja ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules $(KBUILD_LDFLAGS_MODULE) is used to add arch-specific options used when linking modules. This is often a linker script. From commandline LDFLAGS_MODULE shall be used (see kbuild.rst). h](j)}(hKBUILD_LDFLAGS_MODULEh]hKBUILD_LDFLAGS_MODULE}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh](h)}(h&Options for $(LD) when linking modulesh]h&Options for $(LD) when linking modules}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(hw$(KBUILD_LDFLAGS_MODULE) is used to add arch-specific options used when linking modules. This is often a linker script.h]hw$(KBUILD_LDFLAGS_MODULE) is used to add arch-specific options used when linking modules. This is often a linker script.}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubh)}(h?From commandline LDFLAGS_MODULE shall be used (see kbuild.rst).h]h?From commandline LDFLAGS_MODULE shall be used (see kbuild.rst).}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj ubeh}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hQKBUILD_LDS The linker script with full path. Assigned by the top-level Makefile. h](j)}(h KBUILD_LDSh]h KBUILD_LDS}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj ubj)}(hhh]h)}(hEThe linker script with full path. Assigned by the top-level Makefile.h]hEThe linker script with full path. Assigned by the top-level Makefile.}(hj !hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj !ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_VMLINUX_OBJS All object files for vmlinux. They are linked to vmlinux in the same order as listed in KBUILD_VMLINUX_OBJS. The objects listed in scripts/head-object-list.txt are exceptions; they are placed before the other objects. h](j)}(hKBUILD_VMLINUX_OBJSh]hKBUILD_VMLINUX_OBJS}(hj*!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj&!ubj)}(hhh](h)}(hlAll object files for vmlinux. They are linked to vmlinux in the same order as listed in KBUILD_VMLINUX_OBJS.h]hlAll object files for vmlinux. They are linked to vmlinux in the same order as listed in KBUILD_VMLINUX_OBJS.}(hj;!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj8!ubh)}(hlThe objects listed in scripts/head-object-list.txt are exceptions; they are placed before the other objects.h]hlThe objects listed in scripts/head-object-list.txt are exceptions; they are placed before the other objects.}(hjI!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj8!ubeh}(h]h ]h"]h$]h&]uh1jhj&!ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubj)}(hKBUILD_VMLINUX_LIBS All .a ``lib`` files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS together specify all the object files used to link vmlinux. h](j)}(hKBUILD_VMLINUX_LIBSh]hKBUILD_VMLINUX_LIBS}(hjg!hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhjc!ubj)}(hhh]h)}(hAll .a ``lib`` files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS together specify all the object files used to link vmlinux.h](hAll .a }(hjx!hhhNhNubj~)}(h``lib``h]hlib}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjx!ubh{ files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS together specify all the object files used to link vmlinux.}(hjx!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhju!ubah}(h]h ]h"]h$]h&]uh1jhjc!ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj)hhubeh}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]4set-variables-to-tweak-the-build-to-the-architectureah ]h"]4set variables to tweak the build to the architectureah$]h&]uh1hhjhhhhhM?ubh)}(hhh](h)}(h Add prerequisites to archheadersh]h Add prerequisites to archheaders}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj!hhhhhMubh)}(hxThe archheaders: rule is used to generate header files that may be installed into user space by ``make header_install``.h](h`The archheaders: rule is used to generate header files that may be installed into user space by }(hj!hhhNhNubj~)}(h``make header_install``h]hmake header_install}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj!ubh.}(hj!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj!hhubh)}(hJIt is run before ``make archprepare`` when run on the architecture itself.h](hIt is run before }(hj!hhhNhNubj~)}(h``make archprepare``h]hmake archprepare}(hj!hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj!ubh% when run on the architecture itself.}(hj!hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj!hhubeh}(h] add-prerequisites-to-archheadersah ]h"] add prerequisites to archheadersah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h Add prerequisites to archprepareh]h Add prerequisites to archprepare}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj "hhhhhMubh)}(hThe archprepare: rule is used to list prerequisites that need to be built before starting to descend down in the subdirectories.h]hThe archprepare: rule is used to list prerequisites that need to be built before starting to descend down in the subdirectories.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj "hhubh)}(hEThis is usually used for header files containing assembler constants.h]hEThis is usually used for header files containing assembler constants.}(hj*"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj "hhubh)}(h Example::h]hExample:}(hj8"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj "hhubh)}(h)#arch/arm/Makefile archprepare: maketoolsh]h)#arch/arm/Makefile archprepare: maketools}hjF"sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj "hhubh)}(hjIn this example, the file target maketools will be processed before descending down in the subdirectories.h]hjIn this example, the file target maketools will be processed before descending down in the subdirectories.}(hjT"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj "hhubh)}(h\See also chapter XXX-TODO that describes how kbuild supports generating offset header files.h]h\See also chapter XXX-TODO that describes how kbuild supports generating offset header files.}(hjb"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj "hhubeh}(h] add-prerequisites-to-archprepareah ]h"] add prerequisites to archprepareah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(h)List directories to visit when descendingh]h)List directories to visit when descending}(hj{"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjx"hhhhhMubh)}(hAn arch Makefile cooperates with the top Makefile to define variables which specify how to build the vmlinux file. Note that there is no corresponding arch-specific section for modules; the module-building machinery is all architecture-independent.h]hAn arch Makefile cooperates with the top Makefile to define variables which specify how to build the vmlinux file. Note that there is no corresponding arch-specific section for modules; the module-building machinery is all architecture-independent.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjx"hhubj)}(hhh]j)}(hXScore-y, libs-y, drivers-y $(libs-y) lists directories where a lib.a archive can be located. The rest list directories where a built-in.a object file can be located. Then the rest follows in this order: $(core-y), $(libs-y), $(drivers-y) The top level Makefile defines values for all generic directories, and arch/$(SRCARCH)/Makefile only adds architecture-specific directories. Example:: # arch/sparc/Makefile core-y += arch/sparc/ libs-y += arch/sparc/prom/ libs-y += arch/sparc/lib/ drivers-$(CONFIG_PM) += arch/sparc/power/ h](j)}(hcore-y, libs-y, drivers-yh]hcore-y, libs-y, drivers-y}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM%hj"ubj)}(hhh](h)}(hA$(libs-y) lists directories where a lib.a archive can be located.h]hA$(libs-y) lists directories where a lib.a archive can be located.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubh)}(hHThe rest list directories where a built-in.a object file can be located.h]hHThe rest list directories where a built-in.a object file can be located.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubh)}(h$Then the rest follows in this order:h]h$Then the rest follows in this order:}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubh block_quote)}(h#$(core-y), $(libs-y), $(drivers-y) h]h)}(h"$(core-y), $(libs-y), $(drivers-y)h]h"$(core-y), $(libs-y), $(drivers-y)}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubah}(h]h ]h"]h$]h&]uh1j"hhhMhj"ubh)}(hThe top level Makefile defines values for all generic directories, and arch/$(SRCARCH)/Makefile only adds architecture-specific directories.h]hThe top level Makefile defines values for all generic directories, and arch/$(SRCARCH)/Makefile only adds architecture-specific directories.}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubh)}(h Example::h]hExample:}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj"ubh)}(h# arch/sparc/Makefile core-y += arch/sparc/ libs-y += arch/sparc/prom/ libs-y += arch/sparc/lib/ drivers-$(CONFIG_PM) += arch/sparc/power/h]h# arch/sparc/Makefile core-y += arch/sparc/ libs-y += arch/sparc/prom/ libs-y += arch/sparc/lib/ drivers-$(CONFIG_PM) += arch/sparc/power/}hj#sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj"ubeh}(h]h ]h"]h$]h&]uh1jhj"ubeh}(h]h ]h"]h$]h&]uh1jhhhM%hj"ubah}(h]h ]h"]h$]h&]uh1jhjx"hhhhhNubeh}(h]jGah ]h"])list directories to visit when descendingah$]h&]uh1hhjhhhhhMjWKubh)}(hhh](h)}(h!Architecture-specific boot imagesh]h!Architecture-specific boot images}(hj9#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj6#hhhhhM(ubh)}(hXAn arch Makefile specifies goals that take the vmlinux file, compress it, wrap it in bootstrapping code, and copy the resulting files somewhere. This includes various kinds of installation commands. The actual goals are not standardized across architectures.h]hXAn arch Makefile specifies goals that take the vmlinux file, compress it, wrap it in bootstrapping code, and copy the resulting files somewhere. This includes various kinds of installation commands. The actual goals are not standardized across architectures.}(hjG#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM*hj6#hhubh)}(h]It is common to locate any additional processing in a boot/ directory below arch/$(SRCARCH)/.h]h]It is common to locate any additional processing in a boot/ directory below arch/$(SRCARCH)/.}(hjU#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM/hj6#hhubh)}(hKbuild does not provide any smart way to support building a target specified in boot/. Therefore arch/$(SRCARCH)/Makefile shall call make manually to build a target in boot/.h]hKbuild does not provide any smart way to support building a target specified in boot/. Therefore arch/$(SRCARCH)/Makefile shall call make manually to build a target in boot/.}(hjc#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM2hj6#hhubh)}(hThe recommended approach is to include shortcuts in arch/$(SRCARCH)/Makefile, and use the full path when calling down into the arch/$(SRCARCH)/boot/Makefile.h]hThe recommended approach is to include shortcuts in arch/$(SRCARCH)/Makefile, and use the full path when calling down into the arch/$(SRCARCH)/boot/Makefile.}(hjq#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM6hj6#hhubh)}(h Example::h]hExample:}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM:hj6#hhubh)}(hi#arch/x86/Makefile boot := arch/x86/boot bzImage: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@h]hi#arch/x86/Makefile boot := arch/x86/boot bzImage: vmlinux $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@}hj#sbah}(h]h ]h"]h$]h&]hhuh1hhhhM<hj6#hhubh)}(hW``$(Q)$(MAKE) $(build)=`` is the recommended way to invoke make in a subdirectory.h](j~)}(h``$(Q)$(MAKE) $(build)=``h]h$(Q)$(MAKE) $(build)=}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj#ubh9 is the recommended way to invoke make in a subdirectory.}(hj#hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMAhj6#hhubh)}(hThere are no rules for naming architecture-specific targets, but executing ``make help`` will list all relevant targets. To support this, $(archhelp) must be defined.h](hKThere are no rules for naming architecture-specific targets, but executing }(hj#hhhNhNubj~)}(h ``make help``h]h make help}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj#ubhN will list all relevant targets. To support this, $(archhelp) must be defined.}(hj#hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMDhj6#hhubh)}(h Example::h]hExample:}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMHhj6#hhubh)}(hs#arch/x86/Makefile define archhelp echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)' endifh]hs#arch/x86/Makefile define archhelp echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)' endif}hj#sbah}(h]h ]h"]h$]h&]hhuh1hhhhMJhj6#hhubh)}(hWhen make is executed without arguments, the first goal encountered will be built. In the top level Makefile the first goal present is all:.h]hWhen make is executed without arguments, the first goal encountered will be built. In the top level Makefile the first goal present is all:.}(hj#hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMOhj6#hhubh)}(hAn architecture shall always, per default, build a bootable image. In ``make help``, the default goal is highlighted with a ``*``.h](hFAn architecture shall always, per default, build a bootable image. In }(hj$hhhNhNubj~)}(h ``make help``h]h make help}(hj $hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj$ubh), the default goal is highlighted with a }(hj$hhhNhNubj~)}(h``*``h]h*}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj$ubh.}(hj$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMShj6#hhubh)}(hOAdd a new prerequisite to all: to select a default goal different from vmlinux.h]hOAdd a new prerequisite to all: to select a default goal different from vmlinux.}(hj3$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMVhj6#hhubh)}(h Example::h]hExample:}(hjA$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMYhj6#hhubh)}(h#arch/x86/Makefile all: bzImageh]h#arch/x86/Makefile all: bzImage}hjO$sbah}(h]h ]h"]h$]h&]hhuh1hhhhM[hj6#hhubh)}(hCWhen ``make`` is executed without arguments, bzImage will be built.h](hWhen }(hj]$hhhNhNubj~)}(h``make``h]hmake}(hje$hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj]$ubh6 is executed without arguments, bzImage will be built.}(hj]$hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM^hj6#hhubeh}(h]!architecture-specific-boot-imagesah ]h"]!architecture-specific boot imagesah$]h&]uh1hhjhhhhhM(ubh)}(hhh](h)}(h)Commands useful for building a boot imageh]h)Commands useful for building a boot image}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj$hhhhhMaubh)}(hHKbuild provides a few macros that are useful when building a boot image.h]hHKbuild provides a few macros that are useful when building a boot image.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMchj$hhubj)}(hhh](j)}(hXld Link target. Often, LDFLAGS_$@ is used to set specific options to ld. Example:: #arch/x86/boot/Makefile LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext targets += setup setup.o bootsect bootsect.o $(obj)/setup $(obj)/bootsect: %: %.o FORCE $(call if_changed,ld) In this example, there are two possible targets, requiring different options to the linker. The linker options are specified using the LDFLAGS_$@ syntax - one for each potential target. $(targets) are assigned all potential targets, by which kbuild knows the targets and will: 1) check for commandline changes 2) delete target during make clean The ``: %: %.o`` part of the prerequisite is a shorthand that frees us from listing the setup.o and bootsect.o files. Note: It is a common mistake to forget the ``targets :=`` assignment, resulting in the target file being recompiled for no obvious reason. h](j)}(hldh]hld}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj$ubj)}(hhh](h)}(hELink target. Often, LDFLAGS_$@ is used to set specific options to ld.h]hELink target. Often, LDFLAGS_$@ is used to set specific options to ld.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghj$ubh)}(h Example::h]hExample:}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMihj$ubh)}(h#arch/x86/boot/Makefile LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext targets += setup setup.o bootsect bootsect.o $(obj)/setup $(obj)/bootsect: %: %.o FORCE $(call if_changed,ld)h]h#arch/x86/boot/Makefile LDFLAGS_bootsect := -Ttext 0x0 -s --oformat binary LDFLAGS_setup := -Ttext 0x0 -s --oformat binary -e begtext targets += setup setup.o bootsect bootsect.o $(obj)/setup $(obj)/bootsect: %: %.o FORCE $(call if_changed,ld)}hj$sbah}(h]h ]h"]h$]h&]hhuh1hhhhMkhj$ubh)}(hIn this example, there are two possible targets, requiring different options to the linker. The linker options are specified using the LDFLAGS_$@ syntax - one for each potential target.h]hIn this example, there are two possible targets, requiring different options to the linker. The linker options are specified using the LDFLAGS_$@ syntax - one for each potential target.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMshj$ubh)}(hZ$(targets) are assigned all potential targets, by which kbuild knows the targets and will:h]hZ$(targets) are assigned all potential targets, by which kbuild knows the targets and will:}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMwhj$ubj)}(hhh](j)}(hcheck for commandline changesh]h)}(hj%h]hcheck for commandline changes}(hj %hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMzhj%ubah}(h]h ]h"]h$]h&]uh1jhj%ubj)}(h delete target during make clean h]h)}(hdelete target during make cleanh]hdelete target during make clean}(hj %hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM{hj%ubah}(h]h ]h"]h$]h&]uh1jhj%ubeh}(h]h ]h"]h$]h&]jjjhjjuh1jhj$ubh)}(huThe ``: %: %.o`` part of the prerequisite is a shorthand that frees us from listing the setup.o and bootsect.o files.h](hThe }(hj:%hhhNhNubj~)}(h ``: %: %.o``h]h: %: %.o}(hjB%hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj:%ubhe part of the prerequisite is a shorthand that frees us from listing the setup.o and bootsect.o files.}(hj:%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhM}hj$ubh)}(hNote: It is a common mistake to forget the ``targets :=`` assignment, resulting in the target file being recompiled for no obvious reason.h](h+Note: It is a common mistake to forget the }(hjZ%hhhNhNubj~)}(h``targets :=``h]h targets :=}(hjb%hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjZ%ubhQ assignment, resulting in the target file being recompiled for no obvious reason.}(hjZ%hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj$ubeh}(h]h ]h"]h$]h&]uh1jhj$ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj$ubj)}(hobjcopy Copy binary. Uses OBJCOPYFLAGS usually specified in arch/$(SRCARCH)/Makefile. OBJCOPYFLAGS_$@ may be used to set additional options. h](j)}(hobjcopyh]hobjcopy}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj%ubj)}(hhh](h)}(hMCopy binary. Uses OBJCOPYFLAGS usually specified in arch/$(SRCARCH)/Makefile.h]hMCopy binary. Uses OBJCOPYFLAGS usually specified in arch/$(SRCARCH)/Makefile.}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj%ubh)}(h6OBJCOPYFLAGS_$@ may be used to set additional options.h]h6OBJCOPYFLAGS_$@ may be used to set additional options.}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj%ubeh}(h]h ]h"]h$]h&]uh1jhj%ubeh}(h]h ]h"]h$]h&]uh1jhhhMhj$hhubj)}(hgzip Compress target. Use maximum compression to compress target. Example:: #arch/x86/boot/compressed/Makefile $(obj)/vmlinux.bin.gz: $(vmlinux.bin.all-y) FORCE $(call if_changed,gzip) h](j)}(hgziph]hgzip}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMhj%ubj)}(hhh](h)}(h ``*lds``.h](h,kbuild knows .lds files and includes a rule }(hj'hhhNhNubj~)}(h ``*lds.S``h]h*lds.S}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj'ubh -> }(hj'hhhNhNubj~)}(h``*lds``h]h*lds}(hj 'hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj'ubh.}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubh)}(h Example::h]hExample:}(hj8'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubh)}(h0#arch/x86/kernel/Makefile extra-y := vmlinux.ldsh]h0#arch/x86/kernel/Makefile extra-y := vmlinux.lds}hjF'sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj&hhubh)}(hQThe assignment to extra-y is used to tell kbuild to build the target vmlinux.lds.h]hQThe assignment to extra-y is used to tell kbuild to build the target vmlinux.lds.}(hjT'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubh)}(hyThe assignment to $(CPPFLAGS_vmlinux.lds) tells kbuild to use the specified options when building the target vmlinux.lds.h]hyThe assignment to $(CPPFLAGS_vmlinux.lds) tells kbuild to use the specified options when building the target vmlinux.lds.}(hjb'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubh)}(h?When building the ``*.lds`` target, kbuild uses the variables::h](hWhen building the }(hjp'hhhNhNubj~)}(h ``*.lds``h]h*.lds}(hjx'hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hjp'ubh# target, kbuild uses the variables:}(hjp'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubh)}(hKBUILD_CPPFLAGS : Set in top-level Makefile cppflags-y : May be set in the kbuild makefile CPPFLAGS_$(@F) : Target-specific flags. Note that the full filename is used in this assignment.h]hKBUILD_CPPFLAGS : Set in top-level Makefile cppflags-y : May be set in the kbuild makefile CPPFLAGS_$(@F) : Target-specific flags. Note that the full filename is used in this assignment.}hj'sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhj&hhubh)}(h\The kbuild infrastructure for ``*lds`` files is used in several architecture-specific files.h](hThe kbuild infrastructure for }(hj'hhhNhNubj~)}(h``*lds``h]h*lds}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj'ubh6 files is used in several architecture-specific files.}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj&hhubeh}(h]preprocessing-linker-scriptsah ]h"]preprocessing linker scriptsah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hGeneric header filesh]hGeneric header files}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj'hhhhhMubh)}(hpThe directory include/asm-generic contains the header files that may be shared between individual architectures.h]hpThe directory include/asm-generic contains the header files that may be shared between individual architectures.}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubh)}(haThe recommended approach how to use a generic header file is to list the file in the Kbuild file.h]haThe recommended approach how to use a generic header file is to list the file in the Kbuild file.}(hj'hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubh)}(h0See `generic-y`_ for further info on syntax etc.h](hSee }(hj'hhhNhNubj)}(h `generic-y`_h]h generic-y}(hj'hhhNhNubah}(h]h ]h"]h$]h&]name generic-yj generic-yuh1jhj'jKubh for further info on syntax etc.}(hj'hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj'hhubeh}(h]generic-header-filesah ]h"]generic header filesah$]h&]uh1hhjhhhhhMubh)}(hhh](h)}(hPost-link passh]hPost-link pass}(hj!(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj(hhhhhMubh)}(hIf the file arch/xxx/Makefile.postlink exists, this makefile will be invoked for post-link objects (vmlinux and modules.ko) for architectures to run post-link passes on. Must also handle the clean target.h]hIf the file arch/xxx/Makefile.postlink exists, this makefile will be invoked for post-link objects (vmlinux and modules.ko) for architectures to run post-link passes on. Must also handle the clean target.}(hj/(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj(hhubh)}(hThis pass runs after kallsyms generation. If the architecture needs to modify symbol locations, rather than manipulate the kallsyms, it may be easier to add another postlink target for .tmp_vmlinux? targets to be called from link-vmlinux.sh.h]hThis pass runs after kallsyms generation. If the architecture needs to modify symbol locations, rather than manipulate the kallsyms, it may be easier to add another postlink target for .tmp_vmlinux? targets to be called from link-vmlinux.sh.}(hj=(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj(hhubh)}(hUFor example, powerpc uses this to check relocation sanity of the linked vmlinux file.h]hUFor example, powerpc uses this to check relocation sanity of the linked vmlinux file.}(hjK(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj(hhubeh}(h]post-link-passah ]h"]post-link passah$]h&]uh1hhjhhhhhMubeh}(h]architecture-makefilesah ]h"]architecture makefilesah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(h"Kbuild syntax for exported headersh]h"Kbuild syntax for exported headers}(hjl(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhji(hhhhhMubh)}(hThe kernel includes a set of headers that is exported to userspace. Many headers can be exported as-is but other headers require a minimal pre-processing before they are ready for user-space.h]hThe kernel includes a set of headers that is exported to userspace. Many headers can be exported as-is but other headers require a minimal pre-processing before they are ready for user-space.}(hjz(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhji(hhubh)}(hThe pre-processing does:h]hThe pre-processing does:}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhji(hhubjG)}(hhh](j)}(h drop kernel-specific annotationsh]h)}(hj(h]h drop kernel-specific annotations}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj(ubah}(h]h ]h"]h$]h&]uh1jhj(hhhhhNubj)}(hdrop include of compiler.hh]h)}(hj(h]hdrop include of compiler.h}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj(ubah}(h]h ]h"]h$]h&]uh1jhj(hhhhhNubj)}(hMdrop all sections that are kernel internal (guarded by ``ifdef __KERNEL__``) h]h)}(hLdrop all sections that are kernel internal (guarded by ``ifdef __KERNEL__``)h](h7drop all sections that are kernel internal (guarded by }(hj(hhhNhNubj~)}(h``ifdef __KERNEL__``h]hifdef __KERNEL__}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj(ubh)}(hj(hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj(ubah}(h]h ]h"]h$]h&]uh1jhj(hhhhhNubeh}(h]h ]h"]h$]h&]jijjuh1jFhhhMhji(hhubh)}(hAll headers under include/uapi/, include/generated/uapi/, arch//include/uapi/ and arch//include/generated/uapi/ are exported.h]hAll headers under include/uapi/, include/generated/uapi/, arch//include/uapi/ and arch//include/generated/uapi/ are exported.}(hj(hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhji(hhubh)}(hA Kbuild file may be defined under arch//include/uapi/asm/ and arch//include/asm/ to list asm files coming from asm-generic.h]hA Kbuild file may be defined under arch//include/uapi/asm/ and arch//include/asm/ to list asm files coming from asm-generic.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhji(hhubh)}(h9See subsequent chapter for the syntax of the Kbuild file.h]h9See subsequent chapter for the syntax of the Kbuild file.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhji(hhubh)}(hhh](h)}(hno-export-headersh]hno-export-headers}(hj$)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj!)hhhhhMubh)}(hno-export-headers is essentially used by include/uapi/linux/Kbuild to avoid exporting specific headers (e.g. kvm.h) on architectures that do not support it. It should be avoided as much as possible.h]hno-export-headers is essentially used by include/uapi/linux/Kbuild to avoid exporting specific headers (e.g. kvm.h) on architectures that do not support it. It should be avoided as much as possible.}(hj2)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj!)hhubeh}(h]no-export-headersah ]h"]no-export-headersah$]h&]uh1hhji(hhhhhMubh)}(hhh](h)}(h generic-yh]h generic-y}(hjK)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjH)hhhhhMubh)}(hIf an architecture uses a verbatim copy of a header from include/asm-generic then this is listed in the file arch/$(SRCARCH)/include/asm/Kbuild like this:h]hIf an architecture uses a verbatim copy of a header from include/asm-generic then this is listed in the file arch/$(SRCARCH)/include/asm/Kbuild like this:}(hjY)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH)hhubh)}(h Example::h]hExample:}(hjg)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH)hhubh)}(hF#arch/x86/include/asm/Kbuild generic-y += termios.h generic-y += rtc.hh]hF#arch/x86/include/asm/Kbuild generic-y += termios.h generic-y += rtc.h}hju)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjH)hhubh)}(h\During the prepare phase of the build a wrapper include file is generated in the directory::h]h[During the prepare phase of the build a wrapper include file is generated in the directory:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM hjH)hhubh)}(h%arch/$(SRCARCH)/include/generated/asmh]h%arch/$(SRCARCH)/include/generated/asm}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjH)hhubh)}(hWhen a header is exported where the architecture uses the generic header a similar wrapper is generated as part of the set of exported headers in the directory::h]hWhen a header is exported where the architecture uses the generic header a similar wrapper is generated as part of the set of exported headers in the directory:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH)hhubh)}(husr/include/asmh]husr/include/asm}hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjH)hhubh)}(hAThe generated wrapper will in both cases look like the following:h]hAThe generated wrapper will in both cases look like the following:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH)hhubh)}(hExample: termios.h::h]hExample: termios.h:}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjH)hhubh)}(h #include h]h #include }hj)sbah}(h]h ]h"]h$]h&]hhuh1hhhhMhjH)hhubeh}(h]j (ah ]h"] generic-yah$]h&]uh1hhji(hhhhhMjWKubh)}(hhh](h)}(h generated-yh]h generated-y}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj)hhhhhMubh)}(hiIf an architecture generates other header files alongside generic-y wrappers, generated-y specifies them.h]hiIf an architecture generates other header files alongside generic-y wrappers, generated-y specifies them.}(hj)hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj)hhubh)}(hKThis prevents them being treated as stale asm-generic wrappers and removed.h]hKThis prevents them being treated as stale asm-generic wrappers and removed.}(hj *hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM"hj)hhubh)}(h Example::h]hExample:}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM%hj)hhubh)}(h9#arch/x86/include/asm/Kbuild generated-y += syscalls_32.hh]h9#arch/x86/include/asm/Kbuild generated-y += syscalls_32.h}hj'*sbah}(h]h ]h"]h$]h&]hhuh1hhhhM'hj)hhubeh}(h] generated-yah ]h"] generated-yah$]h&]uh1hhji(hhhhhMubh)}(hhh](h)}(h mandatory-yh]h mandatory-y}(hj@*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj=*hhhhhM+ubh)}(hmandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild to define the minimum set of ASM headers that all architectures must have.h]hmandatory-y is essentially used by include/(uapi/)asm-generic/Kbuild to define the minimum set of ASM headers that all architectures must have.}(hjN*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM-hj=*hhubh)}(hThis works like optional generic-y. If a mandatory header is missing in arch/$(SRCARCH)/include/(uapi/)/asm, Kbuild will automatically generate a wrapper of the asm-generic one.h]hThis works like optional generic-y. If a mandatory header is missing in arch/$(SRCARCH)/include/(uapi/)/asm, Kbuild will automatically generate a wrapper of the asm-generic one.}(hj\*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM0hj=*hhubeh}(h] mandatory-yah ]h"] mandatory-yah$]h&]uh1hhji(hhhhhM+ubeh}(h]"kbuild-syntax-for-exported-headersah ]h"]"kbuild syntax for exported headersah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hKbuild Variablesh]hKbuild Variables}(hj}*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjz*hhhhhM5ubh)}(h1The top Makefile exports the following variables:h]h1The top Makefile exports the following variables:}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM7hjz*hhubj)}(hhh](j)}(hXVERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION These variables define the current kernel version. A few arch Makefiles actually use these values directly; they should use $(KERNELRELEASE) instead. $(VERSION), $(PATCHLEVEL), and $(SUBLEVEL) define the basic three-part version number, such as "2", "4", and "0". These three values are always numeric. $(EXTRAVERSION) defines an even tinier sublevel for pre-patches or additional patches. It is usually some non-numeric string such as "-pre4", and is often blank. h](j)}(h+VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSIONh]h+VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMDhj*ubj)}(hhh](h)}(hThese variables define the current kernel version. A few arch Makefiles actually use these values directly; they should use $(KERNELRELEASE) instead.h]hThese variables define the current kernel version. A few arch Makefiles actually use these values directly; they should use $(KERNELRELEASE) instead.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM:hj*ubh)}(h$(VERSION), $(PATCHLEVEL), and $(SUBLEVEL) define the basic three-part version number, such as "2", "4", and "0". These three values are always numeric.h]h$(VERSION), $(PATCHLEVEL), and $(SUBLEVEL) define the basic three-part version number, such as “2”, “4”, and “0”. These three values are always numeric.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM>hj*ubh)}(h$(EXTRAVERSION) defines an even tinier sublevel for pre-patches or additional patches. It is usually some non-numeric string such as "-pre4", and is often blank.h]h$(EXTRAVERSION) defines an even tinier sublevel for pre-patches or additional patches. It is usually some non-numeric string such as “-pre4”, and is often blank.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMBhj*ubeh}(h]h ]h"]h$]h&]uh1jhj*ubeh}(h]h ]h"]h$]h&]uh1jhhhMDhj*ubj)}(hKERNELRELEASE $(KERNELRELEASE) is a single string such as "2.4.0-pre4", suitable for constructing installation directory names or showing in version strings. Some arch Makefiles use it for this purpose. h](j)}(h KERNELRELEASEh]h KERNELRELEASE}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMIhj*ubj)}(hhh]h)}(h$(KERNELRELEASE) is a single string such as "2.4.0-pre4", suitable for constructing installation directory names or showing in version strings. Some arch Makefiles use it for this purpose.h]h$(KERNELRELEASE) is a single string such as “2.4.0-pre4”, suitable for constructing installation directory names or showing in version strings. Some arch Makefiles use it for this purpose.}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMGhj*ubah}(h]h ]h"]h$]h&]uh1jhj*ubeh}(h]h ]h"]h$]h&]uh1jhhhMIhj*hhubj)}(hXcARCH This variable defines the target architecture, such as "i386", "arm", or "sparc". Some kbuild Makefiles test $(ARCH) to determine which files to compile. By default, the top Makefile sets $(ARCH) to be the same as the host system architecture. For a cross build, a user may override the value of $(ARCH) on the command line:: make ARCH=m68k ... h](j)}(hARCHh]hARCH}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMThj+ubj)}(hhh](h)}(hThis variable defines the target architecture, such as "i386", "arm", or "sparc". Some kbuild Makefiles test $(ARCH) to determine which files to compile.h]hThis variable defines the target architecture, such as “i386”, “arm”, or “sparc”. Some kbuild Makefiles test $(ARCH) to determine which files to compile.}(hj++hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMLhj(+ubh)}(hBy default, the top Makefile sets $(ARCH) to be the same as the host system architecture. For a cross build, a user may override the value of $(ARCH) on the command line::h]hBy default, the top Makefile sets $(ARCH) to be the same as the host system architecture. For a cross build, a user may override the value of $(ARCH) on the command line:}(hj9+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMPhj(+ubh)}(hmake ARCH=m68k ...h]hmake ARCH=m68k ...}hjG+sbah}(h]h ]h"]h$]h&]hhuh1hhhhMThj(+ubeh}(h]h ]h"]h$]h&]uh1jhj+ubeh}(h]h ]h"]h$]h&]uh1jhhhMThj*hhubj)}(hXqSRCARCH This variable specifies the directory in arch/ to build. ARCH and SRCARCH may not necessarily match. A couple of arch directories are biarch, that is, a single ``arch/*/`` directory supports both 32-bit and 64-bit. For example, you can pass in ARCH=i386, ARCH=x86_64, or ARCH=x86. For all of them, SRCARCH=x86 because arch/x86/ supports both i386 and x86_64. h](j)}(hSRCARCHh]hSRCARCH}(hje+hhhNhNubah}(h]h ]h"]h$ >]h&]uh1jhhhM_hja+ubj)}(hhh](h)}(h8This variable specifies the directory in arch/ to build.h]h8This variable specifies the directory in arch/ to build.}(hjv+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMWhjs+ubh)}(hARCH and SRCARCH may not necessarily match. A couple of arch directories are biarch, that is, a single ``arch/*/`` directory supports both 32-bit and 64-bit.h](hgARCH and SRCARCH may not necessarily match. A couple of arch directories are biarch, that is, a single }(hj+hhhNhNubj~)}(h ``arch/*/``h]harch/*/}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj+ubh+ directory supports both 32-bit and 64-bit.}(hj+hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMYhjs+ubh)}(hFor example, you can pass in ARCH=i386, ARCH=x86_64, or ARCH=x86. For all of them, SRCARCH=x86 because arch/x86/ supports both i386 and x86_64.h]hFor example, you can pass in ARCH=i386, ARCH=x86_64, or ARCH=x86. For all of them, SRCARCH=x86 because arch/x86/ supports both i386 and x86_64.}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhM]hjs+ubeh}(h]h ]h"]h$]h&]uh1jhja+ubeh}(h]h ]h"]h$]h&]uh1jhhhM_hj*hhubj)}(hINSTALL_PATH This variable defines a place for the arch Makefiles to install the resident kernel image and System.map file. Use this for architecture-specific install targets. h](j)}(h INSTALL_PATHh]h INSTALL_PATH}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMdhj+ubj)}(hhh]h)}(hThis variable defines a place for the arch Makefiles to install the resident kernel image and System.map file. Use this for architecture-specific install targets.h]hThis variable defines a place for the arch Makefiles to install the resident kernel image and System.map file. Use this for architecture-specific install targets.}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMbhj+ubah}(h]h ]h"]h$]h&]uh1jhj+ubeh}(h]h ]h"]h$]h&]uh1jhhhMdhj*hhubj)}(hXINSTALL_MOD_PATH, MODLIB $(INSTALL_MOD_PATH) specifies a prefix to $(MODLIB) for module installation. This variable is not defined in the Makefile but may be passed in by the user if desired. $(MODLIB) specifies the directory for module installation. The top Makefile defines $(MODLIB) to $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may override this value on the command line if desired. h](j)}(hINSTALL_MOD_PATH, MODLIBh]hINSTALL_MOD_PATH, MODLIB}(hj+hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMnhj+ubj)}(hhh](h)}(h$(INSTALL_MOD_PATH) specifies a prefix to $(MODLIB) for module installation. This variable is not defined in the Makefile but may be passed in by the user if desired.h]h$(INSTALL_MOD_PATH) specifies a prefix to $(MODLIB) for module installation. This variable is not defined in the Makefile but may be passed in by the user if desired.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMghj+ubh)}(h$(MODLIB) specifies the directory for module installation. The top Makefile defines $(MODLIB) to $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may override this value on the command line if desired.h]h$(MODLIB) specifies the directory for module installation. The top Makefile defines $(MODLIB) to $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE). The user may override this value on the command line if desired.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMkhj+ubeh}(h]h ]h"]h$]h&]uh1jhj+ubeh}(h]h ]h"]h$]h&]uh1jhhhMnhj*hhubj)}(hXINSTALL_MOD_STRIP If this variable is specified, it will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is "1", then the default option --strip-debug will be used. Otherwise, the INSTALL_MOD_STRIP value will be used as the option(s) to the strip command. h](j)}(hINSTALL_MOD_STRIPh]hINSTALL_MOD_STRIP}(hj.,hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhMuhj*,ubj)}(hhh]h)}(hX If this variable is specified, it will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is "1", then the default option --strip-debug will be used. Otherwise, the INSTALL_MOD_STRIP value will be used as the option(s) to the strip command.h]hXIf this variable is specified, it will cause modules to be stripped after they are installed. If INSTALL_MOD_STRIP is “1”, then the default option --strip-debug will be used. Otherwise, the INSTALL_MOD_STRIP value will be used as the option(s) to the strip command.}(hj?,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMqhj<,ubah}(h]h ]h"]h$]h&]uh1jhj*,ubeh}(h]h ]h"]h$]h&]uh1jhhhMuhj*hhubj)}(hX*INSTALL_DTBS_PATH This variable specifies a prefix for relocations required by build roots. It defines a place for installing the device tree blobs. Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed by the user if desired. Otherwise it defaults to the kernel install path. h](j)}(hINSTALL_DTBS_PATHh]hINSTALL_DTBS_PATH}(hj],hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhM|hjY,ubj)}(hhh]h)}(hXThis variable specifies a prefix for relocations required by build roots. It defines a place for installing the device tree blobs. Like INSTALL_MOD_PATH, it isn't defined in the Makefile, but can be passed by the user if desired. Otherwise it defaults to the kernel install path.h]hXThis variable specifies a prefix for relocations required by build roots. It defines a place for installing the device tree blobs. Like INSTALL_MOD_PATH, it isn’t defined in the Makefile, but can be passed by the user if desired. Otherwise it defaults to the kernel install path.}(hjn,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMxhjk,ubah}(h]h ]h"]h$]h&]uh1jhjY,ubeh}(h]h ]h"]h$]h&]uh1jhhhM|hj*hhubeh}(h]h ]h"]h$]h&]uh1jhjz*hhhhhNubeh}(h]kbuild-variablesah ]h"]kbuild variablesah$]h&]uh1hhhhhhhhM5ubh)}(hhh](h)}(hMakefile languageh]hMakefile language}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj,hhhhhMubh)}(hThe kernel Makefiles are designed to be run with GNU Make. The Makefiles use only the documented features of GNU Make, but they do use many GNU extensions.h]hThe kernel Makefiles are designed to be run with GNU Make. The Makefiles use only the documented features of GNU Make, but they do use many GNU extensions.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj,hhubh)}(hGNU Make supports elementary list-processing functions. The kernel Makefiles use a novel style of list building and manipulation with few ``if`` statements.h](hGNU Make supports elementary list-processing functions. The kernel Makefiles use a novel style of list building and manipulation with few }(hj,hhhNhNubj~)}(h``if``h]hif}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj,ubh statements.}(hj,hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj,hhubh)}(hXGGNU Make has two assignment operators, ``:=`` and ``=``. ``:=`` performs immediate evaluation of the right-hand side and stores an actual string into the left-hand side. ``=`` is like a formula definition; it stores the right-hand side in an unevaluated form and then evaluates this form each time the left-hand side is used.h](h'GNU Make has two assignment operators, }(hj,hhhNhNubj~)}(h``:=``h]h:=}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj,ubh and }(hj,hhhNhNubj~)}(h``=``h]h=}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj,ubh. }(hj,hhhNhNubj~)}(h``:=``h]h:=}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj,ubhl performs immediate evaluation of the right-hand side and stores an actual string into the left-hand side. }(hj,hhhNhNubj~)}(h``=``h]h=}(hj-hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj,ubh is like a formula definition; it stores the right-hand side in an unevaluated form and then evaluates this form each time the left-hand side is used.}(hj,hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj,hhubh)}(h^There are some cases where ``=`` is appropriate. Usually, though, ``:=`` is the right choice.h](hThere are some cases where }(hj+-hhhNhNubj~)}(h``=``h]h=}(hj3-hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj+-ubh# is appropriate. Usually, though, }(hj+-hhhNhNubj~)}(h``:=``h]h:=}(hjE-hhhNhNubah}(h]h ]h"]h$]h&]uh1j}hj+-ubh is the right choice.}(hj+-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj,hhubeh}(h]makefile-languageah ]h"]makefile languageah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hCreditsh]hCredits}(hjh-hhhNhNubah}(h]h ]h"]h$]h&]uh1hhje-hhhhhMubjG)}(hhh](j)}(hKOriginal version made by Michael Elizabeth Chastain, h]h)}(hj{-h](h6Original version made by Michael Elizabeth Chastain, <}(hj}-hhhNhNubj)}(hmailto:mec@shout.neth]hmailto:mec@shout.net}(hj-hhhNhNubah}(h]h ]h"]h$]h&]refurij-uh1jhj}-ubh>}(hj}-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjy-ubah}(h]h ]h"]h$]h&]uh1jhjv-hhhhhNubj)}(h9Updates by Kai Germaschewski h]h)}(hj-h](hUpdates by Kai Germaschewski <}(hj-hhhNhNubj)}(hkai@tp1.ruhr-uni-bochum.deh]hkai@tp1.ruhr-uni-bochum.de}(hj-hhhNhNubah}(h]h ]h"]h$]h&]refuri!mailto:kai@tp1.ruhr-uni-bochum.deuh1jhj-ubh>}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-ubah}(h]h ]h"]h$]h&]uh1jhjv-hhhhhNubj)}(h*Updates by Sam Ravnborg h]h)}(hj-h](hUpdates by Sam Ravnborg <}(hj-hhhNhNubj)}(hsam@ravnborg.orgh]hsam@ravnborg.org}(hj-hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:sam@ravnborg.orguh1jhj-ubh>}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-ubah}(h]h ]h"]h$]h&]uh1jhjv-hhhhhNubj)}(h/Language QA by Jan Engelhardt h]h)}(h.Language QA by Jan Engelhardt h](hLanguage QA by Jan Engelhardt <}(hj-hhhNhNubj)}(hjengelh@gmx.deh]hjengelh@gmx.de}(hj.hhhNhNubah}(h]h ]h"]h$]h&]refurimailto:jengelh@gmx.deuh1jhj-ubh>}(hj-hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhj-ubah}(h]h ]h"]h$]h&]uh1jhjv-hhhhhNubeh}(h]h ]h"]h$]h&]jijjuh1jFhhhMhje-hhubeh}(h]creditsah ]h"]creditsah$]h&]uh1hhhhhhhhMubh)}(hhh](h)}(hTODOh]hTODO}(hj6.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj3.hhhhhMubjG)}(hhh](j)}(hGenerating offset header files.h]h)}(hjI.h]hGenerating offset header files.}(hjK.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhjG.ubah}(h]h ]h"]h$]h&]uh1jhjD.hhhhhNubj)}(h&Add more variables to chapters 7 or 9?h]h)}(hj`.h]h&Add more variables to chapters 7 or 9?}(hjb.hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhMhj^.ubah}(h]h ]h"]h$]h&]uh1jhjD.hhhhhNubeh}(h]h ]h"]h$]h&]jijjuh1jFhhhMhj3.hhubeh}(h]todoah ]h"]todoah$]h&]uh1hhhhhhhhMubeh}(h]linux-kernel-makefilesah ]h"]linux kernel makefilesah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj.error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}(goal definitions]ja)list directories to visit when descending]j7a custom rules]j6 a%non-builtin vmlinux targets - extra-y]ja generic-y]j'aurefids}nameids}(j.j.jCj@jj j jjTjjjjjjjj|jyjAj>jjj j jb j_ j j j j jjjLjIjjjjj+j(jjjKjHjjjqjnj6j3j#j j jjjj,j)jHjEjjjjjf(jc(j!j!j"j"ju"jr"j3#jGj$j$j&j&j'j'j(j(j^(j[(jw*jt*jE)jB)j)j (j:*j7*jo*jl*j,j,jb-j_-j0.j-.j.j}.u nametypes}(j.jCjj jTjjjj|jAjj jb j j jjLjjj+jjKjjqj6j#j jj,jHjjjf(j!j"ju"j3#j$j&j'j(j^(jw*jE)j)j:*jo*j,jb-j0.j.uh}(j.hj@hj jFjjjjjjXjjjjjyjj>jjjDj jj_ j j je j j jj jIjjjOjjj(j#jjjHjjjNjnjj3jtj j9jj.jjj)jjEj/jjKjj#jc(jj!jj"j!jr"j "jGjx"j$j6#j&j$j'j&j(j'j[(j(jt*ji(jB)j!)j (jH)j7*j)jl*j=*j,jz*j_-j,j-.je-j}.j3.u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.