← Documents Documentation/kbuild/bash-completion.rst GitHub 원문 ↗

Linux 6.18.37 · Kbuild

Bash completion for Kbuild

Kernel tree context를 인식해 Kbuild target, variable, single target, configuration 후보를 제공하는 Bash completion을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

bash-completion.rst:1-65

`scripts/bash-completion/make`는 kernel source/build tree를 인식해 일반 `make` completion보다 구체적인 Kbuild 후보를 제공합니다. 직접 source하거나 사용자 completion search path에 설치할 수 있으며, 문맥이 kernel tree가 아니면 일반 규칙으로 돌아갑니다.

Completion 결정
현재 directory와 `-C`·`-f` 분석Kernel source/build tree 여부 판정Kbuild target·variable·file 후보 생성아니면 generic make completion 사용

Kernel build context를 확인한 뒤 전용 또는 일반 규칙을 선택합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0-only
2
3 ==========================
4 Bash completion for Kbuild
5 ==========================
6
7 The kernel build system is written using Makefiles, and Bash completion
8 for the `make` command is available through the `bash-completion`_ project.
9
10 However, the Makefiles for the kernel build are complex. The generic completion
11 rules for the `make` command do not provide meaningful suggestions for the
12 kernel build system, except for the options of the `make` command itself.
13
14 To enhance completion for various variables and targets, the kernel source
15 includes its own completion script at `scripts/bash-completion/make`.
16
17 This script provides additional completions when working within the kernel tree.
18 Outside the kernel tree, it defaults to the generic completion rules for the
19 `make` command.
20
21 Prerequisites
22 =============
23
24 The script relies on helper functions provided by `bash-completion`_ project.
25 Please ensure it is installed on your system. On most distributions, you can
26 install the `bash-completion` package through the standard package manager.
27
28 How to use
29 ==========
30
31 You can source the script directly::
32
33 $ source scripts/bash-completion/make
34
35 Or, you can copy it into the search path for Bash completion scripts.
36 For example::
37
38 $ mkdir -p ~/.local/share/bash-completion/completions
39 $ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/
40
41 Details
42 =======
43
44 The additional completion for Kbuild is enabled in the following cases:
45
46 - You are in the root directory of the kernel source.
47 - You are in the top-level build directory created by the O= option
48 (checked via the `source` symlink pointing to the kernel source).
49 - The -C make option specifies the kernel source or build directory.
50 - The -f make option specifies a file in the kernel source or build directory.
51
52 If none of the above are met, it falls back to the generic completion rules.
53
54 The completion supports:
55
56 - Commonly used targets, such as `all`, `menuconfig`, `dtbs`, etc.
57 - Make (or environment) variables, such as `ARCH`, `LLVM`, etc.
58 - Single-target builds (`foo/bar/baz.o`)
59 - Configuration files (`*_defconfig` and `*.config`)
60
61 Some variables offer intelligent behavior. For instance, `CROSS_COMPILE=`
62 followed by a TAB displays installed toolchains. The list of defconfig files
63 shown depends on the value of the `ARCH=` variable.
64
65 .. _bash-completion: https://github.com/scop/bash-completion/
66

3. 한국어 전문 번역

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

Kbuild completion 개요와 전제 조건

1-27

Linux kernel build system은 Makefile로 작성되어 있으며 `make` command의 Bash completion은 `bash-completion` project가 제공합니다.

하지만 kernel build Makefile은 복잡하므로 일반 `make` completion 규칙은 `make` 자체 option 외에는 kernel build에 의미 있는 제안을 제공하지 못합니다. 여러 variable과 target completion을 보강하기 위해 kernel source는 `scripts/bash-completion/make`에 전용 script를 포함합니다.

이 script는 kernel tree 안에서 작업할 때 추가 completion을 제공하고, kernel tree 밖에서는 일반 `make` completion 규칙으로 돌아갑니다.

Completion 선택
환경적용 규칙
Kernel source/build tree`scripts/bash-completion/make`의 Kbuild completion
그 밖의 directory일반 `make` completion

현재 작업 위치에 따라 적용되는 규칙입니다.

Script는 `bash-completion` project가 제공하는 helper function에 의존합니다. System에 설치되어 있어야 하며 대부분 distribution에서는 표준 package manager로 `bash-completion` package를 설치할 수 있습니다.

.. SPDX-License-Identifier: GPL-2.0-only

==========================
Bash completion for Kbuild
==========================

The kernel build system is written using Makefiles, and Bash completion
for the `make` command is available through the `bash-completion`_ project.

