mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Updated build_cross_gcc script and renamed. (#2557)
This commit is contained in:
178
tools/build_cros_gcc
Executable file
178
tools/build_cros_gcc
Executable file
@@ -0,0 +1,178 @@
|
||||
#!/bin/bash
|
||||
|
||||
GLIBC=glibc-$(crew search glibc -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1)
|
||||
BINUTILS=binutils-2.31.1
|
||||
GCC=gcc-8.2.0
|
||||
MPFR=mpfr-4.0.1
|
||||
GMP=gmp-6.1.2
|
||||
MPC=mpc-1.1.0
|
||||
ISL=isl-0.20
|
||||
CLOOG=cloog-0.18.4
|
||||
|
||||
KERNEL_VERSION=$(crew search linuxheaders -v | tail -1 | cut -d' ' -f2 | cut -d'-' -f1).1
|
||||
|
||||
MAJOR_VERSION="$(echo $KERNEL_VERSION | cut -c1)"
|
||||
|
||||
case $1 in
|
||||
-h|--help) echo USAGE:
|
||||
echo \ $0 target arch_type prefix
|
||||
echo \ \-h, --help: Display this help
|
||||
echo \ \-v, --version: Display version
|
||||
echo \ \-t, --const: Display constants
|
||||
echo \ \-c, --clean: Clean current directory
|
||||
echo \ Valid targets: 'aarch64-cros-linux-gnu', 'x86_64-cros-linux-gnu', 'i686-cros-linux-gnu', 'armv7l-cros-linux-gnueabihf'
|
||||
shift
|
||||
exit 0;;
|
||||
-v|--version) echo build_cros_gcc version 1.26
|
||||
shift
|
||||
exit 0;;
|
||||
-c|--clean) rm -rf build-binutils build-gcc build-glibc
|
||||
rm -rf \
|
||||
./$GCC \
|
||||
./$CLOOG \
|
||||
./$GMP \
|
||||
./$GLIBC \
|
||||
./$BINUTILS \
|
||||
./$MPFR \
|
||||
./$MPC \
|
||||
./linux-$KERNEL_VERSION \
|
||||
./$ISL \
|
||||
./$GLIBC.tar.xz \
|
||||
./$GMP.tar.xz \
|
||||
./$GCC.tar.xz \
|
||||
./$BINUTILS.tar.xz \
|
||||
./linux-$KERNEL_VERSION.tar.xz \
|
||||
./$MPFR.tar.xz \
|
||||
./$CLOOG.tar.gz \
|
||||
./$ISL.tar.bz2 \
|
||||
./$MPC.tar.gz || true
|
||||
shift
|
||||
exit 0;;
|
||||
-t|--const)
|
||||
echo KERNEL_VERSION=$KERNEL_VERSION
|
||||
echo MAJOR_VERSION=$MAJOR_VERSION
|
||||
echo CLOOG=$CLOOG
|
||||
echo ISL=$ISL
|
||||
echo MPC=$MPC
|
||||
echo GMP=$GMP
|
||||
echo MPFR=$MPFR
|
||||
echo GCC=$GCC
|
||||
echo BINUTILS=$BINUTILS
|
||||
echo GLIBC=$GLIBC
|
||||
shift
|
||||
exit 0;;
|
||||
armv7l-cros-linux-gnueabihf)
|
||||
true;;
|
||||
aarch64-cros-linux-gnu)
|
||||
true;;
|
||||
i686-cros-linux-gnu)
|
||||
true;;
|
||||
x86_64-cros-linux-gnu)
|
||||
true;;
|
||||
*)
|
||||
echo Invalid target or option \'$1\'
|
||||
$0 -h
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
# '\033[1;31' outputs red text. '\033[0m' reverts it to normal.
|
||||
command -v crew > /dev/null || { echo "\033[1;31mcrew command not found.\033[0m"; exit 1; }
|
||||
|
||||
if test ! $2; then
|
||||
echo "$1" | grep x86_64 1>/dev/null
|
||||
if [ $? == 0 ]; then
|
||||
$0 $1 x86 $3;
|
||||
exit 0;
|
||||
fi
|
||||
echo "$1" | grep i686 1>/dev/null
|
||||
if [ $? == 0 ]; then
|
||||
$0 $1 x86 $3;
|
||||
exit 0;
|
||||
fi
|
||||
echo "$1" | grep armv7l 1>/dev/null
|
||||
if [ $? == 0 ]; then
|
||||
$0 $1 arm $3;
|
||||
exit 0;
|
||||
fi
|
||||
echo "$1" | grep aarch64 1>/dev/null
|
||||
if [ $? == 0 ]; then
|
||||
$0 $1 arm64 $3;
|
||||
exit 0;
|
||||
fi
|
||||
fi
|
||||
if test ! $3; then
|
||||
$0 $1 $2 $(crew const CREW_PREFIX | cut -d'=' -f2)
|
||||
exit 0
|
||||
fi
|
||||
|
||||
$0 -c
|
||||
|
||||
echo $1 $2 $3
|
||||
|
||||
wget https://ftpmirror.gnu.org/gnu/binutils/$BINUTILS.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/gcc/$GCC/$GCC.tar.xz
|
||||
wget https://www.kernel.org/pub/linux/kernel/v"$MAJOR_VERSION".x/linux-$KERNEL_VERSION.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/libc/$GLIBC.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/mpfr/$MPFR.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/gmp/$GMP.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/mpc/$MPC.tar.gz
|
||||
wget http://isl.gforge.inria.fr/$ISL.tar.bz2
|
||||
wget https://www.bastoul.net/cloog/pages/download/$CLOOG.tar.gz
|
||||
|
||||
for tar in *.tar*; do tar xpf $tar; done
|
||||
|
||||
rm -f \
|
||||
./$GLIBC.tar.xz \
|
||||
./$GMP.tar.xz \
|
||||
./$GCC.tar.xz \
|
||||
./$BINUTILS.tar.xz \
|
||||
./linux-$KERNEL_VERSION.tar.xz \
|
||||
./$MPFR.tar.xz \
|
||||
./$CLOOG.tar.gz \
|
||||
./$ISL.tar.bz2 \
|
||||
./$MPC.tar.gz
|
||||
|
||||
cd $GCC
|
||||
ln -s ../$CLOOG cloog
|
||||
ln -s ../$ISL isl
|
||||
ln -s ../$MPC mpc
|
||||
ln -s ../$GMP gmp
|
||||
ln -s ../$MPFR mpfr
|
||||
cd ..
|
||||
mkdir build-binutils || true
|
||||
cd build-binutils
|
||||
../$BINUTILS/configure --prefix=$3 --target=$1 --disable-multilib
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
cd linux-$KERNEL_VERSION
|
||||
make ARCH=$2 INSTALL_HDR_PATH=$3/$1 headers_install
|
||||
cd ..
|
||||
mkdir build-gcc || true
|
||||
cd build-gcc
|
||||
../$GCC/configure --disable-libmpx --prefix=$3 --target=$1 --enable-shared --enable-host-shared --enable-languages=c,c++,fortran,go --disable-multilib
|
||||
make -j$(nproc) all-gcc
|
||||
make install-gcc
|
||||
cd ..
|
||||
mkdir build-glibc || true
|
||||
cd build-glibc
|
||||
../$GLIBC/configure --disable-libmpx --prefix=$3/$1 --enable-shared --enable-host-shared --build=$MACHTYPE --host=$1 --target=$1 --with-headers=$3/$1/include --disable-multilib libc_cv_forced_unwind=yes
|
||||
make install-bootstrap-headers=yes install-headers
|
||||
make -j$(nproc) csu/subdir_lib
|
||||
install csu/crt1.o csu/crti.o csu/crtn.o $3/$1/lib
|
||||
$1-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o $3/$1/lib/libc.so
|
||||
touch $3/$1/include/gnu/stubs.h
|
||||
cd ..
|
||||
cd build-gcc
|
||||
make -j$(nproc) all-target-libgcc
|
||||
make install-target-libgcc
|
||||
cd ..
|
||||
cd build-glibc
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
cd build-gcc
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
$1-gcc -v
|
||||
@@ -1,116 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
case $1 in
|
||||
|
||||
-h) echo USAGE:
|
||||
echo \ $0 [options] target arch_type kernel_version
|
||||
echo \ \-h, --help: Display help
|
||||
echo \ \-v, --version: Display version
|
||||
echo \ \-c, --clean: Clean current directory
|
||||
shift
|
||||
exit 0;;
|
||||
--help) echo USAGE:
|
||||
echo \ $0 target arch_type kernel_version
|
||||
echo \ \-h, --help: Display help
|
||||
echo \ \-v, --version: Display version
|
||||
echo \ \-c, --clean: Clean current directory
|
||||
shift
|
||||
exit 0;;
|
||||
-v) echo build_cross_gcc version 1.2.0
|
||||
shift
|
||||
exit 0;;
|
||||
--version) echo build_cross_gcc version 1.2.0
|
||||
shift
|
||||
exit 0;;
|
||||
-c) rm -rf build-binutils build-gcc build-glibc
|
||||
rm -rf \
|
||||
./gcc-8.2.0 \
|
||||
./cloog-0.18.4 \
|
||||
./gmp-6.1.2 \
|
||||
./glibc-2.28 \
|
||||
./binutils-2.31.1 \
|
||||
./mpfr-4.0.1 \
|
||||
./mpc-1.1.0 \
|
||||
./linux-3.18.1 \
|
||||
./isl-0.20
|
||||
shift
|
||||
exit 0;;
|
||||
--clean) rm -rf build-binutils build-gcc build-glibc
|
||||
rm -rf \
|
||||
./gcc-8.2.0 \
|
||||
./cloog-0.18.4 \
|
||||
./gmp-6.1.2 \
|
||||
./glibc-2.28 \
|
||||
./binutils-2.31.1 \
|
||||
./mpfr-4.0.1 \
|
||||
./mpc-1.1.0 \
|
||||
./linux-3.18.1 \
|
||||
./isl-0.20
|
||||
shift
|
||||
exit 0;;
|
||||
esac
|
||||
|
||||
export major_version="$(echo $3 | cut -c1)"
|
||||
|
||||
wget https://ftpmirror.gnu.org/gnu/binutils/binutils-2.31.1.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/gcc/gcc-8.2.0/gcc-8.2.0.tar.xz
|
||||
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v"$major_version".x/linux-$3.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/libc/glibc-2.28.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/mpfr/mpfr-4.0.1.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz
|
||||
wget https://ftpmirror.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
|
||||
wget http://isl.gforge.inria.fr/isl-0.20.tar.bz2
|
||||
wget https://www.bastoul.net/cloog/pages/download/cloog-0.18.4.tar.gz
|
||||
|
||||
for tar in *.tar*; do tar xpf $tar; done
|
||||
|
||||
rm -f \
|
||||
./glibc-2.28.tar.xz \
|
||||
./gmp-6.1.2.tar.xz \
|
||||
./gcc-8.2.0.tar.xz \
|
||||
./binutils-2.31.1.tar.xz \
|
||||
./linux-3.18.1.tar.xz \
|
||||
./mpfr-4.0.1.tar.xz \
|
||||
./cloog-0.18.4.tar.gz \
|
||||
./isl-0.20.tar.bz2 \
|
||||
./mpc-1.1.0.tar.gz \
|
||||
|
||||
mkdir build-binutils || true
|
||||
cd build-binutils
|
||||
../binutils-2.31.1/configure --prefix=/usr/local --target=$1
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
cd linux-$3
|
||||
make ARCH=$2 INSTALL_HDR_PATH=/usr/local/$1 headers_install
|
||||
cd ..
|
||||
mkdir build-gcc || true
|
||||
cd build-gcc
|
||||
../gcc-8.2.0/configure --prefix=/usr/local --target=$1 --enable-languages=c,c++,fortran --disable-multilib
|
||||
make -j$(nproc) all-gcc
|
||||
make install-gcc
|
||||
cd ..
|
||||
mkdir build-glibc || true
|
||||
cd build-glibc
|
||||
../glibc-2.28/configure --disable-libmpx --prefix=/usr/local/$1 --disable-werror --enable-shared --build=$MACHTYPE --host=$1 --with-headers=/usr/local/$1/include --disable-multilib libc_cv_forced_unwind=yes
|
||||
make install-bootstrap-headers=yes install-headers
|
||||
make -j$(nproc) csu/subdir_lib
|
||||
install csu/crt1.o csu/crti.o csu/crtn.o /usr/local/$1/lib
|
||||
$1-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o /usr/local/$1/lib/libc.so
|
||||
touch /usr/local/$1/include/gnu/stubs.h
|
||||
cd ..
|
||||
cd build-gcc
|
||||
make -j$(nproc) all-target-libgcc
|
||||
make install-target-libgcc
|
||||
cd ..
|
||||
cd build-glibc
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
cd build-gcc
|
||||
make -j$(nproc)
|
||||
make install
|
||||
cd ..
|
||||
$1-gcc -v
|
||||
Reference in New Issue
Block a user