← Documents Documentation/kbuild/kbuild.rst GitHub 원문 ↗

Linux 6.18.37 · Kbuild

Kbuild

Kbuild output metadata와 compiler·linker·directory·install·diagnostic·identity environment variable을 정의합니다.

Source pathDocumentation/kbuild/kbuild.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

kbuild.rst:1-343

Kbuild의 환경 변수는 target·host·user compile flag, kernel과 external module output, installation root, warning·signing·modpost, tag database와 build identity를 세밀하게 제어합니다. Command-line의 `V/M/O/MO/W` assignment가 대응 environment variable보다 우선합니다.

자주 혼동되는 경로
목적VariableCommand line
Kernel output`KBUILD_OUTPUT``O=...`
External module source`KBUILD_EXTMOD``M=...`
External module output`KBUILD_EXTMOD_OUTPUT``MO=...`
Module install root`INSTALL_MOD_PATH`make argument
UAPI header install root`INSTALL_HDR_PATH`make argument

Kernel, external module, 설치 destination을 분리해 지정합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ======
2 Kbuild
3 ======
4
5
6 Output files
7 ============
8
9 modules.order
10 -------------
11 This file records the order in which modules appear in Makefiles. This
12 is used by modprobe to deterministically resolve aliases that match
13 multiple modules.
14
15 modules.builtin
16 ---------------
17 This file lists all modules that are built into the kernel. This is used
18 by modprobe to not fail when trying to load something builtin.
19
20 modules.builtin.modinfo
21 -----------------------
22 This file contains modinfo from all modules that are built into the kernel.
23 Unlike modinfo of a separate module, all fields are prefixed with module name.
24
25 modules.builtin.ranges
26 ----------------------
27 This file contains address offset ranges (per ELF section) for all modules
28 that are built into the kernel. Together with System.map, it can be used
29 to associate module names with symbols.
30
31 Environment variables
32 =====================
33
34 KCPPFLAGS
35 ---------
36 Additional options to pass when preprocessing. The preprocessing options
37 will be used in all cases where kbuild does preprocessing including
38 building C files and assembler files.
39
40 KAFLAGS
41 -------
42 Additional options to the assembler (for built-in and modules).
43
44 AFLAGS_MODULE
45 -------------
46 Additional assembler options for modules.
47
48 AFLAGS_KERNEL
49 -------------
50 Additional assembler options for built-in.
51
52 KCFLAGS
53 -------
54 Additional options to the C compiler (for built-in and modules).
55
56 KRUSTFLAGS
57 ----------
58 Additional options to the Rust compiler (for built-in and modules).
59
60 CFLAGS_KERNEL
61 -------------
62 Additional options for $(CC) when used to compile
63 code that is compiled as built-in.
64
65 CFLAGS_MODULE
66 -------------
67 Additional module specific options to use for $(CC).
68
69 RUSTFLAGS_KERNEL
70 ----------------
71 Additional options for $(RUSTC) when used to compile
72 code that is compiled as built-in.
73
74 RUSTFLAGS_MODULE
75 ----------------
76 Additional module specific options to use for $(RUSTC).
77
78 LDFLAGS_MODULE
79 --------------
80 Additional options used for $(LD) when linking modules.
81
82 HOSTCFLAGS
83 ----------
84 Additional flags to be passed to $(HOSTCC) when building host programs.
85
86 HOSTCXXFLAGS
87 ------------
88 Additional flags to be passed to $(HOSTCXX) when building host programs.
89
90 HOSTRUSTFLAGS
91 -------------
92 Additional flags to be passed to $(HOSTRUSTC) when building host programs.
93
94 PROCMACROLDFLAGS
95 ----------------
96 Flags to be passed when linking Rust proc macros. Since proc macros are loaded
97 by rustc at build time, they must be linked in a way that is compatible with
98 the rustc toolchain being used.
99
100 For instance, it can be useful when rustc uses a different C library than
101 the one the user wants to use for host programs.
102
103 If unset, it defaults to the flags passed when linking host programs.
104
105 HOSTLDFLAGS
106 -----------
107 Additional flags to be passed when linking host programs.
108
109 HOSTLDLIBS
110 ----------
111 Additional libraries to link against when building host programs.
112
113 .. _userkbuildflags:
114
115 USERCFLAGS
116 ----------
117 Additional options used for $(CC) when compiling userprogs.
118
119 USERLDFLAGS
120 -----------
121 Additional options used for $(LD) when linking userprogs. userprogs are linked
122 with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.
123
124 KBUILD_KCONFIG
125 --------------
126 Set the top-level Kconfig file to the value of this environment
127 variable. The default name is "Kconfig".
128
129 KBUILD_VERBOSE
130 --------------
131 Set the kbuild verbosity. Can be assigned same values as "V=...".
132
133 See make help for the full list.
134
135 Setting "V=..." takes precedence over KBUILD_VERBOSE.
136
137 KBUILD_EXTMOD
138 -------------
139 Set the directory to look for the kernel source when building external
140 modules.
141
142 Setting "M=..." takes precedence over KBUILD_EXTMOD.
143
144 KBUILD_OUTPUT
145 -------------
146 Specify the output directory when building the kernel.
147
148 This variable can also be used to point to the kernel output directory when
149 building external modules against a pre-built kernel in a separate build
150 directory. Please note that this does NOT specify the output directory for the
151 external modules themselves. (Use KBUILD_EXTMOD_OUTPUT for that purpose.)
152
153 The output directory can also be specified using "O=...".
154
155 Setting "O=..." takes precedence over KBUILD_OUTPUT.
156
157 KBUILD_EXTMOD_OUTPUT
158 --------------------
159 Specify the output directory for external modules.
160
161 Setting "MO=..." takes precedence over KBUILD_EXTMOD_OUTPUT.
162
163 KBUILD_EXTRA_WARN
164 -----------------
165 Specify the extra build checks. The same value can be assigned by passing
166 W=... from the command line.
167
168 See `make help` for the list of the supported values.
169
170 Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.
171
172 KBUILD_DEBARCH
173 --------------
174 For the deb-pkg target, allows overriding the normal heuristics deployed by
175 deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
176 the UTS_MACHINE variable, and on some architectures also the kernel config.
177 The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
178 architecture.
179
180 KDOCFLAGS
181 ---------
182 Specify extra (warning/error) flags for kernel-doc checks during the build,
183 see scripts/kernel-doc for which flags are supported. Note that this doesn't
184 (currently) apply to documentation builds.
185
186 ARCH
187 ----
188 Set ARCH to the architecture to be built.
189
190 In most cases the name of the architecture is the same as the
191 directory name found in the arch/ directory.
192
193 But some architectures such as x86 and sparc have aliases.
194
195 - x86: i386 for 32 bit, x86_64 for 64 bit
196 - parisc: parisc64 for 64 bit
197 - sparc: sparc32 for 32 bit, sparc64 for 64 bit
198
199 CROSS_COMPILE
200 -------------
201 Specify an optional fixed part of the binutils filename.
202 CROSS_COMPILE can be a part of the filename or the full path.
203
204 CROSS_COMPILE is also used for ccache in some setups.
205
206 CF
207 --
208 Additional options for sparse.
209
210 CF is often used on the command-line like this::
211
212 make CF=-Wbitwise C=2
213
214 INSTALL_PATH
215 ------------
216 INSTALL_PATH specifies where to place the updated kernel and system map
217 images. Default is /boot, but you can set it to other values.
218
219 INSTALLKERNEL
220 -------------
221 Install script called when using "make install".
222 The default name is "installkernel".
223
224 The script will be called with the following arguments:
225
226 - $1 - kernel version
227 - $2 - kernel image file
228 - $3 - kernel map file
229 - $4 - default install path (use root directory if blank)
230
231 The implementation of "make install" is architecture specific
232 and it may differ from the above.
233
234 INSTALLKERNEL is provided to enable the possibility to
235 specify a custom installer when cross compiling a kernel.
236
237 MODLIB
238 ------
239 Specify where to install modules.
240 The default value is::
241
242 $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
243
244 The value can be overridden in which case the default value is ignored.
245
246 INSTALL_MOD_PATH
247 ----------------
248 INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
249 relocations required by build roots. This is not defined in the
250 makefile but the argument can be passed to make if needed.
251
252 INSTALL_MOD_STRIP
253 -----------------
254 INSTALL_MOD_STRIP, if defined, will cause modules to be
255 stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
256 the default option --strip-debug will be used. Otherwise,
257 INSTALL_MOD_STRIP value will be used as the options to the strip command.
258
259 INSTALL_HDR_PATH
260 ----------------
261 INSTALL_HDR_PATH specifies where to install user space headers when
262 executing "make headers_*".
263
264 The default value is::
265
266 $(objtree)/usr
267
268 $(objtree) is the directory where output files are saved.
269 The output directory is often set using "O=..." on the commandline.
270
271 The value can be overridden in which case the default value is ignored.
272
273 INSTALL_DTBS_PATH
274 -----------------
275 INSTALL_DTBS_PATH specifies where to install device tree blobs for
276 relocations required by build roots. This is not defined in the
277 makefile but the argument can be passed to make if needed.
278
279 KBUILD_ABS_SRCTREE
280 --------------------------------------------------
281 Kbuild uses a relative path to point to the tree when possible. For instance,
282 when building in the source tree, the source tree path is '.'
283
284 Setting this flag requests Kbuild to use absolute path to the source tree.
285 There are some useful cases to do so, like when generating tag files with
286 absolute path entries etc.
287
288 KBUILD_SIGN_PIN
289 ---------------
290 This variable allows a passphrase or PIN to be passed to the sign-file
291 utility when signing kernel modules, if the private key requires such.
292
293 KBUILD_MODPOST_WARN
294 -------------------
295 KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
296 symbols in the final module linking stage. It changes such errors
297 into warnings.
298
299 KBUILD_MODPOST_NOFINAL
300 ----------------------
301 KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
302 This is solely useful to speed up test compiles.
303
304 KBUILD_EXTRA_SYMBOLS
305 --------------------
306 For modules that use symbols from other modules.
307 See more details in modules.rst.
308
309 ALLSOURCE_ARCHS
310 ---------------
311 For tags/TAGS/cscope targets, you can specify more than one arch
312 to be included in the databases, separated by blank space. E.g.::
313
314 $ make ALLSOURCE_ARCHS="x86 mips arm" tags
315
316 To get all available archs you can also specify all. E.g.::
317
318 $ make ALLSOURCE_ARCHS=all tags
319
320 IGNORE_DIRS
321 -----------
322 For tags/TAGS/cscope targets, you can choose which directories won't
323 be included in the databases, separated by blank space. E.g.::
324
325 $ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope
326
327 KBUILD_BUILD_TIMESTAMP
328 ----------------------
329 Setting this to a date string overrides the timestamp used in the
330 UTS_VERSION definition (uname -v in the running kernel). The value has to
331 be a string that can be passed to date -d. The default value
332 is the output of the date command at one point during build.
333
334 KBUILD_BUILD_USER, KBUILD_BUILD_HOST
335 ------------------------------------
336 These two variables allow to override the user@host string displayed during
337 boot and in /proc/version. The default value is the output of the commands
338 whoami and host, respectively.
339
340 LLVM
341 ----
342 If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
343 of GCC and GNU binutils to build the kernel.
344

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Kbuild module 출력 파일

1-30

`modules.order`는 module이 Makefile에 나타나는 순서를 기록합니다. `modprobe`는 여러 module과 일치하는 alias를 결정론적으로 해석할 때 이 순서를 사용합니다.

`modules.builtin`은 kernel에 built-in된 모든 module을 나열합니다. `modprobe`가 built-in 기능을 load하려다 실패로 처리하지 않도록 합니다.

`modules.builtin.modinfo`는 kernel에 built-in된 모든 module의 modinfo를 담습니다. 별도 module의 modinfo와 달리 모든 field 앞에 module 이름이 붙습니다.

`modules.builtin.ranges`는 built-in module마다 ELF section별 address offset 범위를 담습니다. `System.map`과 함께 사용하면 symbol을 module 이름과 연결할 수 있습니다.

Kbuild module metadata output
파일내용소비자·용도
`modules.order`Makefile의 module 순서`modprobe` alias 결정
`modules.builtin`Built-in module 목록`modprobe`의 false failure 방지
`modules.builtin.modinfo`이름 prefix가 붙은 built-in modinfoModule metadata 조회
`modules.builtin.ranges`ELF section별 address offset`System.map`과 symbol→module 연결

네 파일이 module 탐색·정보·symbol 대응에 맡는 역할입니다.

======
Kbuild
======


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.

