€•PŒsphinx.addnodes”Œdocument”“”)�”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)�”}”(hhh]”(hŒ pending_xref”“”)�”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…”�”}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ"/translations/zh_CN/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/zh_TW/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/it_IT/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ja_JP/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/ko_KR/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/pt_BR/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ"/translations/sp_SP/kbuild/modules”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒBuilding External Modules”h]”hŒBuilding External Modules”…”�”}”(hh¼h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhh·h²hh³Œ M=$PWD The kbuild system knows that an external module is being built due to the "M=" option given in the command. To build against the running kernel use:: $ make -C /lib/modules/`uname -r`/build M=$PWD Then to install the module(s) just built, add the target "modules_install" to the command:: $ make -C /lib/modules/`uname -r`/build M=$PWD modules_install Starting from Linux 6.13, you can use the -f option instead of -C. This will avoid unnecessary change of the working directory. The external module will be output to the directory where you invoke make. $ make -f /lib/modules/`uname -r`/build/Makefile M=$PWD ”h]”(hÌ)�”}”(hŒ,The command to build an external module is::”h]”hŒ+The command to build an external module is:”…”�”}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K.hjwubhŒ literal_block”“”)�”}”(hŒ%$ make -C M=$PWD”h]”hŒ%$ make -C M=$PWD”…”�”}”hj‹sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1j‰h³hÊh´K0hjwubhÌ)�”}”(hŒpThe kbuild system knows that an external module is being built due to the "M=" option given in the command.”h]”hŒtThe kbuild system knows that an external module is being built due to the “M=â€� option given in the command.”…”�”}”(hj›h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K2hjwubhÌ)�”}”(hŒ)To build against the running kernel use::”h]”hŒ(To build against the running kernel use:”…”�”}”(hj©h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K5hjwubjŠ)�”}”(hŒ.$ make -C /lib/modules/`uname -r`/build M=$PWD”h]”hŒ.$ make -C /lib/modules/`uname -r`/build M=$PWD”…”�”}”hj·sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´K7hjwubhÌ)�”}”(hŒ[Then to install the module(s) just built, add the target "modules_install" to the command::”h]”hŒ^Then to install the module(s) just built, add the target “modules_installâ€� to the command:”…”�”}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K9hjwubjŠ)�”}”(hŒ>$ make -C /lib/modules/`uname -r`/build M=$PWD modules_install”h]”hŒ>$ make -C /lib/modules/`uname -r`/build M=$PWD modules_install”…”�”}”hjÓsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Khjwubjv)�”}”(hŒ8$ make -f /lib/modules/`uname -r`/build/Makefile M=$PWD ”h]”hÌ)�”}”(hŒ7$ make -f /lib/modules/`uname -r`/build/Makefile M=$PWD”h]”(hŒ$ make -f /lib/modules/”…”�”}”(hjóh²hh³Nh´NubhŒtitle_reference”“”)�”}”(hŒ `uname -r`”h]”hŒuname -r”…”�”}”(hjýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjóubhŒ/build/Makefile M=$PWD”…”�”}”(hjóh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KBhjïubah}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´KBhjwubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K.hjdh²hubeh}”(h]”Œcommand-syntax”ah ]”h"]”Œcommand syntax”ah$]”h&]”uh1hµhj)h²hh³hÊh´K,ubh¶)�”}”(hhh]”(h»)�”}”(hŒOptions”h]”hŒOptions”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj)h²hh³hÊh´KEubjv)�”}”(hXE($KDIR refers to the path of the kernel source directory, or the path of the kernel output directory if the kernel was built in a separate build directory.) You can optionally pass MO= option if you want to build the modules in a separate directory. make -C $KDIR M=$PWD [MO=$BUILD_DIR] -C $KDIR The directory that contains the kernel and relevant build artifacts used for building an external module. "make" will actually change to the specified directory when executing and will change back when finished. M=$PWD Informs kbuild that an external module is being built. The value given to "M" is the absolute path of the directory where the external module (kbuild file) is located. MO=$BUILD_DIR Specifies a separate output directory for the external module. ”h]”(hÌ)�”}”(hŒœ($KDIR refers to the path of the kernel source directory, or the path of the kernel output directory if the kernel was built in a separate build directory.)”h]”hŒœ($KDIR refers to the path of the kernel source directory, or the path of the kernel output directory if the kernel was built in a separate build directory.)”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KGhj:ubhÌ)�”}”(hŒ\You can optionally pass MO= option if you want to build the modules in a separate directory.”h]”hŒ\You can optionally pass MO= option if you want to build the modules in a separate directory.”…”�”}”(hjLh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KKhj:ubhÌ)�”}”(hŒ$make -C $KDIR M=$PWD [MO=$BUILD_DIR]”h]”hŒ$make -C $KDIR M=$PWD [MO=$BUILD_DIR]”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KNhj:ubhŒdefinition_list”“”)�”}”(hhh]”(hŒdefinition_list_item”“”)�”}”(hŒÝ-C $KDIR The directory that contains the kernel and relevant build artifacts used for building an external module. "make" will actually change to the specified directory when executing and will change back when finished. ”h]”(hŒterm”“”)�”}”(hŒ-C $KDIR”h]”hŒ-C $KDIR”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´KThjoubhŒ definition”“”)�”}”(hhh]”hÌ)�”}”(hŒÓThe directory that contains the kernel and relevant build artifacts used for building an external module. "make" will actually change to the specified directory when executing and will change back when finished.”h]”hŒ×The directory that contains the kernel and relevant build artifacts used for building an external module. “makeâ€� will actually change to the specified directory when executing and will change back when finished.”…”�”}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KQhj…ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjoubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´KThjjubjn)�”}”(hŒ¯M=$PWD Informs kbuild that an external module is being built. The value given to "M" is the absolute path of the directory where the external module (kbuild file) is located. ”h]”(jt)�”}”(hŒM=$PWD”h]”hŒM=$PWD”…”�”}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´KZhj¢ubj„)�”}”(hhh]”hÌ)�”}”(hŒ§Informs kbuild that an external module is being built. The value given to "M" is the absolute path of the directory where the external module (kbuild file) is located.”h]”hŒ«Informs kbuild that an external module is being built. The value given to “Mâ€� is the absolute path of the directory where the external module (kbuild file) is located.”…”�”}”(hj·h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KWhj´ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhj¢ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´KZhjjubjn)�”}”(hŒMMO=$BUILD_DIR Specifies a separate output directory for the external module. ”h]”(jt)�”}”(hŒ MO=$BUILD_DIR”h]”hŒ MO=$BUILD_DIR”…”�”}”(hjÕh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´K]hjÑubj„)�”}”(hhh]”hÌ)�”}”(hŒ>Specifies a separate output directory for the external module.”h]”hŒ>Specifies a separate output directory for the external module.”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K]hjãubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjÑubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´K]hjjubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhj:ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´KGhj)h²hubeh}”(h]”Œoptions”ah ]”h"]”Œoptions”ah$]”h&]”uh1hµhj)h²hh³hÊh´KEubh¶)�”}”(hhh]”(h»)�”}”(hŒTargets”h]”hŒTargets”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´K`ubjv)�”}”(hX½When building an external module, only a subset of the "make" targets are available. make -C $KDIR M=$PWD [target] The default will build the module(s) located in the current directory, so a target does not need to be specified. All output files will also be generated in this directory. No attempts are made to update the kernel source, and it is a precondition that a successful "make" has been executed for the kernel. modules The default target for external modules. It has the same functionality as if no target was specified. See description above. modules_install Install the external module(s). The default location is /lib/modules//updates/, but a prefix may be added with INSTALL_MOD_PATH (discussed in section `Module Installation`_). clean Remove all generated files in the module directory only. help List the available targets for external modules. ”h]”(hÌ)�”}”(hŒTWhen building an external module, only a subset of the "make" targets are available.”h]”hŒXWhen building an external module, only a subset of the “makeâ€� targets are available.”…”�”}”(hj)h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kbhj%ubhÌ)�”}”(hŒmake -C $KDIR M=$PWD [target]”h]”hŒmake -C $KDIR M=$PWD [target]”…”�”}”(hj7h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kehj%ubhÌ)�”}”(hX2The default will build the module(s) located in the current directory, so a target does not need to be specified. All output files will also be generated in this directory. No attempts are made to update the kernel source, and it is a precondition that a successful "make" has been executed for the kernel.”h]”hX6The default will build the module(s) located in the current directory, so a target does not need to be specified. All output files will also be generated in this directory. No attempts are made to update the kernel source, and it is a precondition that a successful “makeâ€� has been executed for the kernel.”…”�”}”(hjEh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kghj%ubji)�”}”(hhh]”(jn)�”}”(hŒ…modules The default target for external modules. It has the same functionality as if no target was specified. See description above. ”h]”(jt)�”}”(hŒmodules”h]”hŒmodules”…”�”}”(hjZh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´KqhjVubj„)�”}”(hhh]”hÌ)�”}”(hŒ|The default target for external modules. It has the same functionality as if no target was specified. See description above.”h]”hŒ|The default target for external modules. It has the same functionality as if no target was specified. See description above.”…”�”}”(hjkh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kohjhubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjVubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´KqhjSubjn)�”}”(hŒÏmodules_install Install the external module(s). The default location is /lib/modules//updates/, but a prefix may be added with INSTALL_MOD_PATH (discussed in section `Module Installation`_). ”h]”(jt)�”}”(hŒmodules_install”h]”hŒmodules_install”…”�”}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´Kwhj…ubj„)�”}”(hhh]”hÌ)�”}”(hŒ¾Install the external module(s). The default location is /lib/modules//updates/, but a prefix may be added with INSTALL_MOD_PATH (discussed in section `Module Installation`_).”h]”(hŒ¦Install the external module(s). The default location is /lib/modules//updates/, but a prefix may be added with INSTALL_MOD_PATH (discussed in section ”…”�”}”(hjšh²hh³Nh´Nubj)�”}”(hŒ`Module Installation`_”h]”hŒModule Installation”…”�”}”(hj¢h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”ŒModule Installation”jŒmodule-installation”uh1jhjšjKubhŒ).”…”�”}”(hjšh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Kthj—ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhj…ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´KwhjSubjn)�”}”(hŒ?clean Remove all generated files in the module directory only. ”h]”(jt)�”}”(hŒclean”h]”hŒclean”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´KzhjÉubj„)�”}”(hhh]”hÌ)�”}”(hŒ8Remove all generated files in the module directory only.”h]”hŒ8Remove all generated files in the module directory only.”…”�”}”(hjÞh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KzhjÛubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjÉubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´KzhjSubjn)�”}”(hŒ6help List the available targets for external modules. ”h]”(jt)�”}”(hŒhelp”h]”hŒhelp”…”�”}”(hjüh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´K}hjøubj„)�”}”(hhh]”hÌ)�”}”(hŒ0List the available targets for external modules.”h]”hŒ0List the available targets for external modules.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K}hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjøubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´K}hjSubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhj%ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Kbhjh²hubeh}”(h]”Œtargets”ah ]”h"]”Œtargets”ah$]”h&]”uh1hµhj)h²hh³hÊh´K`ubh¶)�”}”(hhh]”(h»)�”}”(hŒBuilding Separate Files”h]”hŒBuilding Separate Files”…”�”}”(hj>h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj;h²hh³hÊh´K€ubjv)�”}”(hXZIt is possible to build single files that are part of a module. This works equally well for the kernel, a module, and even for external modules. Example (The module foo.ko, consist of bar.o and baz.o):: make -C $KDIR M=$PWD bar.lst make -C $KDIR M=$PWD baz.o make -C $KDIR M=$PWD foo.ko make -C $KDIR M=$PWD ./ ”h]”(hÌ)�”}”(hŒ�It is possible to build single files that are part of a module. This works equally well for the kernel, a module, and even for external modules.”h]”hŒ�It is possible to build single files that are part of a module. This works equally well for the kernel, a module, and even for external modules.”…”�”}”(hjPh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‚hjLubhÌ)�”}”(hŒ9Example (The module foo.ko, consist of bar.o and baz.o)::”h]”hŒ8Example (The module foo.ko, consist of bar.o and baz.o):”…”�”}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K†hjLubjŠ)�”}”(hŒkmake -C $KDIR M=$PWD bar.lst make -C $KDIR M=$PWD baz.o make -C $KDIR M=$PWD foo.ko make -C $KDIR M=$PWD ./”h]”hŒkmake -C $KDIR M=$PWD bar.lst make -C $KDIR M=$PWD baz.o make -C $KDIR M=$PWD foo.ko make -C $KDIR M=$PWD ./”…”�”}”hjlsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´KˆhjLubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K‚hj;h²hubeh}”(h]”Œbuilding-separate-files”ah ]”h"]”Œbuilding separate files”ah$]”h&]”uh1hµhj)h²hh³hÊh´K€ubeh}”(h]”Œhow-to-build-external-modules”ah ]”h"]”Œhow to build external modules”ah$]”h&]”uh1hµhh·h²hh³hÊh´Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ-Creating a Kbuild File for an External Module”h]”hŒ-Creating a Kbuild File for an External Module”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj�h²hh³hÊh´K�ubhÌ)�”}”(hX?In the last section we saw the command to build a module for the running kernel. The module is not actually built, however, because a build file is required. Contained in this file will be the name of the module(s) being built, along with the list of requisite source files. The file may be as simple as a single line::”h]”hX>In the last section we saw the command to build a module for the running kernel. The module is not actually built, however, because a build file is required. Contained in this file will be the name of the module(s) being built, along with the list of requisite source files. The file may be as simple as a single line:”…”�”}”(hj¡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K‘hj�h²hubjŠ)�”}”(hŒobj-m := .o”h]”hŒobj-m := .o”…”�”}”hj¯sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´K—hj�h²hubhÌ)�”}”(hX/The kbuild system will build .o from .c, and, after linking, will result in the kernel module .ko. The above line can be put in either a "Kbuild" file or a "Makefile." When the module is built from multiple sources, an additional line is needed listing the files::”h]”hX6The kbuild system will build .o from .c, and, after linking, will result in the kernel module .ko. The above line can be put in either a “Kbuildâ€� file or a “Makefile.â€� When the module is built from multiple sources, an additional line is needed listing the files:”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K™hj�h²hubjŠ)�”}”(hŒ(-y := .o .o ...”h]”hŒ(-y := .o .o ...”…”�”}”hjËsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´KŸhj�h²hubhÌ)�”}”(hŒrNOTE: Further documentation describing the syntax used by kbuild is located in Documentation/kbuild/makefiles.rst.”h]”hŒrNOTE: Further documentation describing the syntax used by kbuild is located in Documentation/kbuild/makefiles.rst.”…”�”}”(hjÙh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¡hj�h²hubhÌ)�”}”(hŒ{The examples below demonstrate how to create a build file for the module 8123.ko, which is built from the following files::”h]”hŒzThe examples below demonstrate how to create a build file for the module 8123.ko, which is built from the following files:”…”�”}”(hjçh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K¤hj�h²hubjŠ)�”}”(hŒ8123_if.c 8123_if.h 8123_pci.c”h]”hŒ8123_if.c 8123_if.h 8123_pci.c”…”�”}”hjõsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´K§hj�h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒShared Makefile”h]”hŒShared Makefile”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjh²hh³hÊh´K¬ubjv)�”}”(hX7An external module always includes a wrapper makefile that supports building the module using "make" with no arguments. This target is not used by kbuild; it is only for convenience. Additional functionality, such as test targets, can be included but should be filtered out from kbuild due to possible name clashes. Example 1:: --> filename: Makefile ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o else # normal makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD endif The check for KERNELRELEASE is used to separate the two parts of the makefile. In the example, kbuild will only see the two assignments, whereas "make" will see everything except these two assignments. This is due to two passes made on the file: the first pass is by the "make" instance run on the command line; the second pass is by the kbuild system, which is initiated by the parameterized "make" in the default target. ”h]”(hÌ)�”}”(hX;An external module always includes a wrapper makefile that supports building the module using "make" with no arguments. This target is not used by kbuild; it is only for convenience. Additional functionality, such as test targets, can be included but should be filtered out from kbuild due to possible name clashes.”h]”hX?An external module always includes a wrapper makefile that supports building the module using “makeâ€� with no arguments. This target is not used by kbuild; it is only for convenience. Additional functionality, such as test targets, can be included but should be filtered out from kbuild due to possible name clashes.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´K®hjubhÌ)�”}”(hŒ Example 1::”h]”hŒ Example 1:”…”�”}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KµhjubjŠ)�”}”(hŒì--> filename: Makefile ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o else # normal makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD endif”h]”hŒì--> filename: Makefile ifneq ($(KERNELRELEASE),) # kbuild part of makefile obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o else # normal makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD endif”…”�”}”hj4sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´K·hjubhÌ)�”}”(hX¦The check for KERNELRELEASE is used to separate the two parts of the makefile. In the example, kbuild will only see the two assignments, whereas "make" will see everything except these two assignments. This is due to two passes made on the file: the first pass is by the "make" instance run on the command line; the second pass is by the kbuild system, which is initiated by the parameterized "make" in the default target.”h]”hX²The check for KERNELRELEASE is used to separate the two parts of the makefile. In the example, kbuild will only see the two assignments, whereas “makeâ€� will see everything except these two assignments. This is due to two passes made on the file: the first pass is by the “makeâ€� instance run on the command line; the second pass is by the kbuild system, which is initiated by the parameterized “makeâ€� in the default target.”…”�”}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÆhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´K®hjh²hubeh}”(h]”Œshared-makefile”ah ]”h"]”Œshared makefile”ah$]”h&]”uh1hµhj�h²hh³hÊh´K¬ubh¶)�”}”(hhh]”(h»)�”}”(hŒ!Separate Kbuild File and Makefile”h]”hŒ!Separate Kbuild File and Makefile”…”�”}”(hjah²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj^h²hh³hÊh´KÏubjv)�”}”(hXhKbuild will first look for a file named "Kbuild", and if it is not found, it will then look for "Makefile". Utilizing a "Kbuild" file allows us to split up the "Makefile" from example 1 into two files: Example 2:: --> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD The split in example 2 is questionable due to the simplicity of each file; however, some external modules use makefiles consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest. Linux 6.13 and later support another way. The external module Makefile can include the kernel Makefile directly, rather than invoking sub Make. Example 3:: --> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/$(shell uname -r)/build export KBUILD_EXTMOD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) include $(KDIR)/Makefile ”h]”(hÌ)�”}”(hŒÉKbuild will first look for a file named "Kbuild", and if it is not found, it will then look for "Makefile". Utilizing a "Kbuild" file allows us to split up the "Makefile" from example 1 into two files:”h]”hŒÙKbuild will first look for a file named “Kbuildâ€�, and if it is not found, it will then look for “Makefileâ€�. Utilizing a “Kbuildâ€� file allows us to split up the “Makefileâ€� from example 1 into two files:”…”�”}”(hjsh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÑhjoubhÌ)�”}”(hŒ Example 2::”h]”hŒ Example 2:”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KÕhjoubjŠ)�”}”(hŒ¯--> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD”h]”hŒ¯--> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/`uname -r`/build default: $(MAKE) -C $(KDIR) M=$$PWD”…”�”}”hj�sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´K×hjoubhÌ)�”}”(hŒãThe split in example 2 is questionable due to the simplicity of each file; however, some external modules use makefiles consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest.”h]”hŒãThe split in example 2 is questionable due to the simplicity of each file; however, some external modules use makefiles consisting of several hundred lines, and here it really pays off to separate the kbuild part from the rest.”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KáhjoubhÌ)�”}”(hŒ�Linux 6.13 and later support another way. The external module Makefile can include the kernel Makefile directly, rather than invoking sub Make.”h]”hŒ�Linux 6.13 and later support another way. The external module Makefile can include the kernel Makefile directly, rather than invoking sub Make.”…”�”}”(hj«h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KæhjoubhÌ)�”}”(hŒ Example 3::”h]”hŒ Example 3:”…”�”}”(hj¹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KéhjoubjŠ)�”}”(hŒê--> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/$(shell uname -r)/build export KBUILD_EXTMOD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) include $(KDIR)/Makefile”h]”hŒê--> filename: Kbuild obj-m := 8123.o 8123-y := 8123_if.o 8123_pci.o --> filename: Makefile KDIR ?= /lib/modules/$(shell uname -r)/build export KBUILD_EXTMOD := $(realpath $(dir $(lastword $(MAKEFILE_LIST)))) include $(KDIR)/Makefile”…”�”}”hjÇsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Këhjoubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´KÑhj^h²hubeh}”(h]”Œ!separate-kbuild-file-and-makefile”ah ]”h"]”Œ!separate kbuild file and makefile”ah$]”h&]”uh1hµhj�h²hh³hÊh´KÏubh¶)�”}”(hhh]”(h»)�”}”(hŒBuilding Multiple Modules”h]”hŒBuilding Multiple Modules”…”�”}”(hjæh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjãh²hh³hÊh´Köubjv)�”}”(hXkbuild supports building multiple modules with a single build file. For example, if you wanted to build two modules, foo.ko and bar.ko, the kbuild lines would be:: obj-m := foo.o bar.o foo-y := bar-y := It is that simple! ”h]”(hÌ)�”}”(hŒ£kbuild supports building multiple modules with a single build file. For example, if you wanted to build two modules, foo.ko and bar.ko, the kbuild lines would be::”h]”hŒ¢kbuild supports building multiple modules with a single build file. For example, if you wanted to build two modules, foo.ko and bar.ko, the kbuild lines would be:”…”�”}”(hjøh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´KøhjôubjŠ)�”}”(hŒ bar-y := ”h]”hŒ bar-y := ”…”�”}”hjsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´KühjôubhÌ)�”}”(hŒIt is that simple!”h]”hŒIt is that simple!”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjôubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Køhjãh²hubeh}”(h]”Œbuilding-multiple-modules”ah ]”h"]”Œbuilding multiple modules”ah$]”h&]”uh1hµhj�h²hh³hÊh´Köubeh}”(h]”jah ]”h"]”Œ-creating a kbuild file for an external module”ah$]”h&]”uh1hµhh·h²hh³hÊh´K�Œ referenced”Kubh¶)�”}”(hhh]”(h»)�”}”(hŒ Include Files”h]”hŒ Include Files”…”�”}”(hj;h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj8h²hh³hÊh´MubhÌ)�”}”(hŒ_Within the kernel, header files are kept in standard locations according to the following rule:”h]”hŒ_Within the kernel, header files are kept in standard locations according to the following rule:”…”�”}”(hjIh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj8h²hubjv)�”}”(hX&* If the header file only describes the internal interface of a module, then the file is placed in the same directory as the source files. * If the header file describes an interface used by other parts of the kernel that are located in different directories, then the file is placed in include/linux/. NOTE: There are two notable exceptions to this rule: larger subsystems have their own directory under include/, such as include/scsi; and architecture specific headers are located under arch/$(SRCARCH)/include/. ”h]”hŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒˆIf the header file only describes the internal interface of a module, then the file is placed in the same directory as the source files.”h]”hÌ)�”}”(hŒˆIf the header file only describes the internal interface of a module, then the file is placed in the same directory as the source files.”h]”hŒˆIf the header file only describes the internal interface of a module, then the file is placed in the same directory as the source files.”…”�”}”(hjfh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjbubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hj]ubja)�”}”(hX‡If the header file describes an interface used by other parts of the kernel that are located in different directories, then the file is placed in include/linux/. NOTE: There are two notable exceptions to this rule: larger subsystems have their own directory under include/, such as include/scsi; and architecture specific headers are located under arch/$(SRCARCH)/include/. ”h]”(hÌ)�”}”(hŒ¡If the header file describes an interface used by other parts of the kernel that are located in different directories, then the file is placed in include/linux/.”h]”hŒ¡If the header file describes an interface used by other parts of the kernel that are located in different directories, then the file is placed in include/linux/.”…”�”}”(hj~h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M hjzubji)�”}”(hhh]”jn)�”}”(hŒÔNOTE: There are two notable exceptions to this rule: larger subsystems have their own directory under include/, such as include/scsi; and architecture specific headers are located under arch/$(SRCARCH)/include/. ”h]”(jt)�”}”(hŒNOTE:”h]”hŒNOTE:”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´Mhj�ubj„)�”}”(hhh]”hÌ)�”}”(hŒÍThere are two notable exceptions to this rule: larger subsystems have their own directory under include/, such as include/scsi; and architecture specific headers are located under arch/$(SRCARCH)/include/.”h]”hŒÍThere are two notable exceptions to this rule: larger subsystems have their own directory under include/, such as include/scsi; and architecture specific headers are located under arch/$(SRCARCH)/include/.”…”�”}”(hj¤h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhj¡ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhj�ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´MhjŒubah}”(h]”h ]”h"]”h$]”h&]”uh1jhhjzubeh}”(h]”h ]”h"]”h$]”h&]”uh1j`hj]ubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ*”uh1j[h³hÊh´M hjWubah}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M hj8h²hubh¶)�”}”(hhh]”(h»)�”}”(hŒKernel Includes”h]”hŒKernel Includes”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjØh²hh³hÊh´Mubjv)�”}”(hŒºTo include a header file located under include/linux/, simply use:: #include kbuild will add options to the compiler so the relevant directories are searched. ”h]”(hÌ)�”}”(hŒCTo include a header file located under include/linux/, simply use::”h]”hŒBTo include a header file located under include/linux/, simply use:”…”�”}”(hjíh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MhjéubjŠ)�”}”(hŒ#include ”h]”hŒ#include ”…”�”}”hjûsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´MhjéubhÌ)�”}”(hŒQkbuild will add options to the compiler so the relevant directories are searched.”h]”hŒQkbuild will add options to the compiler so the relevant directories are searched.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mhjéubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´MhjØh²hubeh}”(h]”Œkernel-includes”ah ]”h"]”Œkernel includes”ah$]”h&]”uh1hµhj8h²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒSingle Subdirectory”h]”hŒSingle Subdirectory”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj%h²hh³hÊh´M"ubjv)�”}”(hXôExternal modules tend to place header files in a separate include/ directory where their source is located, although this is not the usual kernel style. To inform kbuild of the directory, use either ccflags-y or CFLAGS_.o. Using the example from section 3, if we moved 8123_if.h to a subdirectory named include, the resulting kbuild file would look like:: --> filename: Kbuild obj-m := 8123.o ccflags-y := -I $(src)/include 8123-y := 8123_if.o 8123_pci.o ”h]”(hÌ)�”}”(hŒèExternal modules tend to place header files in a separate include/ directory where their source is located, although this is not the usual kernel style. To inform kbuild of the directory, use either ccflags-y or CFLAGS_.o.”h]”hŒèExternal modules tend to place header files in a separate include/ directory where their source is located, although this is not the usual kernel style. To inform kbuild of the directory, use either ccflags-y or CFLAGS_.o.”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M$hj6ubhÌ)�”}”(hŒ„Using the example from section 3, if we moved 8123_if.h to a subdirectory named include, the resulting kbuild file would look like::”h]”hŒƒUsing the example from section 3, if we moved 8123_if.h to a subdirectory named include, the resulting kbuild file would look like:”…”�”}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M)hj6ubjŠ)�”}”(hŒc--> filename: Kbuild obj-m := 8123.o ccflags-y := -I $(src)/include 8123-y := 8123_if.o 8123_pci.o”h]”hŒc--> filename: Kbuild obj-m := 8123.o ccflags-y := -I $(src)/include 8123-y := 8123_if.o 8123_pci.o”…”�”}”hjVsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´M-hj6ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M$hj%h²hubeh}”(h]”Œsingle-subdirectory”ah ]”h"]”Œsingle subdirectory”ah$]”h&]”uh1hµhj8h²hh³hÊh´M"ubh¶)�”}”(hhh]”(h»)�”}”(hŒSeveral Subdirectories”h]”hŒSeveral Subdirectories”…”�”}”(hjuh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjrh²hh³hÊh´M4ubjv)�”}”(hX•kbuild can handle files that are spread over several directories. Consider the following example:: . |__ src | |__ complex_main.c | |__ hal | |__ hardwareif.c | |__ include | |__ hardwareif.h |__ include |__ complex.h To build the module complex.ko, we then need the following kbuild file:: --> filename: Kbuild obj-m := complex.o complex-y := src/complex_main.o complex-y += src/hal/hardwareif.o ccflags-y := -I$(src)/include ccflags-y += -I$(src)/src/hal/include As you can see, kbuild knows how to handle object files located in other directories. The trick is to specify the directory relative to the kbuild file's location. That being said, this is NOT recommended practice. For the header files, kbuild must be explicitly told where to look. When kbuild executes, the current directory is always the root of the kernel tree (the argument to "-C") and therefore an absolute path is needed. $(src) provides the absolute path by pointing to the directory where the currently executing kbuild file is located. ”h]”(hÌ)�”}”(hŒbkbuild can handle files that are spread over several directories. Consider the following example::”h]”hŒakbuild can handle files that are spread over several directories. Consider the following example:”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M6hjƒubjŠ)�”}”(hŒ˜. |__ src | |__ complex_main.c | |__ hal | |__ hardwareif.c | |__ include | |__ hardwareif.h |__ include |__ complex.h”h]”hŒ˜. |__ src | |__ complex_main.c | |__ hal | |__ hardwareif.c | |__ include | |__ hardwareif.h |__ include |__ complex.h”…”�”}”hj•sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´M9hjƒubhÌ)�”}”(hŒHTo build the module complex.ko, we then need the following kbuild file::”h]”hŒGTo build the module complex.ko, we then need the following kbuild file:”…”�”}”(hj£h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MChjƒubjŠ)�”}”(hŒ®--> filename: Kbuild obj-m := complex.o complex-y := src/complex_main.o complex-y += src/hal/hardwareif.o ccflags-y := -I$(src)/include ccflags-y += -I$(src)/src/hal/include”h]”hŒ®--> filename: Kbuild obj-m := complex.o complex-y := src/complex_main.o complex-y += src/hal/hardwareif.o ccflags-y := -I$(src)/include ccflags-y += -I$(src)/src/hal/include”…”�”}”hj±sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´MFhjƒubhÌ)�”}”(hŒÖAs you can see, kbuild knows how to handle object files located in other directories. The trick is to specify the directory relative to the kbuild file's location. That being said, this is NOT recommended practice.”h]”hŒØAs you can see, kbuild knows how to handle object files located in other directories. The trick is to specify the directory relative to the kbuild file’s location. That being said, this is NOT recommended practice.”…”�”}”(hj¿h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MNhjƒubhÌ)�”}”(hXKFor the header files, kbuild must be explicitly told where to look. When kbuild executes, the current directory is always the root of the kernel tree (the argument to "-C") and therefore an absolute path is needed. $(src) provides the absolute path by pointing to the directory where the currently executing kbuild file is located.”h]”hXOFor the header files, kbuild must be explicitly told where to look. When kbuild executes, the current directory is always the root of the kernel tree (the argument to “-Câ€�) and therefore an absolute path is needed. $(src) provides the absolute path by pointing to the directory where the currently executing kbuild file is located.”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MShjƒubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M6hjrh²hubeh}”(h]”Œseveral-subdirectories”ah ]”h"]”Œseveral subdirectories”ah$]”h&]”uh1hµhj8h²hh³hÊh´M4ubeh}”(h]”Œ include-files”ah ]”h"]”Œ include files”ah$]”h&]”uh1hµhh·h²hh³hÊh´Mubh¶)�”}”(hhh]”(h»)�”}”(hŒModule Installation”h]”hŒModule Installation”…”�”}”(hjôh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjñh²hh³hÊh´M\ubhÌ)�”}”(hŒHModules which are included in the kernel are installed in the directory:”h]”hŒHModules which are included in the kernel are installed in the directory:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M^hjñh²hubjv)�”}”(hŒ&/lib/modules/$(KERNELRELEASE)/kernel/ ”h]”hÌ)�”}”(hŒ%/lib/modules/$(KERNELRELEASE)/kernel/”h]”hŒ%/lib/modules/$(KERNELRELEASE)/kernel/”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mahjubah}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Mahjñh²hubhÌ)�”}”(hŒ&And external modules are installed in:”h]”hŒ&And external modules are installed in:”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mchjñh²hubjv)�”}”(hŒ'/lib/modules/$(KERNELRELEASE)/updates/ ”h]”hÌ)�”}”(hŒ&/lib/modules/$(KERNELRELEASE)/updates/”h]”hŒ&/lib/modules/$(KERNELRELEASE)/updates/”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mehj6ubah}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Mehjñh²hubh¶)�”}”(hhh]”(h»)�”}”(hŒINSTALL_MOD_PATH”h]”hŒINSTALL_MOD_PATH”…”�”}”(hjQh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjNh²hh³hÊh´Mhubjv)�”}”(hXùAbove are the default directories but as always some level of customization is possible. A prefix can be added to the installation path using the variable INSTALL_MOD_PATH:: $ make INSTALL_MOD_PATH=/frodo modules_install => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/ INSTALL_MOD_PATH may be set as an ordinary shell variable or, as shown above, can be specified on the command line when calling "make." This has effect when installing both in-tree and out-of-tree modules. ”h]”(hÌ)�”}”(hŒ­Above are the default directories but as always some level of customization is possible. A prefix can be added to the installation path using the variable INSTALL_MOD_PATH::”h]”hŒ¬Above are the default directories but as always some level of customization is possible. A prefix can be added to the installation path using the variable INSTALL_MOD_PATH:”…”�”}”(hjch²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mjhj_ubjŠ)�”}”(hŒj$ make INSTALL_MOD_PATH=/frodo modules_install => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/”h]”hŒj$ make INSTALL_MOD_PATH=/frodo modules_install => Install dir: /frodo/lib/modules/$(KERNELRELEASE)/kernel/”…”�”}”hjqsbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Mnhj_ubhÌ)�”}”(hŒÍINSTALL_MOD_PATH may be set as an ordinary shell variable or, as shown above, can be specified on the command line when calling "make." This has effect when installing both in-tree and out-of-tree modules.”h]”hŒÑINSTALL_MOD_PATH may be set as an ordinary shell variable or, as shown above, can be specified on the command line when calling “make.â€� This has effect when installing both in-tree and out-of-tree modules.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mqhj_ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´MjhjNh²hubeh}”(h]”Œinstall-mod-path”ah ]”h"]”Œinstall_mod_path”ah$]”h&]”uh1hµhjñh²hh³hÊh´Mhubh¶)�”}”(hhh]”(h»)�”}”(hŒINSTALL_MOD_DIR”h]”hŒINSTALL_MOD_DIR”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj›h²hh³hÊh´Mwubjv)�”}”(hX®External modules are by default installed to a directory under /lib/modules/$(KERNELRELEASE)/updates/, but you may wish to locate modules for a specific functionality in a separate directory. For this purpose, use INSTALL_MOD_DIR to specify an alternative name to "updates.":: $ make INSTALL_MOD_DIR=gandalf -C $KDIR \ M=$PWD modules_install => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/ ”h]”(hÌ)�”}”(hXExternal modules are by default installed to a directory under /lib/modules/$(KERNELRELEASE)/updates/, but you may wish to locate modules for a specific functionality in a separate directory. For this purpose, use INSTALL_MOD_DIR to specify an alternative name to "updates."::”h]”hXExternal modules are by default installed to a directory under /lib/modules/$(KERNELRELEASE)/updates/, but you may wish to locate modules for a specific functionality in a separate directory. For this purpose, use INSTALL_MOD_DIR to specify an alternative name to “updates.â€�:”…”�”}”(hj°h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Myhj¬ubjŠ)�”}”(hŒ~$ make INSTALL_MOD_DIR=gandalf -C $KDIR \ M=$PWD modules_install => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/”h]”hŒ~$ make INSTALL_MOD_DIR=gandalf -C $KDIR \ M=$PWD modules_install => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf/”…”�”}”hj¾sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Mhj¬ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´Myhj›h²hubeh}”(h]”Œinstall-mod-dir”ah ]”h"]”Œinstall_mod_dir”ah$]”h&]”uh1hµhjñh²hh³hÊh´Mwubeh}”(h]”j²ah ]”h"]”Œmodule installation”ah$]”h&]”uh1hµhh·h²hh³hÊh´M\j7Kubh¶)�”}”(hhh]”(h»)�”}”(hŒModule Versioning”h]”hŒModule Versioning”…”�”}”(hjäh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjáh²hh³hÊh´M…ubhÌ)�”}”(hXbModule versioning is enabled by the CONFIG_MODVERSIONS tag, and is used as a simple ABI consistency check. A CRC value of the full prototype for an exported symbol is created. When a module is loaded/used, the CRC values contained in the kernel are compared with similar values in the module; if they are not equal, the kernel refuses to load the module.”h]”hXbModule versioning is enabled by the CONFIG_MODVERSIONS tag, and is used as a simple ABI consistency check. A CRC value of the full prototype for an exported symbol is created. When a module is loaded/used, the CRC values contained in the kernel are compared with similar values in the module; if they are not equal, the kernel refuses to load the module.”…”�”}”(hjòh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M‡hjáh²hubhÌ)�”}”(hŒKModule.symvers contains a list of all exported symbols from a kernel build.”h]”hŒKModule.symvers contains a list of all exported symbols from a kernel build.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŽhjáh²hubh¶)�”}”(hhh]”(h»)�”}”(hŒ+Symbols From the Kernel (vmlinux + modules)”h]”hŒ+Symbols From the Kernel (vmlinux + modules)”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´M’ubjv)�”}”(hX2During a kernel build, a file named Module.symvers will be generated. Module.symvers contains all exported symbols from the kernel and compiled modules. For each symbol, the corresponding CRC value is also stored. The syntax of the Module.symvers file is:: 0xe1cc2a05 usb_stor_suspend drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL USB_STORAGE The fields are separated by tabs and values may be empty (e.g. if no namespace is defined for an exported symbol). For a kernel build without CONFIG_MODVERSIONS enabled, the CRC would read 0x00000000. Module.symvers serves two purposes: 1) It lists all exported symbols from vmlinux and all modules. 2) It lists the CRC if CONFIG_MODVERSIONS is enabled. ”h]”(hÌ)�”}”(hŒÕDuring a kernel build, a file named Module.symvers will be generated. Module.symvers contains all exported symbols from the kernel and compiled modules. For each symbol, the corresponding CRC value is also stored.”h]”hŒÕDuring a kernel build, a file named Module.symvers will be generated. Module.symvers contains all exported symbols from the kernel and compiled modules. For each symbol, the corresponding CRC value is also stored.”…”�”}”(hj# h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M”hj ubhÌ)�”}”(hŒ*The syntax of the Module.symvers file is::”h]”hŒ)The syntax of the Module.symvers file is:”…”�”}”(hj1 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M™hj ubjŠ)�”}”(hŒ¸ 0xe1cc2a05 usb_stor_suspend drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL USB_STORAGE”h]”hŒ¸ 0xe1cc2a05 usb_stor_suspend drivers/usb/storage/usb-storage EXPORT_SYMBOL_GPL USB_STORAGE”…”�”}”hj? sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´M›hj ubhÌ)�”}”(hŒrThe fields are separated by tabs and values may be empty (e.g. if no namespace is defined for an exported symbol).”h]”hŒrThe fields are separated by tabs and values may be empty (e.g. if no namespace is defined for an exported symbol).”…”�”}”(hjM h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MŸhj ubhÌ)�”}”(hŒUFor a kernel build without CONFIG_MODVERSIONS enabled, the CRC would read 0x00000000.”h]”hŒUFor a kernel build without CONFIG_MODVERSIONS enabled, the CRC would read 0x00000000.”…”�”}”(hj[ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¢hj ubhÌ)�”}”(hŒ#Module.symvers serves two purposes:”h]”hŒ#Module.symvers serves two purposes:”…”�”}”(hji h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¥hj ubhŒenumerated_list”“”)�”}”(hhh]”(ja)�”}”(hŒ;It lists all exported symbols from vmlinux and all modules.”h]”hÌ)�”}”(hj~ h]”hŒ;It lists all exported symbols from vmlinux and all modules.”…”�”}”(hj€ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M§hj| ubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjy ubja)�”}”(hŒ3It lists the CRC if CONFIG_MODVERSIONS is enabled. ”h]”hÌ)�”}”(hŒ2It lists the CRC if CONFIG_MODVERSIONS is enabled.”h]”hŒ2It lists the CRC if CONFIG_MODVERSIONS is enabled.”…”�”}”(hj— h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¨hj“ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j`hjy ubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ)”uh1jw hj ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M”hj h²hubeh}”(h]”Œ'symbols-from-the-kernel-vmlinux-modules”ah ]”h"]”Œ+symbols from the kernel (vmlinux + modules)”ah$]”h&]”uh1hµhjáh²hh³hÊh´M’ubh¶)�”}”(hhh]”(h»)�”}”(hŒVersion Information Formats”h]”hŒVersion Information Formats”…”�”}”(hjÇ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjÄ h²hh³hÊh´M«ubjv)�”}”(hX�Exported symbols have information stored in the __ksymtab and __kflagstab sections. Symbol names and namespaces are stored in __ksymtab_strings section, using a format similar to the string table used for ELF. If CONFIG_MODVERSIONS is enabled, the CRCs corresponding to exported symbols will be added to the __kcrctab section. If CONFIG_BASIC_MODVERSIONS is enabled (default with CONFIG_MODVERSIONS), imported symbols will have their symbol name and CRC stored in the __versions section of the importing module. This mode only supports symbols of length up to 64 bytes. If CONFIG_EXTENDED_MODVERSIONS is enabled (required to enable both CONFIG_MODVERSIONS and CONFIG_RUST at the same time), imported symbols will have their symbol name recorded in the __version_ext_names section as a series of concatenated, null-terminated strings. CRCs for these symbols will be recorded in the __version_ext_crcs section. ”h]”(hÌ)�”}”(hXFExported symbols have information stored in the __ksymtab and __kflagstab sections. Symbol names and namespaces are stored in __ksymtab_strings section, using a format similar to the string table used for ELF. If CONFIG_MODVERSIONS is enabled, the CRCs corresponding to exported symbols will be added to the __kcrctab section.”h]”hXFExported symbols have information stored in the __ksymtab and __kflagstab sections. Symbol names and namespaces are stored in __ksymtab_strings section, using a format similar to the string table used for ELF. If CONFIG_MODVERSIONS is enabled, the CRCs corresponding to exported symbols will be added to the __kcrctab section.”…”�”}”(hjÙ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M­hjÕ ubhÌ)�”}”(hŒòIf CONFIG_BASIC_MODVERSIONS is enabled (default with CONFIG_MODVERSIONS), imported symbols will have their symbol name and CRC stored in the __versions section of the importing module. This mode only supports symbols of length up to 64 bytes.”h]”hŒòIf CONFIG_BASIC_MODVERSIONS is enabled (default with CONFIG_MODVERSIONS), imported symbols will have their symbol name and CRC stored in the __versions section of the importing module. This mode only supports symbols of length up to 64 bytes.”…”�”}”(hjç h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M´hjÕ ubhÌ)�”}”(hXRIf CONFIG_EXTENDED_MODVERSIONS is enabled (required to enable both CONFIG_MODVERSIONS and CONFIG_RUST at the same time), imported symbols will have their symbol name recorded in the __version_ext_names section as a series of concatenated, null-terminated strings. CRCs for these symbols will be recorded in the __version_ext_crcs section.”h]”hXRIf CONFIG_EXTENDED_MODVERSIONS is enabled (required to enable both CONFIG_MODVERSIONS and CONFIG_RUST at the same time), imported symbols will have their symbol name recorded in the __version_ext_names section as a series of concatenated, null-terminated strings. CRCs for these symbols will be recorded in the __version_ext_crcs section.”…”�”}”(hjõ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´M¹hjÕ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´M­hjÄ h²hubeh}”(h]”Œversion-information-formats”ah ]”h"]”Œversion information formats”ah$]”h&]”uh1hµhjáh²hh³hÊh´M«ubh¶)�”}”(hhh]”(h»)�”}”(hŒSymbols and External Modules”h]”hŒSymbols and External Modules”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhj h²hh³hÊh´MÀubjv)�”}”(hX€When building an external module, the build system needs access to the symbols from the kernel to check if all external symbols are defined. This is done in the MODPOST step. modpost obtains the symbols by reading Module.symvers from the kernel source tree. During the MODPOST step, a new Module.symvers file will be written containing all exported symbols from that external module. ”h]”hÌ)�”}”(hXWhen building an external module, the build system needs access to the symbols from the kernel to check if all external symbols are defined. This is done in the MODPOST step. modpost obtains the symbols by reading Module.symvers from the kernel source tree. During the MODPOST step, a new Module.symvers file will be written containing all exported symbols from that external module.”h]”hXWhen building an external module, the build system needs access to the symbols from the kernel to check if all external symbols are defined. This is done in the MODPOST step. modpost obtains the symbols by reading Module.symvers from the kernel source tree. During the MODPOST step, a new Module.symvers file will be written containing all exported symbols from that external module.”…”�”}”(hj& h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÂhj" ubah}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´MÂhj h²hubeh}”(h]”Œsymbols-and-external-modules”ah ]”h"]”Œsymbols and external modules”ah$]”h&]”uh1hµhjáh²hh³hÊh´MÀubh¶)�”}”(hhh]”(h»)�”}”(hŒ$Symbols From Another External Module”h]”hŒ$Symbols From Another External Module”…”�”}”(hjE h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjB h²hh³hÊh´MÊubjv)�”}”(hXFSometimes, an external module uses exported symbols from another external module. Kbuild needs to have full knowledge of all symbols to avoid spitting out warnings about undefined symbols. Two solutions exist for this situation. NOTE: The method with a top-level kbuild file is recommended but may be impractical in certain situations. Use a top-level kbuild file If you have two modules, foo.ko and bar.ko, where foo.ko needs symbols from bar.ko, you can use a common top-level kbuild file so both modules are compiled in the same build. Consider the following directory layout:: ./foo/ <= contains foo.ko ./bar/ <= contains bar.ko The top-level kbuild file would then look like:: #./Kbuild (or ./Makefile): obj-m := foo/ bar/ And executing:: $ make -C $KDIR M=$PWD will then do the expected and compile both modules with full knowledge of symbols from either module. Use "make" variable KBUILD_EXTRA_SYMBOLS If it is impractical to add a top-level kbuild file, you can assign a space separated list of files to KBUILD_EXTRA_SYMBOLS in your build file. These files will be loaded by modpost during the initialization of its symbol tables. ”h]”(hÌ)�”}”(hŒäSometimes, an external module uses exported symbols from another external module. Kbuild needs to have full knowledge of all symbols to avoid spitting out warnings about undefined symbols. Two solutions exist for this situation.”h]”hŒäSometimes, an external module uses exported symbols from another external module. Kbuild needs to have full knowledge of all symbols to avoid spitting out warnings about undefined symbols. Two solutions exist for this situation.”…”�”}”(hjW h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÌhjS ubhÌ)�”}”(hŒjNOTE: The method with a top-level kbuild file is recommended but may be impractical in certain situations.”h]”hŒjNOTE: The method with a top-level kbuild file is recommended but may be impractical in certain situations.”…”�”}”(hje h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÑhjS ubji)�”}”(hhh]”(jn)�”}”(hXKUse a top-level kbuild file If you have two modules, foo.ko and bar.ko, where foo.ko needs symbols from bar.ko, you can use a common top-level kbuild file so both modules are compiled in the same build. Consider the following directory layout:: ./foo/ <= contains foo.ko ./bar/ <= contains bar.ko The top-level kbuild file would then look like:: #./Kbuild (or ./Makefile): obj-m := foo/ bar/ And executing:: $ make -C $KDIR M=$PWD will then do the expected and compile both modules with full knowledge of symbols from either module. ”h]”(jt)�”}”(hŒUse a top-level kbuild file”h]”hŒUse a top-level kbuild file”…”�”}”(hjz h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´Mèhjv ubj„)�”}”(hhh]”(hÌ)�”}”(hŒØIf you have two modules, foo.ko and bar.ko, where foo.ko needs symbols from bar.ko, you can use a common top-level kbuild file so both modules are compiled in the same build. Consider the following directory layout::”h]”hŒ×If you have two modules, foo.ko and bar.ko, where foo.ko needs symbols from bar.ko, you can use a common top-level kbuild file so both modules are compiled in the same build. Consider the following directory layout:”…”�”}”(hj‹ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÕhjˆ ubjŠ)�”}”(hŒ3./foo/ <= contains foo.ko ./bar/ <= contains bar.ko”h]”hŒ3./foo/ <= contains foo.ko ./bar/ <= contains bar.ko”…”�”}”hj™ sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´MÛhjˆ ubhÌ)�”}”(hŒ0The top-level kbuild file would then look like::”h]”hŒ/The top-level kbuild file would then look like:”…”�”}”(hj§ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´MÞhjˆ ubjŠ)�”}”(hŒ5#./Kbuild (or ./Makefile): obj-m := foo/ bar/”h]”hŒ5#./Kbuild (or ./Makefile): obj-m := foo/ bar/”…”�”}”hjµ sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Màhjˆ ubhÌ)�”}”(hŒAnd executing::”h]”hŒAnd executing:”…”�”}”(hjà h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mãhjˆ ubjŠ)�”}”(hŒ$ make -C $KDIR M=$PWD”h]”hŒ$ make -C $KDIR M=$PWD”…”�”}”hjÑ sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Måhjˆ ubhÌ)�”}”(hŒewill then do the expected and compile both modules with full knowledge of symbols from either module.”h]”hŒewill then do the expected and compile both modules with full knowledge of symbols from either module.”…”�”}”(hjß h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mçhjˆ ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjv ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´Mèhjs ubjn)�”}”(hXUse "make" variable KBUILD_EXTRA_SYMBOLS If it is impractical to add a top-level kbuild file, you can assign a space separated list of files to KBUILD_EXTRA_SYMBOLS in your build file. These files will be loaded by modpost during the initialization of its symbol tables. ”•mh]”(jt)�”}”(hŒ(Use "make" variable KBUILD_EXTRA_SYMBOLS”h]”hŒ,Use “makeâ€� variable KBUILD_EXTRA_SYMBOLS”…”�”}”(hjý h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jsh³hÊh´Mðhjù ubj„)�”}”(hhh]”hÌ)�”}”(hŒåIf it is impractical to add a top-level kbuild file, you can assign a space separated list of files to KBUILD_EXTRA_SYMBOLS in your build file. These files will be loaded by modpost during the initialization of its symbol tables.”h]”hŒåIf it is impractical to add a top-level kbuild file, you can assign a space separated list of files to KBUILD_EXTRA_SYMBOLS in your build file. These files will be loaded by modpost during the initialization of its symbol tables.”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Mëhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jƒhjù ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jmh³hÊh´Mðhjs ubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhhjS ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´MÌhjB h²hubeh}”(h]”Œ$symbols-from-another-external-module”ah ]”h"]”Œ$symbols from another external module”ah$]”h&]”uh1hµhjáh²hh³hÊh´MÊubeh}”(h]”Œmodule-versioning”ah ]”h"]”Œmodule versioning”ah$]”h&]”uh1hµhh·h²hh³hÊh´M…ubh¶)�”}”(hhh]”(h»)�”}”(hŒ Tips & Tricks”h]”hŒ Tips & Tricks”…”�”}”(hjG h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjD h²hh³hÊh´Móubh¶)�”}”(hhh]”(h»)�”}”(hŒTesting for CONFIG_FOO_BAR”h]”hŒTesting for CONFIG_FOO_BAR”…”�”}”(hjX h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hºhjU h²hh³hÊh´Möubjv)�”}”(hXZModules often need to check for certain `CONFIG_` options to decide if a specific feature is included in the module. In kbuild this is done by referencing the `CONFIG_` variable directly:: #fs/ext2/Makefile obj-$(CONFIG_EXT2_FS) += ext2.o ext2-y := balloc.o bitmap.o dir.o ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o”h]”(hÌ)�”}”(hŒ¼Modules often need to check for certain `CONFIG_` options to decide if a specific feature is included in the module. In kbuild this is done by referencing the `CONFIG_` variable directly::”h]”(hŒ(Modules often need to check for certain ”…”�”}”(hjj h²hh³Nh´Nubjü)�”}”(hŒ `CONFIG_`”h]”hŒCONFIG_”…”�”}”(hjr h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjj ubhŒn options to decide if a specific feature is included in the module. In kbuild this is done by referencing the ”…”�”}”(hjj h²hh³Nh´Nubjü)�”}”(hŒ `CONFIG_`”h]”hŒCONFIG_”…”�”}”(hj„ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jûhjj ubhŒ variable directly:”…”�”}”(hjj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hËh³hÊh´Møhjf ubjŠ)�”}”(hŒ|#fs/ext2/Makefile obj-$(CONFIG_EXT2_FS) += ext2.o ext2-y := balloc.o bitmap.o dir.o ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o”h]”hŒ|#fs/ext2/Makefile obj-$(CONFIG_EXT2_FS) += ext2.o ext2-y := balloc.o bitmap.o dir.o ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o”…”�”}”hjœ sbah}”(h]”h ]”h"]”h$]”h&]”j™jšuh1j‰h³hÊh´Mýhjf ubeh}”(h]”h ]”h"]”h$]”h&]”uh1juh³hÊh´MøhjU h²hubeh}”(h]”Œtesting-for-config-foo-bar”ah ]”h"]”Œtesting for config_foo_bar”ah$]”h&]”uh1hµhjD h²hh³hÊh´Möubeh}”(h]”Œ tips-tricks”ah ]”h"]”Œ tips & tricks”ah$]”h&]”uh1hµhh·h²hh³hÊh´Móubeh}”(h]”Œbuilding-external-modules”ah ]”h"]”Œbuilding external modules”ah$]”h&]”uh1hµhhh²hh³hÊh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÊuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hºNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jë Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÊŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”(Œ-creating a kbuild file for an external module”]”jaŒmodule installation”]”j¢auŒrefids”}”Œnameids”}”(jÅ j j&j#j�jŠj&j#jjj8j5j…j‚j4jj[jXjàjÝj-j*jîjëj"jjojljæjãjÞj²j˜j•j×jÔjA j> jÁ j¾ j j j? j< j9 j6 j½ jº jµ j² uŒ nametypes”}”(jÅ ‰j&‰j�‰j&‰j‰j8‰j…‰j4‰j[‰jà‰j-‰jî‰j"‰jo‰jæ‰jÞ‰j˜‰j׉jA ‰jÁ ‰j ‰j? ‰j9 ‰j½ ‰jµ ‰uh}”(j h·j#hÛjŠj)j#jdjj)j5jj‚j;jj�jXjjÝj^j*jãjëj8jjØjlj%jãjrj²jñj•jNjÔj›j> jáj¾ j j jÄ j< j j6 jB jº jD j² jU uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.