#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 5: Linux API Headers # ============================================================================ # Purpose: Install the Linux kernel API headers into the target sysroot. # These headers define the kernel-userspace interface that glibc # needs to compile against. We use kernel 6.19.8 to match our # target kernel version. # Inputs: ${LFS}/sources/linux-6.19.8.tar.xz # Outputs: Kernel headers in ${LFS}/usr/include/ # Assumes: Running as 'lfs' user # Ref: LFS 13.0 §5.4 # ============================================================================ set -euo pipefail source "${LFS}/sources/darkforge-env.sh" PACKAGE="linux" VERSION="6.19.8" SRCDIR="${LFS}/sources" echo "=== Installing ${PACKAGE}-${VERSION} API Headers ===" cd "${SRCDIR}" tar -xf "${PACKAGE}-${VERSION}.tar.xz" cd "${PACKAGE}-${VERSION}" # Clean any stale files or configurations make mrproper # Generate the sanitized kernel headers # The 'headers' target produces userspace-safe versions of kernel headers make headers # Remove non-header files from the generated output find usr/include -type f ! -name '*.h' -delete # Install headers to target sysroot cp -rv usr/include "${LFS}/usr" # Cleanup cd "${SRCDIR}" rm -rf "${PACKAGE}-${VERSION}" echo "=== ${PACKAGE}-${VERSION} API Headers installed ==="