modules.builtin.modinfo
-----------------------
This file contains modinfo from all modules that are built into the kernel.
Unlike modinfo of a separate module, all fields are prefixed with module name.

modules.builtin.ranges
----------------------
This file contains address offset ranges (per ELF section) for all modules
that are built into the kernel. Together with System.map, it can be used
to associate module names with symbols.

Target·host·user program compile flag

31-123

`KCPPFLAGS`는 C와 assembler file build를 포함해 Kbuild가 preprocessing하는 모든 경우에 추가 option을 전달합니다. `KAFLAGS`는 built-in과 module assembler 공통 option이며 `AFLAGS_MODULE`과 `AFLAGS_KERNEL`은 각각 module과 built-in 전용 assembler option입니다.

`KCFLAGS`는 built-in과 module의 C compiler 공통 option이고 `KRUSTFLAGS`는 Rust compiler 공통 option입니다. `CFLAGS_KERNEL`과 `CFLAGS_MODULE`은 `$(CC)`의 built-in·module 전용 option이며 `RUSTFLAGS_KERNEL`과 `RUSTFLAGS_MODULE`은 `$(RUSTC)`의 대응 option입니다. `LDFLAGS_MODULE`은 `$(LD)`가 module을 link할 때 사용합니다.

Kernel target flag
Variable도구·단계범위
`KCPPFLAGS`Preprocessor모든 preprocessing
`KAFLAGS`AssemblerBuilt-in + module
`AFLAGS_KERNEL`AssemblerBuilt-in
`AFLAGS_MODULE`AssemblerModule
`KCFLAGS`C compilerBuilt-in + module
`CFLAGS_KERNEL``$(CC)`Built-in
`CFLAGS_MODULE``$(CC)`Module
`KRUSTFLAGS`Rust compilerBuilt-in + module
`RUSTFLAGS_KERNEL``$(RUSTC)`Built-in
`RUSTFLAGS_MODULE``$(RUSTC)`Module
`LDFLAGS_MODULE``$(LD)`Module link

공통 flag와 built-in·module 전용 flag를 구분합니다.

Host program에는 `HOSTCFLAGS`, `HOSTCXXFLAGS`, `HOSTRUSTFLAGS`가 각각 `$(HOSTCC)`, `$(HOSTCXX)`, `$(HOSTRUSTC)` compile option을 추가합니다. `HOSTLDFLAGS`는 host program link flag, `HOSTLDLIBS`는 link할 추가 library입니다.

`PROCMACROLDFLAGS`는 Rust proc macro link flag입니다. Proc macro는 build 중 rustc가 load하므로 사용 중인 rustc toolchain과 호환되는 방식으로 link해야 합니다. Rustc가 host program에 쓰려는 C library와 다른 library를 사용할 때 유용하며, 설정하지 않으면 host program link flag가 기본입니다.

Host build flag
Variable대상
`HOSTCFLAGS``$(HOSTCC)` host C program
`HOSTCXXFLAGS``$(HOSTCXX)` host C++ program
`HOSTRUSTFLAGS``$(HOSTRUSTC)` host Rust program
`PROCMACROLDFLAGS`Rust proc macro link
`HOSTLDFLAGS`Host program link
`HOSTLDLIBS`Host program 추가 library

Build host에서 실행되는 program과 proc macro에 적용됩니다.

`USERCFLAGS`는 `$(CC)`로 userprog를 compile할 때, `USERLDFLAGS`는 `$(LD)` 관련 userprog link에 추가됩니다. Userprog는 실제로 CC로 link하므로 필요한 linker option에는 `-Wl,` prefix를 포함해야 합니다.

User program flag
Variable단계주의
`USERCFLAGS`Compile`$(CC)` 추가 option
`USERLDFLAGS`LinkCC가 link하므로 linker option에 `-Wl,` 사용

Kernel tree에서 만드는 사용자 공간 program에 적용합니다.

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 assembler options for modules.

AFLAGS_KERNEL
-------------
Additional assembler options for built-in.

