24
24
# This script aauto downloads, compiles, and compresses Cross & Native GCC ARM64 Toolchain
25
25
# binaries targeting any Raspberry Pi 64-bit (like Pi64) OSes.
26
26
27
+ set -eo pipefail
28
+
27
29
helpfunction () {
28
30
# helper function that prints custom usage help menu
29
31
echo " "
@@ -51,15 +53,14 @@ while getopts "g:o:V" opt; do
51
53
VERBOSE=1
52
54
echo " Info: Activated verbose output!"
53
55
echo " "
54
- set -eov pipefail # Set verbose mode.
56
+ set -v # Set verbose mode.
55
57
;;
56
58
? ) helpfunction ;; # prints help function for invalid parameter
57
59
esac
58
60
done
59
61
# validates parameters and print usage helper function in case parameters are missing
60
62
if [ -z " $VERBOSE " ]; then
61
63
VERBOSE=0
62
- set -eo pipefail # stop the script and exit with return code != 0 if errored
63
64
fi
64
65
if [ -z " $GCC_VERSION " ] || [ -z " $RPIOS_TYPE " ]; then
65
66
echo " Error: Required parameters are missing!"
@@ -135,7 +136,7 @@ mkdir -p "$INSTALLDIR"
135
136
cd " $DOWNLOADDIR " || exit
136
137
# download binaries if not found
137
138
if [ ! -d " linux" ]; then
138
- wget -q https://github.com/$( wget -q https://github.com/raspberrypi/linux/releases/latest -O - | egrep ' /.*/.*/.*.tar.gz' -o)
139
+ wget -q https://github.com/$( wget -q https://github.com/raspberrypi/linux/releases/latest -O - | egrep ' /.*/.*/.*.tar.gz' -o | head -n1 )
139
140
tar xf raspberrypi* .tar.gz
140
141
mv linux* linux
141
142
rm ./* .tar.*
@@ -217,15 +218,15 @@ if [ -n "$(ls -A "$DOWNLOADDIR"/binutils-$BINUTILS_VERSION/build)" ]; then rm -r
217
218
cd " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build || exit
218
219
../configure --target=$TARGET --prefix= --with-arch=$ARCH --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --disable-multilib
219
220
make -s -j$( nproc)
220
- make -s install DESTDIR=" $INSTALLDIR "
221
+ make -s install-strip DESTDIR=" $INSTALLDIR "
221
222
if [ -n " $( ls -A " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /binutils-$BINUTILS_VERSION /build/* ; fi
222
223
223
224
echo " Building Cross GCC $GCCBASE_VERSION Binaries..."
224
225
if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build/* ; fi
225
226
cd " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build || exit
226
227
../configure --prefix= --target=$TARGET --enable-languages=$LANGUAGES --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-arch=$ARCH --disable-multilib
227
228
make -s -j$( nproc) all-gcc
228
- make -s install-gcc DESTDIR=" $INSTALLDIR "
229
+ make -s install-strip- gcc DESTDIR=" $INSTALLDIR "
229
230
if [ -n " $( ls -A " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build/* ; fi
230
231
cd " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build || exit
231
232
../configure --prefix=/usr --build=" $MACHTYPE " --host=$TARGET --target=$TARGET --with-arch=$ARCH --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-headers=" $SYSROOTDIR " /usr/include --with-lib=" $SYSROOTDIR " /usr/lib --disable-multilib libc_cv_forced_unwind=yes
@@ -243,15 +244,15 @@ make -s install DESTDIR="$SYSROOTDIR"
243
244
cd " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build || exit
244
245
if [ -n " $( ls -A " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /glibc-$GLIBC_VERSION /build/* ; fi
245
246
make -s -j$( nproc)
246
- make -s install DESTDIR=" $INSTALLDIR "
247
+ make -s install-strip DESTDIR=" $INSTALLDIR "
247
248
if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-$GCCBASE_VERSION /build/* ; fi
248
249
249
250
if [ " $GCC_VERSION " != " $GCCBASE_VERSION " ]; then
250
251
cd " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build || exit
251
252
if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build/* ; fi
252
253
../configure --prefix= --target=$TARGET --enable-languages=$LANGUAGES --with-sysroot=/$TARGET /libc --with-build-sysroot=" $SYSROOTDIR " --with-arch=$ARCH --disable-multilib
253
254
make -s -j$( nproc)
254
- make -s install DESTDIR=" $INSTALLDIR "
255
+ make -s install-strip DESTDIR=" $INSTALLDIR "
255
256
if [ -n " $( ls -A " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build) " ]; then rm -rf " $DOWNLOADDIR " /gcc-" $GCC_VERSION " /build/* ; fi
256
257
257
258
echo " Building GCC Native GCC $GCC_VERSION Binaries..."
0 commit comments