100 lines
3.5 KiB
Bash
100 lines
3.5 KiB
Bash
#!/bin/bash -e
|
|
|
|
# Clone source code
|
|
git clone -b openwrt-24.10 --single-branch --filter=blob:none https://github.com/immortalwrt/immortalwrt openwrt
|
|
|
|
# Enter source code
|
|
cd openwrt
|
|
|
|
# Init feeds
|
|
./scripts/feeds update -a
|
|
./scripts/feeds install -a
|
|
|
|
# gcc15 patches
|
|
curl -s https://raw.githubusercontent.com/oppen321/ZeroWrt-Action/refs/heads/master/patch/GCC/202-toolchain-gcc-add-support-for-GCC-15.patch | patch -p1
|
|
|
|
# Load devices Config
|
|
if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then
|
|
curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_rockchip.config > .config
|
|
elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then
|
|
curl -s https://git.kejizero.online/zhao/files/raw/branch/main/toolchain/Configs/immortalwrt_x86_64.config > .config
|
|
fi
|
|
|
|
# gcc14 & 15
|
|
if [ "$USE_GCC13" = y ]; then
|
|
export USE_GCC13=y gcc_version=13
|
|
elif [ "$USE_GCC14" = y ]; then
|
|
export USE_GCC14=y gcc_version=14
|
|
elif [ "$USE_GCC15" = y ]; then
|
|
export USE_GCC15=y gcc_version=15
|
|
else
|
|
export USE_GCC14=y gcc_version=14
|
|
fi
|
|
|
|
# gcc config
|
|
echo -e "\n# gcc ${gcc_version}" >> .config
|
|
echo -e "CONFIG_DEVEL=y" >> .config
|
|
echo -e "CONFIG_TOOLCHAINOPTS=y" >> .config
|
|
echo -e "CONFIG_GCC_USE_VERSION_${gcc_version}=y\n" >> .config
|
|
|
|
# Compile
|
|
make defconfig
|
|
make -j$(nproc)
|
|
|
|
# Organize files
|
|
if [ "$model" = "Padavanonly_MT798X_v24.10" ] || [ "$model" = "Hanwckf_MT798X_v21.02" ]; then
|
|
rm -rf build_dir/hostpkg
|
|
rm -rf staging_dir/hostpkg
|
|
rm -rf staging_dir/packages
|
|
rm -rf staging_dir/target-aarch64_cortex-a53_musl/host
|
|
rm -rf staging_dir/target-aarch64_cortex-a53_musl/packages
|
|
rm -rf staging_dir/target-aarch64_cortex-a53_musl/pkginfo
|
|
rm -rf staging_dir/target-aarch64_cortex-a53_musl/root-mediatek
|
|
find build_dir/target-aarch64_cortex-a53_musl -mindepth 1 -maxdepth 1 ! -name 'stamp' -exec rm -rf {} +
|
|
elif [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then
|
|
rm -rf build_dir/hostpkg
|
|
rm -rf staging_dir/hostpkg
|
|
rm -rf staging_dir/packages
|
|
rm -rf staging_dir/target-aarch64_generic_musl/image
|
|
rm -rf staging_dir/target-aarch64_generic_musl/host
|
|
rm -rf staging_dir/target-aarch64_generic_musl/packages
|
|
rm -rf staging_dir/target-aarch64_generic_musl/pkginfo
|
|
rm -rf staging_dir/target-aarch64_generic_musl/root-rockchip
|
|
find build_dir/target-aarch64_generic_musl -mindepth 1 -maxdepth 1 ! -name 'stamp' -exec rm -rf {} +
|
|
elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then
|
|
rm -rf build_dir/hostpkg
|
|
rm -rf staging_dir/hostpkg
|
|
rm -rf staging_dir/packages
|
|
rm -rf staging_dir/target-x86_64_musl/image
|
|
rm -rf staging_dir/target-x86_64_musl/host
|
|
rm -rf staging_dir/target-x86_64_musl/packages
|
|
rm -rf staging_dir/target-x86_64_musl/pkginfo
|
|
rm -rf staging_dir/target-x86_64_musl/root-x86
|
|
find build_dir/target-x86_64_musl -mindepth 1 -maxdepth 1 ! -name 'stamp' -exec rm -rf {} +
|
|
fi
|
|
|
|
# Create folder
|
|
mkdir toolchain-cache
|
|
|
|
# Compression toolchain
|
|
case "$model" in
|
|
"OpenWrt_Rockchip_v24.10" | "OpenWrt_X86_64_v24.10")
|
|
if [ -z "$gcc_version" ]; then
|
|
echo "Error: GCC version not set!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ "$model" = "OpenWrt_Rockchip_v24.10" ]; then
|
|
output_file="toolchain_musl_openwrt_rockchip_gcc-${gcc_version}.tar.zst"
|
|
elif [ "$model" = "OpenWrt_X86_64_v24.10" ]; then
|
|
output_file="toolchain_musl_openwrt_X86_64_gcc-${gcc_version}.tar.zst"
|
|
fi
|
|
|
|
tar -I zstd -cvf "toolchain-cache/${output_file}" build_dir dl tmp staging_dir
|
|
;;
|
|
*)
|
|
echo "Error: Unknown model '$model'!"
|
|
exit 1
|
|
;;
|
|
esac
|