KCFLAGS
-------
Additional options to the C compiler (for built-in and modules).

KRUSTFLAGS
----------
Additional options to the Rust 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).

RUSTFLAGS_KERNEL
----------------
Additional options for $(RUSTC) when used to compile
code that is compiled as built-in.

RUSTFLAGS_MODULE
----------------
Additional module specific options to use for $(RUSTC).

LDFLAGS_MODULE
--------------
Additional options used for $(LD) when linking modules.

HOSTCFLAGS
----------
Additional flags to be passed to $(HOSTCC) when building host programs.

HOSTCXXFLAGS
------------
Additional flags to be passed to $(HOSTCXX) when building host programs.

HOSTRUSTFLAGS
-------------
Additional flags to be passed to $(HOSTRUSTC) when building host programs.

PROCMACROLDFLAGS
----------------
Flags to be passed when linking Rust proc macros. Since proc macros are loaded
by rustc at build time, they must be linked in a way that is compatible with
the rustc toolchain being used.

For instance, it can be useful when rustc uses a different C library than
the one the user wants to use for host programs.

If unset, it defaults to the flags passed when linking host programs.

HOSTLDFLAGS
-----------
Additional flags to be passed when linking host programs.

HOSTLDLIBS
----------
Additional libraries to link against when building host programs.

.. _userkbuildflags:

USERCFLAGS
----------
Additional options used for $(CC) when compiling userprogs.

USERLDFLAGS
-----------
Additional options used for $(LD) when linking userprogs. userprogs are linked
with CC, so $(USERLDFLAGS) should include "-Wl," prefix as applicable.

Kconfig·verbosity·build directory·warning 변수

124-185

`KBUILD_KCONFIG`은 top-level Kconfig file을 지정하며 기본 이름은 `Kconfig`입니다.

`KBUILD_VERBOSE`는 `V=...`와 같은 값으로 Kbuild verbosity를 정합니다. 전체 값 목록은 `make help`에 있으며 command line의 `V=...`가 우선합니다.

`KBUILD_EXTMOD`는 external module을 build할 때 kernel source를 찾을 directory를 지정하고 `M=...`가 우선합니다.

`KBUILD_OUTPUT`은 kernel output directory를 지정합니다. 별도 build directory의 pre-built kernel을 대상으로 external module을 build할 때 kernel output을 가리키는 데도 쓰지만 external module 자체의 output directory를 지정하지는 않습니다. 그 용도는 `KBUILD_EXTMOD_OUTPUT`이며 각각 command line `O=...`, `MO=...`가 우선합니다.

Environment와 command-line 우선순위
환경 변수Command line의미
`KBUILD_VERBOSE``V=...`출력 verbosity
`KBUILD_EXTMOD``M=...`External module source directory
`KBUILD_OUTPUT``O=...`Kernel output directory
`KBUILD_EXTMOD_OUTPUT``MO=...`External module output directory
`KBUILD_EXTRA_WARN``W=...`추가 build check

같은 설정의 command-line assignment가 environment variable보다 우선합니다.

`KBUILD_EXTRA_WARN`은 추가 build check를 정하며 지원 값은 `make help`에서 확인합니다. `W=...`가 우선합니다.

`KBUILD_DEBARCH`는 `deb-pkg` target의 architecture 추정 heuristic을 override합니다. 보통 `UTS_MACHINE`과 일부 architecture의 kernel config로 추정하지만 이 variable 값은 검증하지 않고 유효한 Debian architecture라고 가정합니다.

`KDOCFLAGS`는 build 중 kernel-doc check에 warning/error flag를 추가합니다. 지원 flag는 `scripts/kernel-doc`을 참고하며 현재 documentation build에는 적용되지 않습니다.

KBUILD_KCONFIG
--------------
Set the top-level Kconfig file to the value of this environment
variable.  The default name is "Kconfig".

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.

Setting "M=..." takes precedence over KBUILD_EXTMOD.

KBUILD_OUTPUT
-------------
Specify the output directory when building the kernel.

This variable can also be used to point to the kernel output directory when
building external modules against a pre-built kernel in a separate build
directory. Please note that this does NOT specify the output directory for the
external modules themselves. (Use KBUILD_EXTMOD_OUTPUT for that purpose.)