However, the Makefiles for the kernel build are complex. The generic completion
rules for the `make` command do not provide meaningful suggestions for the
kernel build system, except for the options of the `make` command itself.

To enhance completion for various variables and targets, the kernel source
includes its own completion script at `scripts/bash-completion/make`.

This script provides additional completions when working within the kernel tree.
Outside the kernel tree, it defaults to the generic completion rules for the
`make` command.

Prerequisites
=============

The script relies on helper functions provided by `bash-completion`_ project.
Please ensure it is installed on your system. On most distributions, you can
install the `bash-completion` package through the standard package manager.

Completion script 사용 방법

28-40

한 session에서 바로 사용하려면 kernel tree에서 다음과 같이 script를 source합니다.

$ source scripts/bash-completion/make

항상 검색되게 하려면 Bash completion script search path에 복사할 수 있습니다. 예제는 사용자별 completion directory를 만들고 script를 그곳에 복사합니다.

$ mkdir -p ~/.local/share/bash-completion/completions
$ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/
설치 방식
방법명령·위치범위
직접 source`source scripts/bash-completion/make`현재 shell session
검색 경로에 복사`~/.local/share/bash-completion/completions/`Bash completion loader가 지속적으로 발견

직접 source와 사용자별 설치의 차이입니다.

How to use
==========

You can source the script directly::

  $ source scripts/bash-completion/make

Or, you can copy it into the search path for Bash completion scripts.
For example::

  $ mkdir -p ~/.local/share/bash-completion/completions
  $ cp scripts/bash-completion/make ~/.local/share/bash-completion/completions/

활성화 조건과 지원 completion

41-65

Kbuild 추가 completion은 kernel source root에 있거나, `O=` option으로 만든 top-level build directory에서 `source` symlink가 kernel source를 가리키거나, `make -C`가 kernel source/build directory를 지정하거나, `make -f`가 그 directory 안의 file을 지정할 때 활성화됩니다. 어느 조건도 맞지 않으면 일반 completion 규칙으로 돌아갑니다.

Kbuild completion 활성화 조건
조건판별 방법
Kernel source root현재 directory 자체
`O=` top-level build directory`source` symlink가 kernel source를 가리킴
`make -C`kernel source 또는 build directory 지정
`make -f`kernel source 또는 build directory 안의 file 지정

현재 directory와 `make` option에서 kernel tree를 식별합니다.

Completion은 `all`, `menuconfig`, `dtbs` 같은 자주 쓰는 target, `ARCH`, `LLVM` 같은 Make 또는 environment variable, `foo/bar/baz.o` 형태의 single-target build, `*_defconfig`와 `*.config` configuration file을 지원합니다.

지원 completion
종류
Common target`all`, `menuconfig`, `dtbs`
Variable`ARCH`, `LLVM`
Single target`foo/bar/baz.o`
Configuration`*_defconfig`, `*.config`

Kbuild 전용으로 제안하는 항목입니다.

일부 variable에는 지능형 동작이 있습니다. `CROSS_COMPILE=` 뒤에서 TAB을 누르면 설치된 toolchain을 표시하고, defconfig 목록은 `ARCH=` variable 값에 따라 달라집니다. `bash-completion` project link는 `https://github.com/scop/bash-completion/`입니다.

Context-aware suggestion
`CROSS_COMPILE=` 입력설치된 toolchain 탐색TAB으로 prefix 후보 표시`ARCH=` 값 확인해당 architecture의 defconfig만 제안

선행 variable 값이 뒤의 후보 집합을 바꿉니다.

Details
=======

The additional completion for Kbuild is enabled in the following cases:

 - You are in the root directory of the kernel source.
 - You are in the top-level build directory created by the O= option
   (checked via the `source` symlink pointing to the kernel source).
 - The -C make option specifies the kernel source or build directory.
 - The -f make option specifies a file in the kernel source or build directory.

If none of the above are met, it falls back to the generic completion rules.

The completion supports:

  - Commonly used targets, such as `all`, `menuconfig`, `dtbs`, etc.
  - Make (or environment) variables, such as `ARCH`, `LLVM`, etc.
  - Single-target builds (`foo/bar/baz.o`)
  - Configuration files (`*_defconfig` and `*.config`)

Some variables offer intelligent behavior. For instance, `CROSS_COMPILE=`
followed by a TAB displays installed toolchains. The list of defconfig files
shown depends on the value of the `ARCH=` variable.

.. _bash-completion: https://github.com/scop/bash-completion/