78 lines
1.3 KiB
Bash
Executable File
78 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
# Check
|
|
if [ "$(uname -m)" != 'x86_64' ]; then
|
|
echo 'Unsupported Build System!' > /dev/stderr
|
|
exit 1
|
|
fi
|
|
|
|
# Install Dependencies
|
|
apt-get update
|
|
apt-get install -y \
|
|
build-essential \
|
|
g++-aarch64-linux-gnu \
|
|
flex \
|
|
texinfo \
|
|
help2man \
|
|
gawk \
|
|
libtool-bin \
|
|
bison
|
|
|
|
# Versions
|
|
CT_NAME='crosstool-ng'
|
|
CT_VERSION='1.27.0'
|
|
CT="${CT_NAME}-${CT_VERSION}"
|
|
|
|
# Directories
|
|
SRC="$(pwd)/src"
|
|
WORKSPACE="$(pwd)/workspace"
|
|
OUT="$(pwd)/out"
|
|
|
|
# Create Workspace
|
|
dir() {
|
|
rm -rf "$1"
|
|
mkdir "$1"
|
|
cd "$1"
|
|
}
|
|
dir "${WORKSPACE}"
|
|
|
|
# Build crosstools-ng
|
|
dir "${CT_NAME}"
|
|
wget "https://github.com/${CT_NAME}/${CT_NAME}/releases/download/${CT}/${CT}.tar.xz"
|
|
tar -xJf "${CT}.tar.xz" --strip-components=1
|
|
./configure \
|
|
--enable-local \
|
|
--enable-silent-rules \
|
|
--quiet
|
|
make -j$(nproc)
|
|
|
|
# Add Patch
|
|
cd packages/binutils
|
|
patch() {
|
|
for version in */; do
|
|
cp "${SRC}/$1" "${version}"
|
|
done
|
|
}
|
|
patch 9999-change-page-size.patch
|
|
|
|
# Configure Toolchain
|
|
cd "${WORKSPACE}"
|
|
export PATH="$(pwd)/${CT_NAME}:${PATH}"
|
|
dir build
|
|
prepare() {
|
|
dir "$1"
|
|
cp "${SRC}/defconfig" .
|
|
printf "$2" >> defconfig
|
|
ct-ng defconfig
|
|
ct-ng show-config
|
|
chmod -R o+rw .
|
|
cd ../
|
|
}
|
|
prepare x86_64 ''
|
|
prepare aarch64 'CT_CANADIAN=y\nCT_HOST="aarch64-linux-gnu"\n'
|
|
|
|
# Setup Output Directory
|
|
dir "${OUT}"
|
|
chmod -R o+rw . |