2023-06-02 18:40:24 +03:00
|
|
|
#!/bin/bash
|
2023-04-06 00:02:13 +03:00
|
|
|
set -e
|
|
|
|
|
|
|
|
BINUTILS_VERSION="binutils-2.39"
|
|
|
|
GCC_VERSION="gcc-12.2.0"
|
2023-10-16 01:37:12 +03:00
|
|
|
GRUB_VERSION="grub-2.06"
|
2023-04-06 00:02:13 +03:00
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
cd $(dirname "$0")
|
2023-04-06 00:02:13 +03:00
|
|
|
|
2023-06-02 18:39:42 +03:00
|
|
|
if [[ -n $LIBSTDCPP ]]; then
|
|
|
|
cd build/${GCC_VERSION}/
|
|
|
|
make -j $(nproc) all-target-libstdc++-v3
|
|
|
|
make install-target-libstdc++-v3
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-04-06 00:02:13 +03:00
|
|
|
if [[ -z $SYSROOT ]]; then
|
|
|
|
echo "You must set the SYSROOT environment variable" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $PREFIX ]]; then
|
|
|
|
echo "You must set the PREFIX environment variable" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
if [[ -z $ARCH ]]; then
|
2023-04-06 00:02:13 +03:00
|
|
|
echo "You must set the ARCH environment variable" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-04-06 00:23:02 +03:00
|
|
|
TARGET="${ARCH}-banan_os"
|
|
|
|
|
2023-04-06 00:02:13 +03:00
|
|
|
if [ ! -f ${PREFIX}/bin/${TARGET}-ld ]; then
|
|
|
|
|
|
|
|
echo "Building ${BINUTILS_VERSION}"
|
|
|
|
|
|
|
|
if [ ! -f ${BINUTILS_VERSION}.tar.xz ]; then
|
|
|
|
wget https://ftp.gnu.org/gnu/binutils/${BINUTILS_VERSION}.tar.xz
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $BINUTILS_VERSION ]; then
|
|
|
|
tar xvf ${BINUTILS_VERSION}.tar.xz
|
|
|
|
patch -s -p0 < ${BINUTILS_VERSION}.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p build/${BINUTILS_VERSION}/
|
|
|
|
pushd build/${BINUTILS_VERSION}/
|
|
|
|
|
|
|
|
../../${BINUTILS_VERSION}/configure \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--prefix="$PREFIX" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
2023-06-05 17:55:47 +03:00
|
|
|
--disable-nls \
|
2023-04-06 00:02:13 +03:00
|
|
|
--disable-werror
|
|
|
|
|
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f ${PREFIX}/bin/${TARGET}-g++ ]; then
|
|
|
|
|
|
|
|
echo "Building ${GCC_VERSION}"
|
|
|
|
|
|
|
|
if [ ! -f ${GCC_VERSION}.tar.xz ]; then
|
|
|
|
wget https://ftp.gnu.org/gnu/gcc/${GCC_VERSION}/${GCC_VERSION}.tar.xz
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $GCC_VERSION ]; then
|
|
|
|
tar xvf ${GCC_VERSION}.tar.xz
|
|
|
|
patch -s -p0 < ${GCC_VERSION}.patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p build/${GCC_VERSION}/
|
2023-10-16 01:37:12 +03:00
|
|
|
pushd build/${GCC_VERSION}/
|
2023-04-06 00:02:13 +03:00
|
|
|
|
|
|
|
../../${GCC_VERSION}/configure \
|
|
|
|
--target="$TARGET" \
|
|
|
|
--prefix="$PREFIX" \
|
|
|
|
--with-sysroot="$SYSROOT" \
|
2023-06-05 17:55:47 +03:00
|
|
|
--disable-nls \
|
2023-04-06 00:02:13 +03:00
|
|
|
--enable-languages=c,c++
|
|
|
|
|
2023-05-30 07:59:41 +03:00
|
|
|
make -j $(nproc) all-gcc
|
|
|
|
make -j $(nproc) all-target-libgcc CFLAGS_FOR_TARGET='-g -O2 -mcmodel=large -mno-red-zone'
|
2023-04-06 00:02:13 +03:00
|
|
|
make install-gcc install-target-libgcc
|
|
|
|
|
2023-10-16 01:37:12 +03:00
|
|
|
popd
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f ${PREFIX}/bin/grub-mkstandalone ]; then
|
|
|
|
|
|
|
|
echo "Building ${GRUB_VERSION}"
|
|
|
|
|
|
|
|
if [ ! -f ${GRUB_VERSION}.tar.xz ]; then
|
|
|
|
wget https://ftp.gnu.org/gnu/grub/${GRUB_VERSION}.tar.xz
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d $GRUB_VERSION ]; then
|
|
|
|
tar xvf ${GRUB_VERSION}.tar.xz
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p build/${GRUB_VERSION}/
|
|
|
|
pushd build/${GRUB_VERSION}/
|
|
|
|
|
|
|
|
../../${GRUB_VERSION}/configure \
|
|
|
|
--target="$ARCH" \
|
|
|
|
--prefix="$PREFIX" \
|
|
|
|
--with-platform="efi" \
|
|
|
|
--disable-werror
|
|
|
|
|
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
|
|
|
|
|
|
|
popd
|
|
|
|
|
2023-04-06 00:02:13 +03:00
|
|
|
fi
|