-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsetup-crosstools-workspace
executable file
·110 lines (94 loc) · 2.75 KB
/
setup-crosstools-workspace
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/sh
srcdir="`dirname $0`"
binutils_version="2.38"
gcc_version="11.4.0"
sysroot=""
should_patch="yes"
for i in "$@"
do
case $i in
--sysroot=*)
sysroot=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--binutils-version=*)
binutils_version=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--gcc-version=*)
gcc_version=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--no-patch)
should_patch="no"
;;
*)
echo >&2 "$0: unrecognised command-line option: $i"
exit 1
;;
esac
done
if [ "`ls`" != "" ]
then
echo >&2 "$0: you must run me in an empty directory"
exit 1
fi
if [ "$sysroot" = "" ]
then
echo >&2 "$0: you must specify a --sysroot for the cross-compiler"
exit 1
fi
if [ "$should_patch" = "yes" ]
then
if [ ! -f $srcdir/binutils/binutils-$binutils_version.patch ]
then
echo >&2 "$0: no patch for version $binutils_version of binutils!"
exit 1
fi
if [ ! -f $srcdir/gcc/gcc-$gcc_version.patch ]
then
echo >&2 "$0: no patch for version $gcc_version of gcc!"
exit 1
fi
fi
echo "Downloading binutils..."
rm -f binutils-$binutils_version.tar.gz
wget https://ftp.gnu.org/gnu/binutils/binutils-$binutils_version.tar.gz || exit 1
tar -xzf binutils-$binutils_version.tar.gz || exit 1
mv binutils-$binutils_version glidix-binutils || exit 1
tar -xzf binutils-$binutils_version.tar.gz || exit 1
echo "Downloading GCC..."
rm -f gcc-$gcc_version.tar.gz
wget ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-$gcc_version/gcc-$gcc_version.tar.gz || exit 1
tar -xzf gcc-$gcc_version.tar.gz || exit 1
mv gcc-$gcc_version glidix-gcc || exit 1
tar -xzf gcc-$gcc_version.tar.gz || exit 1
cd gcc-$gcc_version
./contrib/download_prerequisites
cd ../glidix-gcc
./contrib/download_prerequisites
cd ..
if [ "$should_patch" = "yes" ]
then
echo "Patching binutils..."
cd glidix-binutils
patch -p1 < ../$srcdir/binutils/binutils-$binutils_version.patch || exit 1
cd ..
echo "Patching GCC..."
cd glidix-gcc
patch -p1 < ../$srcdir/gcc/gcc-$gcc_version.patch || exit 1
cd ..
fi
echo "Generating install script..."
echo >install.sh "#! /bin/sh"
echo >>install.sh "GCC_VERSION=$gcc_version"
echo >>install.sh "BINUTILS_VERSION=$binutils_version"
echo >>install.sh "SRCDIR=$srcdir"
echo >>install.sh "SYSROOT=$sysroot"
cat >>install.sh $srcdir/crosstools-install
chmod +x install.sh
echo "Generating install-stage2 script..."
cp $srcdir/crosstools-install-stage2 install-stage2.sh
chmod +x install-stage2.sh
echo "Generating make-patches script..."
echo >make-patches.sh "#! /bin/sh"
echo >>make-patches.sh "diff --no-dereference -urN binutils-$binutils_version glidix-binutils > $srcdir/binutils/binutils-$binutils_version.patch"
echo >>make-patches.sh "diff --no-dereference -urN gcc-$gcc_version glidix-gcc > $srcdir/gcc/gcc-$gcc_version.patch"
chmod +x make-patches.sh