-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtools.sh
executable file
·210 lines (181 loc) · 5.63 KB
/
tools.sh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/bin/sh
KERNEL="4.20.12" #matches tested LFS tree, should later match with Kernel for
# proper headers.
ARCH="x86_64-teeny-linux-gnu" #slightly diferent from build, this matches LFS
BINUTIL="2.32"
GCC="8.2.0"
MPFR="4.0.2"
GMP="6.1.2"
MPC="1.1.0"
GLIBC="2.29"
TOP=$HOME/Projects/Emulation/Linux/tools #location of the packages and building dirs, gets cleaned
PREFIX="/tools" #if you change this, the gcc
# will end up elsewhere in the initramfs
ROOTLOC="$HOME/Projects/Emulation/Linux/root" #build.sh expects the gcc stuff to be here to copy
# it into the initramfs later.
#DO NOT EDIT BELOW HERE should not be nececairy.
#-----------------------------------------------------------
#first stuff happening here.
mkdir -p $TOP
cd $TOP
#-----------------------------------------------------------------------
# compile the thing
function MakeBIN1 {
cd $TOP
tar -xvf binutils-$BINUTIL.tar.xz
cd binutils-$BINUTIL/
mkdir -v build
cd build
../configure --prefix=$TOP \
--with-sysroot=$TOP \
--with-lib-path=$TOP/lib \
--target=$ARCH \
--disable-nls \
--disable-werror
make -j8
#-----------------------if x64
mkdir -v $TOP/lib && ln -sv lib $TOP/lib64
make install
rm -rf binutils-$BINUTIL/
}
#-----------------------------------------------------------------------
function MakeGCCP1 {
cd $TOP
tar -xvf gcc-$GCC.tar.xz
cd gcc-$GCC/
tar -xf ../mpfr-$MPFR.tar.xz
mv -v mpfr-$MPFR mpfr
tar -xf ../gmp-$GMP.tar.xz
mv -v gmp-$GMP gmp
tar -xf ../mpc-$MPC.tar.gz
mv -v mpc-$MPC mpc
---------------------- if x86_64
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac
--------------------------
mkdir -v build
cd build
../configure \
--target=$ARCH \
--prefix=$TOP \
--with-glibc-version=2.11 \
--with-sysroot=$TOP \
--with-newlib \
--without-headers \
--with-local-prefix=$TOP \
--with-native-system-header-dir=$TOP/include \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libmpx \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++
make -j8
make install
rm -rf gcc-$GCC/
}
#-----------------------------------------------------------------------
function LinHeaders {
cd $TOP
tar -xvf linux-$KERNEL.tar.xz
cd linux-$KERNEL/
make mrproper
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* $TOP/include
rm -rf linux-$KERNEL/
}
#-----------------------------------------------------------------------
function GlibC {
cd $TOP
tar -xvf glibc-$GLIBC.tar.xz
cd glibc-$GLIBC/
mkdir -v build
cd build
../configure \
--prefix=$TOP \
--host=$ARCH \
--build=$(../scripts/config.guess) \
--enable-kernel=3.2 \
--with-headers=$TOP/include
make
make install
rm -rf glibc-$GLIBC/
}
#-----------------------------------------------------------------------
function LibSTDC {
cd $TOP
tar -xvf gcc-$GCC.tar.xz
cd gcc-$GCC/
rm -rf gcc-$GCC/
}
#-----------------------------------------------------------------------
function MakeBIN2 {
cd $TOP
tar -xvf binutils-$BINUTIL.tar.xz
cd binutils-$BINUTIL/
rm -rf binutils-$BINUTIL/
}
#-----------------------------------------------------------------------
function MakeGCCP2 {
cd $TOP
tar -xvf gcc-$GCC.tar.xz
cd gcc-$GCC/
rm -rf gcc-$GCC/
}
#----------------------------------------------------------------------
#process commandline arguments
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-arch|-cpu)
ARCH="$2"
shift; shift # past argument and value
;;
esac
done
#sets defaults if arguments are empty or incorrect
if [ -z $ARCH ]; then
ARCH="x86_64"; fi
cd $TOP
#Download if nececairy, clean an unclean build
if [ ! -f $TOP/linux-$KERNEL.tar.$KTYPE ]; then
wget -c https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-$KERNEL.tar.xz
fi
if [ ! -f $TOP/binutils-$BINUTIL.tar.xz ]; then
wget -c http://ftp.gnu.org/gnu/binutils/binutils-$BINUTIL.tar.xz
fi
if [ ! -f $TOP/gcc-$GCC.tar.xz ]; then
wget -c http://ftp.gnu.org/gnu/gcc/gcc-8.2.0/gcc-$GCC.tar.xz
fi
if [ ! -f $TOP/mpc-$MPC.tar.gz ]; then
wget -c https://ftp.gnu.org/gnu/mpc/mpc-$MPC.tar.gz
fi
if [ ! -f $TOP/gmp-$GMP.tar.xz ]; then
wget -c http://ftp.gnu.org/gnu/gmp/gmp-$GMP.tar.xz
fi
if [ ! -f $TOP/mpfr-$MPFR.tar.xz ]; then
wget -c http://www.mpfr.org/mpfr-4.0.2/mpfr-$MPFR.tar.xz
fi
if [ ! -f $TOP/glibc-$GLIBC.tar.xz ]; then
wget -c http://ftp.gnu.org/gnu/glibc/glibc-$GLIBC.tar.xz
fi
# Here we build all the software in order
MakeBIN1
MakeGCCP1
LinHeaders
GlibC
#LibSTDC
#MakeBIN2
#MakeGCCP2