The output directory can also be specified using "O=...".

Setting "O=..." takes precedence over KBUILD_OUTPUT.

KBUILD_EXTMOD_OUTPUT
--------------------
Specify the output directory for external modules.

Setting "MO=..." takes precedence over KBUILD_EXTMOD_OUTPUT.

KBUILD_EXTRA_WARN
-----------------
Specify the extra build checks. The same value can be assigned by passing
W=... from the command line.

See `make help` for the list of the supported values.

Setting "W=..." takes precedence over KBUILD_EXTRA_WARN.

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.

KDOCFLAGS
---------
Specify extra (warning/error) flags for kernel-doc checks during the build,
see scripts/kernel-doc for which flags are supported. Note that this doesn't
(currently) apply to documentation builds.

Architecture, cross compile과 kernel 설치

186-236

`ARCH`는 build할 architecture를 지정합니다. 대부분 `arch/` directory 이름과 같지만 x86, parisc, sparc에는 alias가 있습니다.

`ARCH` alias
Architecture32-bit64-bit
x86`i386``x86_64`
parisc`parisc``parisc64`
sparc`sparc32``sparc64`

Bitness에 따라 사용하는 architecture 이름입니다.

`CROSS_COMPILE`은 binutils filename의 고정 부분을 지정합니다. Filename prefix 또는 전체 path일 수 있고 일부 구성에서는 ccache에도 사용됩니다.

`CF`는 sparse에 추가 option을 전달합니다. 예제 `make CF=-Wbitwise C=2`는 bitwise warning과 sparse checking level을 함께 지정합니다.

`INSTALL_PATH`는 갱신한 kernel과 system map image를 놓을 위치이며 기본값은 `/boot`입니다.

`INSTALLKERNEL`은 `make install`에서 호출할 install script 이름이며 기본은 `installkernel`입니다. Argument는 `$1` kernel version, `$2` kernel image file, `$3` kernel map file, `$4` 기본 install path이고 `$4`가 비면 root directory를 사용합니다.

`INSTALLKERNEL` argument
Argument
`$1`Kernel version
`$2`Kernel image file
`$3`Kernel map file
`$4`기본 install path, 비면 root directory

Install script가 받는 네 positional argument입니다.

`make install` 구현은 architecture별이므로 위 형식과 다를 수 있습니다. `INSTALLKERNEL`은 cross compile 중 custom installer를 지정할 수 있도록 제공됩니다.

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
- parisc: parisc64 for 64 bit
- sparc: sparc32 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.

Module·header·DTB 설치와 build 진단

237-303

`MODLIB`은 module 설치 위치이며 기본값은 `$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)`입니다. 직접 override하면 기본값은 무시됩니다.

`INSTALL_MOD_PATH`는 build root에서 module directory를 relocate하기 위해 `MODLIB` 앞에 붙이는 prefix입니다. Makefile에 정의되지는 않지만 필요할 때 make argument로 전달합니다.

`INSTALL_MOD_STRIP`을 정의하면 설치 뒤 module을 strip합니다. 값이 `1`이면 기본 `--strip-debug` option을 쓰고, 다른 값이면 그 값을 strip command option으로 사용합니다.

Module 설치 변수
Variable효과
`MODLIB`최종 module directory
`INSTALL_MOD_PATH``MODLIB` 앞 relocation prefix
`INSTALL_MOD_STRIP=1``--strip-debug`으로 strip
`INSTALL_MOD_STRIP=<options>`지정 option으로 strip

Module destination과 strip 동작을 제어합니다.

`INSTALL_HDR_PATH`는 `make headers_*`의 사용자 공간 header 설치 root입니다. 기본은 `$(objtree)/usr`이며 `$(objtree)`는 output file이 저장되는 directory로 보통 command line `O=...`로 정합니다. Variable을 override하면 기본값은 무시됩니다.

`INSTALL_DTBS_PATH`는 build root relocation을 위한 device tree blob 설치 위치입니다. Makefile에는 정의되지 않으며 필요할 때 make argument로 전달합니다.

