#!/bin/bash # ============================================================================ # DarkForge Linux — Phase 0, Chapter 6: Binutils Pass 2 # ============================================================================ # Purpose: Rebuild binutils with the temporary toolchain. This produces # binutils that runs on the target and generates code for the target. # Pass 1 ran on the host; Pass 2 runs on the target (via cross-compiler). # Inputs: ${LFS}/sources/binutils-2.46.0.tar.xz # Outputs: Updated binutils in ${LFS}/usr/ # Assumes: All Chapter 5 + Chapter 6 temp tools (006-020) complete # Ref: LFS 13.0 §6.17 # ============================================================================ set -euo pipefail source "${LFS}/sources/darkforge-env.sh" PACKAGE="binutils" VERSION="2.46.0" SRCDIR="${LFS}/sources" echo "=== Building ${PACKAGE}-${VERSION} (Pass 2) ===" cd "${SRCDIR}" tar -xf "${PACKAGE}-${VERSION}.tar.xz" cd "${PACKAGE}-${VERSION}" # Remove libtool archive files that cause cross-compilation issues sed '6009s/$add_dir//' -i ltmain.sh mkdir -v build cd build ../configure \ --prefix=/usr \ --build="$(../config.guess)" \ --host="${LFS_TGT}" \ --disable-nls \ --enable-shared \ --enable-gprofng=no \ --disable-werror \ --enable-64-bit-bfd \ --enable-new-dtags \ --enable-default-hash-style=gnu make make DESTDIR="${LFS}" install # Remove libtool archives — they're harmful for cross-compiled libraries rm -v "${LFS}"/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes,sframe}.{a,la} 2>/dev/null || true cd "${SRCDIR}" rm -rf "${PACKAGE}-${VERSION}" echo "=== ${PACKAGE}-${VERSION} Pass 2 complete ==="