From de322c651d10a9a822e4872e5111a6446e5b2cb8 Mon Sep 17 00:00:00 2001 From: wangxg13 Date: Wed, 2 Dec 2015 03:25:59 -0500 Subject: [PATCH 1/2] Add the file of kbuild/kbuild.txt to kbuild.md. Signed-off-by: wangxg13 --- en/kbuild/kbuild.md | 235 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 en/kbuild/kbuild.md diff --git a/en/kbuild/kbuild.md b/en/kbuild/kbuild.md new file mode 100644 index 0000000..02ffd59 --- /dev/null +++ b/en/kbuild/kbuild.md @@ -0,0 +1,235 @@ +#Output files# + +modules.order +-------------------------------------------------- +This file records the order in which modules appear in Makefiles. This +is used by modprobe to deterministically resolve aliases that match +multiple modules. + +modules.builtin +-------------------------------------------------- +This file lists all modules that are built into the kernel. This is used +by modprobe to not fail when trying to load something builtin. + + +Environment variables + +KCPPFLAGS +-------------------------------------------------- +Additional options to pass when preprocessing. The preprocessing options +will be used in all cases where kbuild does preprocessing including +building C files and assembler files. + +KAFLAGS +-------------------------------------------------- +Additional options to the assembler (for built-in and modules). + +AFLAGS_MODULE +-------------------------------------------------- +Additional module specific options to use for $(AS). + +AFLAGS_KERNEL +-------------------------------------------------- +Additional options for $(AS) when used for assembler +code for code that is compiled as built-in. + +KCFLAGS +-------------------------------------------------- +Additional options to the C compiler (for built-in and modules). + +CFLAGS_KERNEL +-------------------------------------------------- +Additional options for $(CC) when used to compile +code that is compiled as built-in. + +CFLAGS_MODULE +-------------------------------------------------- +Additional module specific options to use for $(CC). + +LDFLAGS_MODULE +-------------------------------------------------- +Additional options used for $(LD) when linking modules. + +LDFLAGS_vmlinux +-------------------------------------------------- +Additional options passed to final link of vmlinux. + +KBUILD_VERBOSE +-------------------------------------------------- +Set the kbuild verbosity. Can be assigned same values as "V=...". +See make help for the full list. +Setting "V=..." takes precedence over KBUILD_VERBOSE. + +KBUILD_EXTMOD +-------------------------------------------------- +Set the directory to look for the kernel source when building external +modules. +The directory can be specified in several ways: +1) Use "M=..." on the command line +2) Environment variable KBUILD_EXTMOD +3) Environment variable SUBDIRS +The possibilities are listed in the order they take precedence. +Using "M=..." will always override the others. + +KBUILD_OUTPUT +-------------------------------------------------- +Specify the output directory when building the kernel. +The output directory can also be specified using "O=...". +Setting "O=..." takes precedence over KBUILD_OUTPUT. + +KBUILD_DEBARCH +-------------------------------------------------- +For the deb-pkg target, allows overriding the normal heuristics deployed by +deb-pkg. Normally deb-pkg attempts to guess the right architecture based on +the UTS_MACHINE variable, and on some architectures also the kernel config. +The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian +architecture. + +ARCH +-------------------------------------------------- +Set ARCH to the architecture to be built. +In most cases the name of the architecture is the same as the +directory name found in the arch/ directory. +But some architectures such as x86 and sparc have aliases. +x86: i386 for 32 bit, x86_64 for 64 bit +sparc: sparc for 32 bit, sparc64 for 64 bit + +CROSS_COMPILE +-------------------------------------------------- +Specify an optional fixed part of the binutils filename. +CROSS_COMPILE can be a part of the filename or the full path. + +CROSS_COMPILE is also used for ccache in some setups. + +CF +-------------------------------------------------- +Additional options for sparse. +CF is often used on the command-line like this: + + make CF=-Wbitwise C=2 + +INSTALL_PATH +-------------------------------------------------- +INSTALL_PATH specifies where to place the updated kernel and system map +images. Default is /boot, but you can set it to other values. + +INSTALLKERNEL +-------------------------------------------------- +Install script called when using "make install". +The default name is "installkernel". + +The script will be called with the following arguments: + $1 - kernel version + $2 - kernel image file + $3 - kernel map file + $4 - default install path (use root directory if blank) + +The implementation of "make install" is architecture specific +and it may differ from the above. + +INSTALLKERNEL is provided to enable the possibility to +specify a custom installer when cross compiling a kernel. + +MODLIB +-------------------------------------------------- +Specify where to install modules. +The default value is: + + $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) + +The value can be overridden in which case the default value is ignored. + +INSTALL_MOD_PATH +-------------------------------------------------- +INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory +relocations required by build roots. This is not defined in the +makefile but the argument can be passed to make if needed. + +INSTALL_MOD_STRIP +-------------------------------------------------- +INSTALL_MOD_STRIP, if defined, 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, +INSTALL_MOD_STRIP value will be used as the options to the strip command. + +INSTALL_FW_PATH +-------------------------------------------------- +INSTALL_FW_PATH specifies where to install the firmware blobs. +The default value is: + + $(INSTALL_MOD_PATH)/lib/firmware + +The value can be overridden in which case the default value is ignored. + +INSTALL_HDR_PATH +-------------------------------------------------- +INSTALL_HDR_PATH specifies where to install user space headers when +executing "make headers_*". +The default value is: + + $(objtree)/usr + +$(objtree) is the directory where output files are saved. +The output directory is often set using "O=..." on the commandline. + +The value can be overridden in which case the default value is ignored. + +KBUILD_MODPOST_WARN +-------------------------------------------------- +KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined +symbols in the final module linking stage. It changes such errors +into warnings. + +KBUILD_MODPOST_NOFINAL +-------------------------------------------------- +KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules. +This is solely useful to speed up test compiles. + +KBUILD_EXTRA_SYMBOLS +-------------------------------------------------- +For modules that use symbols from other modules. +See more details in modules.txt. + +ALLSOURCE_ARCHS +-------------------------------------------------- +For tags/TAGS/cscope targets, you can specify more than one arch +to be included in the databases, separated by blank space. E.g.: + + $ make ALLSOURCE_ARCHS="x86 mips arm" tags + +To get all available archs you can also specify all. E.g.: + + $ make ALLSOURCE_ARCHS=all tags + +KBUILD_ENABLE_EXTRA_GCC_CHECKS +-------------------------------------------------- +If enabled over the make command line with "W=1", it turns on additional +gcc -W... options for more extensive build-time checking. + +KBUILD_BUILD_TIMESTAMP +-------------------------------------------------- +Setting this to a date string overrides the timestamp used in the +UTS_VERSION definition (uname -v in the running kernel). The value has to +be a string that can be passed to date -d. The default value +is the output of the date command at one point during build. + +KBUILD_BUILD_USER, KBUILD_BUILD_HOST +-------------------------------------------------- +These two variables allow to override the user@host string displayed during +boot and in /proc/version. The default value is the output of the commands +whoami and host, respectively. + +KBUILD_LDS +-------------------------------------------------- +The linker script with full path. Assigned by the top-level Makefile. + +KBUILD_VMLINUX_INIT +-------------------------------------------------- +All object files for the init (first) part of vmlinux. +Files specified with KBUILD_VMLINUX_INIT are linked first. + +KBUILD_VMLINUX_MAIN +-------------------------------------------------- +All object files for the main part of vmlinux. +KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify +all the object files used to link vmlinux. From 3f0a78176fc9d8c647b618fad0528ea594d32bcd Mon Sep 17 00:00:00 2001 From: wangxg13 Date: Wed, 2 Dec 2015 06:37:21 -0500 Subject: [PATCH 2/2] Translate the kbuild.txt, and checked by myself. Signed-off-by: wangxg13 --- zh-cn/kbuild/kbuild.md | 216 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 zh-cn/kbuild/kbuild.md diff --git a/zh-cn/kbuild/kbuild.md b/zh-cn/kbuild/kbuild.md new file mode 100644 index 0000000..df6fb4a --- /dev/null +++ b/zh-cn/kbuild/kbuild.md @@ -0,0 +1,216 @@ +原文:Documentation/kbuild/kbuild.txt + +翻译:@huddy1985 + +校订: + +#Output files# + +modules.order +-------------------------------------------------- +这个文件记录了在 Makefile 中 modules 出现的顺序。modprobe 使用该选项来解决在加载多个模块具有相同的别名问题。 + +modules.buildin +-------------------------------------------------- +这个文件列出了所有被编译到内核的模块。当加载内建模块的时候被modprobe用来避免失败。 + + +#Environment variables# + +KCPPFLAGS +-------------------------------------------------- +预编译的时候用来传递额外选项。这些预编译的选项被所有的 kbuild 预编译使用,包括 C 文件和汇编文件。 + +KAFLAGS +-------------------------------------------------- +该标志为汇编传递额外选项(对内建函数或变量和模块都适用)。 + +AFLAGS_MODULE +-------------------------------------------------- +在 $(AS) 中使用的特定模块中使用的特定选项。 + +AFLAGS_KERNEL +-------------------------------------------------- +当汇编代码使用 $(AS) 来编译时候,并且该汇编作为内建的函数或者变量时候,该标志用来传递额外选项。 + +KCFLAGS +-------------------------------------------------- +该标志表示为 C 编译器传递额外的选项(包括内建函数变量和模块)。 + +CFLAGS_KERNEL +-------------------------------------------------- +当编译为内建函数或者变量的时候,该标志用来传递额外的选项给 $(CC)。 + +CFLAGS_MODULE +-------------------------------------------------- +该标志被 $(CC) 用来传递额外模块的特定选项。 + +LDFLAGS_MODULE +-------------------------------------------------- +当链接模块的时候,该标志用来传递额外的选项给 $(LD) 。 + +LDFLAGS_vmlinux +-------------------------------------------------- +为最终链接的 vmlinux 传递额外的选项。 + +KBUILD_VERBOSE +-------------------------------------------------- +设置 kbuild verbosity 。该选项可以通过指定与 “V=...” 相同的值。查看 make help 来查看整个列表。设置 “V=...” 的方法要早于使用 KBUILD_VERSION。 + +KBUILD_EXTMOD +-------------------------------------------------- +当编译外部模块的时候,用来设置寻找内核源代码的目录。 +指定目录的方法主要有以下几种: + + 1) 通过在命令行中使用 “M=...”来设置 + + 2) 使用环境变量KBUILD_EXTMOD; + + 3) 使用环境变量SUBDIRS; + +使用上列选项依据他们的优先级来选择。 +使用 “M=...” 会覆盖其他选项。 + +KBUILD_OUTPUT +-------------------------------------------------- +指定内核编译时的输出目录。指定方法是使用 “O=...” 。在使用 KBUILD_OUTPUT 变量之前必须先设置 “O=...” 。 + +KBUILD_DEBARCH +-------------------------------------------------- +对于 deb-pkg 的目标,允许覆盖被 deb-pkg 正常部署的启发性配置。 +正常情况下, deb-pkg 试图根据 UTS\_MACHINE 来猜测正确的体系结构, +或者根据内核编译时候提供的 .config 文件来指定正确的架构。 +KBUILD\_DEBARCH的值被设置为一个合法的Debian体系结构,通常是假定的值,但是不会去验证这个值。 + +ARCH +-------------------------------------------------- +该变量用来指定编译的体系结构。大多数情况下这个体系结构的名称与 arch/ 下的目录名是一致的。 +但是有些体系结构,例如 x86 和 sparc 都有别名。 + +x86: i386 指定32位体系结构。x86_64 指定 64 的 x86 体系结构 + +sparc: sparc 对应32位的体系结构, sparc64 指的是64位。 + +CROSS_COMPILE +-------------------------------------------------- +指定可选的 binutils 工具集名称的固定部分。 +可以是文件名的一部分也可以是全路径。 +也可以在一些安装中被用来 ccache 。 + +CF +-------------------------------------------------- +sparse 的附加项。 +CF 通常在命令行下使用: + + make CF=Wbitwise C=2 + +INSTALL_PATH +-------------------------------------------------- +指定存放更新的内核和系统映像的路径。 +默认情况下,是放在 /boot 目录中,但是你也可以设定其他地址。 + +INSTALLKERNEL +-------------------------------------------------- +该选项是当键入 “make install” 的时候调用的脚本。默认名称为“installkernel”。 +使用以下的参数调用该脚本: + + $1 - 内核版本 + + $2 - 内核镜像文件 + + $3 - 内核映射文件 + + $4 - 默认安装路径 (如果为空,就是root目录) + +“make install”的执行特定于架构,所以可能与上边不一致。 +INSTALLKERNEL 提供了一种选择,当交叉编译内核的时候,指定用户定制的安装程序。 + +MODLIB +-------------------------------------------------- +指定安装模块的存储位置。默认是: + + $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) + +默认值如果被忽略的话,那么该值就会被覆盖。 + +INSTALL_MOD_PATH +-------------------------------------------------- +INSTALL\_MOD\_PATH 指定了M ODLIB 存储位置的前缀。该值在 makefile 中并没有被定义,但是如果需要的话, +该参数可以被传递给 make 命令。 + +INSTALL_MOD_STRIP +-------------------------------------------------- +INSTALL\_MOD\_STRIP 如果被定义,这些模块被安装后会移除不需要的信息(如 debug 信息)。 +如果 INSTALL\_MOD\_STRIP = ‘1’, 默认的选项 --strip-debug 将被使用。否则的话,INSTALL\_MOD\_STRIP 将作为 strip 命令 +的选项。 + +INSTALL_FW_PATH +-------------------------------------------------- +INSTALL_FW_PATH 指定在何处安装固件。 +默认地址是: + + $(INSTALL_MOD_PATH)/lib/firmware + +默认值如果被忽略的话,那么该值就会被覆盖。 + +INSTALL_HDR_PATH +-------------------------------------------------- +INSTALL\_HDR\_PATH 指定安装用户空间头文件的存储位置。 +默认是: + + $(objtree)/usr + +$(objtree) 是保存输出文件的目录。输出文件通常通过命令中执行 “O=...” 来设置。 +默认值如果被忽略的话,那么该值就会被覆盖。 + +KBUILD_MODPOST_WARN +-------------------------------------------------- +KBUILD\_MODPOST\_WARN 如果被设置,那么可以避免在最后模块链接阶段出现未定义符号的错误。 +它能把这种错误改变为警告。 + +KBUILD_MODPOST_NOFINAL +-------------------------------------------------- +KBUILD\_MODPOST\_NOFINAL 如果被设置的话,可以用来跳过最后的模块链接。这样做的主要作用是加快测试时的编译速度。 + +KBUILD_EXTRA_SYMBOLS +-------------------------------------------------- +针对调用别的模块符号的模块。 +详情请看 modules.txt + +ALLSOURCE_ARCHS +-------------------------------------------------- +针对 tags/TAGS/cscope 目录下的目标,你可以从数据库中指定至少一种架构,多种之间通过 “ ” 来分开。 +例如: + + + $ make ALLSOURCE_ARCHS="x86 mips arm" tags + +为了得到所有可用架构,你可以指定所有架构。 +例如: + + $ make ALLSOURCE_ARCHS=all tags + +KBUILD_ENABLE_EXTRA_GCC_CHECKS +-------------------------------------------------- +如果在编译命令行中输入 “W=1” ,这个环境变量能使gcc打开附加的选项 “gcc -W ...”,以作更多的扩展编译时检查。 + +KBUILD_BUILD_TIMESTAMP +-------------------------------------------------- +通过给 KBUILD\_BUILD\_TIMESTAMP 环境变量设置一个时间字符串(代表系统版本)覆盖掉通过 UTS_VERSION 定义的版本 +(通过 uname -v显示的系统版本)。这个值可以通过 date -d 来传递。默认值是在编译的那一刻, date 命令的输出 + +KBUILD_BUILD_USER, KBUILD\_BUILD\_HOST +-------------------------------------------------- +这两个参数允许覆盖在 boot 阶段和 /proc/version 显示的 user@host 字符串。默认分别是 whoami 和 host的输出。 + +KBUILD_LDS +-------------------------------------------------- +链接脚本的全路径名。该值通过顶层的 Makefile 传递进来。 + +KBUILD_VMLINUX_INIT +-------------------------------------------------- +所有针对 vmlinux 的 init 部分的文件。被 KBUILD\_VMLINUX\_INIT 指定的文件会被优先链接。 + +KBUILD_VMLINUX_MAIN +-------------------------------------------------- +所有针对 vmlinux 的 main 部分的文件。 KBUILD\_VMLINUX\_INIT 和 KBUILD\_VMLINUX\_MAIN 一起用来指定所有被链接到 mlinux 的文件。