Kbuild는 가능하면 tree를 상대 path로 가리킵니다. Source tree 안 build에서는 source path가 `.`입니다. `KBUILD_ABS_SRCTREE`를 설정하면 tag file 등에 absolute path entry가 필요할 때 source tree의 absolute path를 사용합니다.

`KBUILD_SIGN_PIN`은 private key에 passphrase나 PIN이 필요할 때 module signing의 `sign-file` utility로 값을 전달합니다.

`KBUILD_MODPOST_WARN`은 final module link에서 undefined symbol error를 warning으로 바꿉니다. `KBUILD_MODPOST_NOFINAL`은 module의 final link를 건너뛰며 test compile 속도를 높이는 용도로만 사용합니다.

Module build 진단 변수
Variable동작
`KBUILD_SIGN_PIN``sign-file`에 passphrase/PIN 전달
`KBUILD_MODPOST_WARN`Undefined symbol error를 warning으로 변경
`KBUILD_MODPOST_NOFINAL`Final module link 생략, test compile 전용

Signing과 modpost 동작을 조정합니다.

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

INSTALL_DTBS_PATH
-----------------
INSTALL_DTBS_PATH specifies where to install device tree blobs for
relocations required by build roots.  This is not defined in the
makefile but the argument can be passed to make if needed.

KBUILD_ABS_SRCTREE
--------------------------------------------------
Kbuild uses a relative path to point to the tree when possible. For instance,
when building in the source tree, the source tree path is '.'

Setting this flag requests Kbuild to use absolute path to the source tree.
There are some useful cases to do so, like when generating tag files with
absolute path entries etc.

KBUILD_SIGN_PIN
---------------
This variable allows a passphrase or PIN to be passed to the sign-file
utility when signing kernel modules, if the private key requires such.

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.

추가 symbol, tag database와 build identity

304-343

`KBUILD_EXTRA_SYMBOLS`는 다른 module의 symbol을 사용하는 module build에 쓰며 자세한 내용은 `modules.rst`를 참고합니다.

`ALLSOURCE_ARCHS`는 `tags`, `TAGS`, `cscope` target database에 넣을 architecture를 공백으로 구분해 여러 개 지정합니다. 예제는 `make ALLSOURCE_ARCHS="x86 mips arm" tags`이며 모든 architecture는 `make ALLSOURCE_ARCHS=all tags`로 지정합니다.

`IGNORE_DIRS`는 tag database에서 제외할 directory를 공백으로 구분해 정합니다. 예제는 `make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope`입니다.

Source navigation database 변수
Variable대상
`ALLSOURCE_ARCHS`포함할 architecture`x86 mips arm` 또는 `all`
`IGNORE_DIRS`제외할 directory`drivers/gpu/drm/radeon tools`

Architecture 범위와 제외 directory를 따로 정합니다.

`KBUILD_BUILD_TIMESTAMP`는 실행 kernel의 `uname -v`에 보이는 `UTS_VERSION` timestamp를 override합니다. 값은 `date -d`에 전달 가능한 date string이어야 하고 기본값은 build 중 한 시점의 `date` 출력입니다.

`KBUILD_BUILD_USER`와 `KBUILD_BUILD_HOST`는 boot 중과 `/proc/version`에 보이는 `user@host`를 override합니다. 기본값은 각각 `whoami`와 `host` command 출력입니다.

`LLVM=1`이면 Kbuild는 GCC와 GNU binutils 대신 Clang과 LLVM utility로 kernel을 build합니다.

Build identity 결정
`KBUILD_BUILD_TIMESTAMP` 또는 `date``KBUILD_BUILD_USER` 또는 `whoami``KBUILD_BUILD_HOST` 또는 `host``UTS_VERSION`과 `/proc/version` identity 생성

명시하지 않은 값은 host command 결과를 사용합니다.

KBUILD_EXTRA_SYMBOLS
--------------------
For modules that use symbols from other modules.
See more details in modules.rst.

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

IGNORE_DIRS
-----------
For tags/TAGS/cscope targets, you can choose which directories won't
be included in the databases, separated by blank space. E.g.::

    $ make IGNORE_DIRS="drivers/gpu/drm/radeon tools" cscope

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.

LLVM
----
If this variable is set to 1, Kbuild will use Clang and LLVM utilities instead
of GCC and GNU binutils to build the kernel.