Open-Source Wikis

/

Linux

/

Subsystems

/

Scripts

torvalds/linux

Scripts

Purpose

scripts/ holds build-time helpers, lint tools, code generators, kconfig itself, and many other utilities used during make. Unlike tools/, the contents are run during the build (not shipped to users).

Notable contents

scripts/
├── checkpatch.pl              # The patch linter (mandatory)
├── get_maintainer.pl          # Subsystem owner lookup
├── kconfig/                   # The kconfig program (Kbuild's config UI)
├── kallsyms/                  # Generates the kernel symbol table (System.map)
├── mod/                       # modpost: post-link processing of modules
├── basic/                     # fixdep, basic compile helpers
├── dtc/                       # The device-tree compiler
├── gcc-plugins/               # Optional gcc plugins (structleak, randstruct, …)
├── coccinelle/                # SmPL semantic-patch scripts
├── faddr2line                 # Function-address to file:line resolver
├── decode_stacktrace.sh       # Translate a stack trace
├── checkstack.pl              # Find functions that use lots of stack
├── sortextable, sorttable.c   # Sort exception tables in vmlinux
├── recordmcount.{c,pl}        # Record mcount call sites for ftrace
├── orc/, objtool integration  # ORC unwind tables (with tools/objtool)
├── package/                   # Distro package builders (rpm, deb, snapcraft, pacman)
├── selinux/, smack/           # Helpers for those LSMs (mdp, etc.)
├── extract-cert.c, sign-file.c # Module signing helpers
├── insert-sys-cert.c          # Embed certificates in vmlinux
├── docproc, kernel-doc, sphinx-pre-install   # docs build
├── Makefile, Makefile.host, Makefile.lib, Makefile.build, Makefile.modpost, Makefile.modfinal, Makefile.modinst, Makefile.headersinst, Makefile.clean, Makefile.dtbinst   # The Kbuild engine
├── ld-version.sh, gcc-version.sh, gcc-x86_64-has-stack-protector.sh, …  # Compiler probes
├── analyze_suspend_*.py        # Suspend-resume timing
├── Lindent                    # Run indent(1) with kernel style
└── ...

Major moving parts

Kbuild engine

scripts/Makefile.* constitute the recursive make engine. Top-level Makefile invokes them.

  • Makefile.build — compiles a directory.
  • Makefile.lib — pattern rules.
  • Makefile.host — builds host tools (hostprogs-y).
  • Makefile.modpost — post-link symbol checking and version magic for modules.
  • Makefile.modfinal — final module link.
  • Makefile.headersinstmake headers_install.

kconfig

scripts/kconfig/ implements make menuconfig, make defconfig, make olddefconfig, make savedefconfig, etc. Written in C with lex/yacc. Drives the entire configuration system.

Module signing

scripts/sign-file signs a .ko with a key from certs/. scripts/extract-cert.c extracts certs from PEM files into the binary.

Device-tree compiler

scripts/dtc/ is the in-tree DTC. Compiles .dts to .dtb. Also performs YAML schema checks (make dtbs_check) against Documentation/devicetree/bindings/*.yaml.

Coccinelle scripts

scripts/coccinelle/ contains semantic-patch scripts run by make coccicheck. Useful for refactors and finding patterns.

checkpatch and friends

The big lint tools. See How to contribute → Tooling.

gcc plugins

Optional GCC plugins compiled here:

  • structleak — zero stack-allocated structs whose initializers might miss fields.
  • randstruct — randomize the layout of selected structs at compile time.
  • latent_entropy — gather entropy at compile time for the early RNG.

ORC and ftrace helpers

recordmcount finds mcount/fentry call sites in object files for ftrace. orc/ (with tools/objtool) builds ORC unwind tables for x86_64.

Documentation

scripts/kernel-doc extracts kernel-doc comments. scripts/sphinx-pre-install is a friendly check before make htmldocs.

Integration points

The kernel build invokes these scripts directly. Kbuild itself is in scripts/Makefile.*. End-users rarely touch this directory; developers may.

Entry points for modification

  • A new build-time check: add a perl/python script and wire into scripts/Makefile.build or expose as a make target.
  • A new kconfig feature: rare; coordinate with the Kbuild maintainers (linux-kbuild@vger.kernel.org).
  • A new coccinelle script: drop under scripts/coccinelle/<category>/. They are auto-discovered by make coccicheck.
  • New DTC feature: typically synced from upstream dtc and checked by dtbs_check.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Scripts – Linux wiki | Factory