Skip to main content
The OpenWrt build system is a Makefile-based framework that downloads upstream source code, cross-compiles a complete GNU/Linux system, and produces firmware images ready to flash onto embedded devices. Rather than distributing pre-built binaries, the build system lets you produce a fully customized firmware from source.

How it works

When you run make, the build system:
  1. Downloads all required source archives from the internet (or a local mirror)
  2. Builds host-side tools needed to drive the rest of the build
  3. Builds a cross-compilation toolchain (GCC, musl/uClibc-ng, binutils) targeting your chosen hardware
  4. Cross-compiles the Linux kernel for the target
  5. Cross-compiles every selected package against the toolchain
  6. Assembles a root filesystem and produces flashable firmware images
All of this is driven by a single top-level make world target.

Build pipeline

1

tools

Host utilities required by later stages are compiled first (e.g. quilt, cmake, ninja, swig). These are installed into staging_dir/host/.
2

toolchain

The cross-compiler toolchain — binutils, GCC, and the C library (musl by default) — is built for the target architecture and installed into staging_dir/toolchain-*/.
3

target/linux

The Linux kernel is configured and compiled for the target platform. Kernel modules are built as part of this step.
4

packages

All selected packages are cross-compiled using the toolchain. Package .ipk or .apk files are written to bin/packages/.
5

images

A root filesystem is assembled from the installed packages, then combined with the kernel to produce firmware image files in bin/targets/<target>/<subtarget>/.

Key directories

include/

Core build rules and Makefile fragments. toplevel.mk bootstraps the entire build; package.mk defines how packages are built.

scripts/

Helper scripts used during the build — feed management (feeds), version detection (getver.sh), config diffing (diffconfig.sh), and more.

package/

Package definitions. Each subdirectory contains a Makefile that describes how to download, patch, compile, and install a package.

target/

Platform-specific targets. target/linux/ holds kernel configuration and patches for each supported architecture and board.

toolchain/

Build rules for GCC, binutils, and the C library. These are built before any target packages.

feeds/

Symlinks to packages obtained from external feeds after running ./scripts/feeds install.

The world target

make world is the top-level target that drives a complete firmware build. It depends on prepare, which in turn builds tools and the toolchain, followed by the kernel, packages, and final image assembly.
world: prepare $(target/stamp-compile) $(package/stamp-compile) \
       $(package/stamp-install) $(target/stamp-install)
Running make without arguments also invokes world because it is the first real target declared in the top-level Makefile.
The build system enforces a strict dependency order. You cannot, for example, compile a package before the toolchain is ready. The stamp-file mechanism (stamp-compile, stamp-install) tracks which stages have completed.