#!/bin/sh # License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. # # Build the kernel Image for one device from a kernel tree. # # Usage: build-kernel.sh DEVICEDIR KERNEL_TREE # The device's kernel.config becomes the tree's .config; an up-to-date tree # is not rebuilt. With KERNEL_DTB in device.conf (a path below # arch/$ARCH/boot/dts, as the tree's Makefile names it) the device tree is # built from the tree's sources too. Prints the path of the Image. set -eu . "$(dirname "$0")/lib.sh" [ $# -eq 2 ] || { echo "usage: $0 DEVICEDIR KERNEL_TREE" >&2; exit 2; } load_device "$1" tree=$2 cmp -s "$KERNEL_CONFIG" "$tree/.config" || cp "$KERNEL_CONFIG" "$tree/.config" # The boot logo (fbcon's, instead of the penguin): KERNEL_LOGO in device.conf # names a PNG; it becomes the 224-colour plain PPM the kernel's pnmtologo # takes, at the path kernel.config's CONFIG_LOGO_LINUX_CLUT224_FILE names # (drivers/video/logo/logo_makronix_clut224.ppm). Made here, in the build # tree, so the PNG in docs/logo/ stays the only copy; needs netpbm. if [ -n "${KERNEL_LOGO:-}" ]; then [ -f "$KERNEL_LOGO" ] || die "no boot logo $KERNEL_LOGO" logo=$tree/drivers/video/logo/logo_makronix_clut224.ppm pngtopnm "$KERNEL_LOGO" | ppmquant 224 2>/dev/null | pnmnoraw > "$logo.tmp" || die "cannot convert $KERNEL_LOGO (netpbm)" cmp -s "$logo.tmp" "$logo" 2>/dev/null && rm -f "$logo.tmp" || mv "$logo.tmp" "$logo" fi # olddefconfig FIRST and alone: in one -j invocation with the build targets it # runs in parallel with them, and a config change then regenerates # include/generated/* while sources compile -- the build failed with an empty # LINUX_VERSION_CODE and an empty KERNEL_REL (2026-11-09) kernel_make "$tree" olddefconfig # the name (uname -r, /proc/version) comes from kernel_make (lib.sh) kernel_make "$tree" -j"$(nproc)" "$(basename "$KERNEL_IMAGE")" modules \ ${KERNEL_DTB:+"$KERNEL_DTB"} echo "$tree/$KERNEL_IMAGE"