bash-completion.rst 2.4 KB

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