#!/bin/bash

# https://sourceware.org/binutils/
# https://sourceware.org/binutils/docs/


export INSTALL_ROOT_DIR="$(pwd)/sysroot"
export BASE_DIR=$(pwd)
export binutils_ver="2.9.1"

# wget -N "https://ftp.gnu.org/gnu/binutils/binutils-2.38.tar.xz"
# wget -N "https://mirrors.kernel.org/gnu/binutils/binutils-2.38.tar.xz"

https://mirrors.kernel.org/gnu/binutils/binutils-2.9.1.tar.gz
cd "$BASE_DIR" || exit
#wget -N "https://ftp.gnu.org/gnu/binutils/binutils-$binutils_ver.tar.xz"
wget -N "https://mirrors.kernel.org/gnu/binutils/binutils-$binutils_ver.tar.gz"
tar -xzf "$BASE_DIR/binutils-$binutils_ver.tar.gz"
cd "$BASE_DIR/binutils-$binutils_ver" || exit


./configure   --host=arm-linux-gnueabihf  --target=arm-linux-gnueabihf
./configure   --host=arm-linux-gnueabihf  --target=arm-linux-gnueabihf

./configure \
  --prefix="$BASE_DIR/install/binutils" \  # 安装路径
  --host=arm-linux-gnueabihf \            # 设置目标平台架构为 ARM
  --with-sysroot="$SYSROOT" \             # 设置 sysroot 路径
  --disable-nls \                         # 禁用本地化支持
  --enable-gold \                         # 启用 gold 链接器
  --enable-ld=default \                   # 使用默认的链接器
  --enable-plugins \                      # 启用插件
  --disable-werror                        # 不将警告当作错误处理

$./configure --host=arm-none-eabi --target=arm-none-eabi --prefix=/usr/local/binutils


make -j$(nproc)
make install


wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.14.8.tar.xz

#        "git clone --branch v1.3.1 --depth 1   https://github.com/madler/zlib.git zlib"

git clone --branch v6.15 --depth 1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux
