altcross: initial version based on https://github.com/abhiTronix/raspberry-pi-cross-compilers
This commit is contained in:
commit
891dc7c0fc
118
altcross.sh
Executable file
118
altcross.sh
Executable file
@ -0,0 +1,118 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -x
|
||||
|
||||
KERNEL_VERSION='5.4'
|
||||
BINUTILS_VERSION='2.31.1'
|
||||
GCC_VERSION='8.4.1-20200305'
|
||||
GLIBC_VERSION='2.27-alt13'
|
||||
|
||||
KERNEL_SOURCE="/usr/src/kernel/sources/kernel-source-${KERNEL_VERSION}.tar"
|
||||
BINUTILS_SOURCE="/usr/src/binutils-source/binutils-${BINUTILS_VERSION}.tar"
|
||||
GCC_SOURCE="/usr/src/gcc-source/gcc-${GCC_VERSION}.tar"
|
||||
GLIBC_SOURCE="/usr/src/glibc-source/glibc-${GLIBC_VERSION}.tar"
|
||||
|
||||
|
||||
TARGET=aarch64-linux-gnu
|
||||
|
||||
BUILDDIR="`pwd`/build"
|
||||
SRCDIR="`pwd`/src"
|
||||
INSTALLDIR="`pwd`/inst/altcross-gcc-${GCC_VERSION}"
|
||||
SYSROOT=/$TARGET/libc
|
||||
SYSROOTDIR="$INSTALLDIR/$SYSROOT"
|
||||
|
||||
mkdir -p -m755 "$SRCDIR"
|
||||
cd "$SRCDIR"
|
||||
|
||||
tar xf "$KERNEL_SOURCE"
|
||||
tar xf "$BINUTILS_SOURCE"
|
||||
tar xf "$GCC_SOURCE"
|
||||
tar xf "$GLIBC_SOURCE"
|
||||
|
||||
cd "gcc-${GCC_VERSION}"
|
||||
sed -i contrib/download_prerequisites -e '/base_url=/s/ftp/http/'
|
||||
./contrib/download_prerequisites
|
||||
|
||||
mkdir -p -m755 "$INSTALLDIR/bin"
|
||||
export PATH="$INSTALLDIR/bin:$PATH"
|
||||
unset LD_LIBRARY_PATH
|
||||
|
||||
mkdir -p -m755 \
|
||||
"$BUILDDIR/obj_binutils" \
|
||||
"$BUILDDIR/obj_gcc" \
|
||||
"$BUILDDIR/obj_glibc" \
|
||||
"$BUILDDIR/obj_kernel" \
|
||||
|
||||
make -j$(nproc) \
|
||||
-C "$SRCDIR/kernel-source-${KERNEL_VERSION}" \
|
||||
O="$BUILDDIR/obj_kernel" \
|
||||
ARCH=arm64 \
|
||||
INSTALL_HDR_PATH="$SYSROOTDIR/usr" \
|
||||
headers_install
|
||||
|
||||
# binutils
|
||||
|
||||
cd "$BUILDDIR/obj_binutils"
|
||||
../../src/binutils-${BINUTILS_VERSION}/configure \
|
||||
--target="$TARGET" \
|
||||
--prefix= \
|
||||
--with-sysroot="$SYSROOT" \
|
||||
--with-build-sysroot="$SYSROOTDIR" \
|
||||
--disable-multilib
|
||||
|
||||
make -j$(nproc)
|
||||
make -j$(nproc) install DESTDIR="$INSTALLDIR"
|
||||
|
||||
# gcc
|
||||
cd "$BUILDDIR/obj_gcc"
|
||||
../../src/gcc-${GCC_VERSION}/configure \
|
||||
--prefix= \
|
||||
--target=$TARGET \
|
||||
--enable-languages=c,c++ \
|
||||
--with-sysroot="$SYSROOT" \
|
||||
--with-build-sysroot="$SYSROOTDIR" \
|
||||
--disable-multilib
|
||||
|
||||
# compiler only
|
||||
make -j$(nproc) all-gcc
|
||||
make -j$(nproc) install-gcc DESTDIR="$INSTALLDIR"
|
||||
|
||||
|
||||
# glibc
|
||||
|
||||
cd "$BUILDDIR/obj_glibc"
|
||||
../../src/glibc-${GLIBC_VERSION}/configure \
|
||||
--prefix=/usr \
|
||||
--target=$TARGET \
|
||||
--host=$TARGET \
|
||||
--build="$MACHTYPE" \
|
||||
--with-sysroot="$SYSROOT" \
|
||||
--with-build-sysroot="$SYSROOTDIR" \
|
||||
--with-headers="$SYSROOTDIR"/usr/include \
|
||||
--with-lib="$SYSROOTDIR"/usr/lib \
|
||||
--disable-multilib \
|
||||
--disable-crypt \
|
||||
libc_cv_forced_unwind=yes
|
||||
|
||||
# glibc: headers + C runtime bits
|
||||
make -j$(nproc) install-bootstrap-headers=yes install-headers DESTDIR="$SYSROOTDIR"
|
||||
make -j$(nproc) csu/subdir_lib
|
||||
install -d -m755 "$SYSROOTDIR"/usr/lib
|
||||
install csu/crt1.o csu/crti.o csu/crtn.o "$SYSROOTDIR"/usr/lib
|
||||
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null -o "$SYSROOTDIR"/usr/lib/libc.so
|
||||
touch "$SYSROOTDIR"/usr/include/gnu/stubs.h "$SYSROOTDIR"/usr/include/bits/stdio_lim.h
|
||||
|
||||
# GCC: runtime (libgcc)
|
||||
cd "$BUILDDIR/obj_gcc"
|
||||
make -j$(nproc) all-target-libgcc
|
||||
make -j$(nproc) install-target-libgcc DESTDIR="$INSTALLDIR"
|
||||
|
||||
# finish off glibc
|
||||
cd "$BUILDDIR/obj_glibc"
|
||||
make -j$(nproc)
|
||||
make install DESTDIR="$SYSROOTDIR"
|
||||
|
||||
# finish off GCC
|
||||
cd "$BUILDDIR/obj_gcc"
|
||||
make -j$(nproc)
|
||||
make -j$(nproc) install DESTDIR="$INSTALLDIR"
|
Loading…
Reference in New Issue
Block a user