-
Notifications
You must be signed in to change notification settings - Fork 4
/
pass2.sh
436 lines (349 loc) · 7.34 KB
/
pass2.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#!/bin/bash
LFS_TGT=$(uname -m)-lfs-linux-gnu
LFS=/mnt/lfs
testToolchain ()
{
echo 'main(){}' > dummy.c
cc dummy.c
TCT=$(readelf -l a.out | grep ': /tools')
echo "toolchain test: "
if [ -n "$TCT" ] ; then
echo "$TCT"
echo "passed"
rm -v dummy.c a.out
else
echo "failed"
exit 1;
fi
}
##########################
# Binutils 2.22 - Pass 2 #
##########################
tar -jxf binutils-2.22.tar.bz2
mkdir -v binutils-build
cd binutils-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../binutils-2.22/configure --prefix=/tools \
--disable-nls --with-lib-path=/tools/lib
make -j4
make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
cd ..
rm -rf binutils-build binutils-2.22
######################
# GCC 4.6.2 - Pass 2 #
######################
tar jxf gcc-4.6.2.tar.bz2
cd gcc-4.6.2
## Apply startfiles patch
patch -Np1 -i ../gcc-4.6.2-startfiles_fix-1.patch
cp -v gcc/Makefile.in{,.orig}
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
cp -v gcc/Makefile.in{,.tmp}
sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp > gcc/Makefile.in
for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
-e 's@/usr@/tools@g' $file.orig > $file
echo '
#undef STANDARD_INCLUDE_DIR
#define STANDARD_INCLUDE_DIR 0
#define STANDARD_STARTFILE_PREFIX_1 ""
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
touch $file.orig
done
case $(uname -m) in
x86_64)
for file in $(find gcc/config -name t-linux64) ; do \
cp -v $file{,.orig}
sed '/MULTILIB_OSDIRNAMES/d' $file.orig > $file
done
;;
esac
tar -jxf ../mpfr-3.1.0.tar.bz2
mv -v mpfr-3.1.0 mpfr
tar -Jxf ../gmp-5.0.4.tar.xz
mv -v gmp-5.0.4 gmp
tar -zxf ../mpc-0.9.tar.gz
mv -v mpc-0.9 mpc
mkdir -v ../gcc-build
cd ../gcc-build
CC="$LFS_TGT-gcc -B/tools/lib/" \
AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib \
../gcc-4.6.2/configure --prefix=/tools \
--with-local-prefix=/tools --enable-clocale=gnu \
--enable-shared --enable-threads=posix \
--enable-__cxa_atexit --enable-languages=c,c++ \
--disable-libstdcxx-pch --disable-multilib \
--disable-bootstrap --disable-libgomp \
--without-ppl --without-cloog \
--with-mpfr-include=$(pwd)/../gcc-4.6.2/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs
make -j4
make install
ln -vs gcc /tools/bin/cc
rm -rf gcc-build gcc-4.6.2
## Test for proper tool chain execution
testToolchain
############################
# #
# Build other packages #
# #
############################
##############
# Tcl 8.5.11 #
##############
tar xzf tcl8.5.11-src.tar.gz
cd tcl8.5.11
cd unix/
./configure --prefix=/tools
make -j4
TZ=UTC make test
make install
chmod -v u+w /tools/lib/libtcl8.5.so
make install-private-headers
ln -sv tclsh8.5 /tools/bin/tclsh
cd ../../
rm -rf tcl8.5.11
###############
# Expect 5.45 #
###############
tar xf expect5.45.tar.gz
cd expect5.45
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
./configure --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=/tools/include
make -j4
make test
make SCRIPTS="" install
cd ..
rm -rf expect5.45
###############
# DejaGNU 1.5 #
###############
tar xf dejagnu-1.5.tar.gz
cd dejagnu-1.5
./configure --prefix=/tools
make install
make check
cd ..
rm -rf dejagnu-1.5
###############
# Check 0.9.8 #
###############
tar xf check-0.9.8.tar.gz
cd check-0.9.8
./configure --prefix=/tools
make -j4
make check
make install
cd ..
rm -rf check-0.9.8
###############
# Ncurses 5.9 #
###############
tar xf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --prefix=/tools --with-shared --without-debug --without-ada --enable-overwrite
make -j4
make install
cd ..
rm -rf ncurses-5.9
############
# Bash 4.2 #
############
tar xf bash-4.2.tar.gz
cd bash-4.2
patch -Np1 -i ../bash-4.2-fixes-4.patch
./configure --prefix=/tools --without-bash-malloc
make -j4
make tests
make install
ln -sv bash /tools/bin/sh
cd ..
rm -rf bash-4.2
##############
# Bzip 1.0.6 #
##############
tar xf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6
make
make PREFIX=/tools install
cd ..
rm -rf bzip2-1.0.6
##################
# Coreutils 8.15 #
##################
tar xf coreutils-8.15.tar.xz
cd coreutils-8.15
./configure --prefix=/tools --enable-install-program=hostname
make -j4
make install
cp -v src/su /tools/bin/su-tools
cd ..
rm -rf coreutils-8.15
#################
# Diffutils 3.2 #
#################
tar xf diffutils-3.2.tar.gz
cd diffutils-3.2
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf diffutils-3.2
#############
# File 5.10 #
#############
tar xf file-5.10.tar.gz
cd file-5.10
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf file-5.10
###################
# Findutils 4.4.2 #
###################
tar xf findutils-4.4.2.tar.gz
cd findutils-4.4.2
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf findutils-4.4.2
##############
# Gawk 4.0.0 #
##############
tar xf gawk-4.0.0.tar.bz2
cd gawk-4.0.0
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf gawk-4.0.0
####################
# Gettext 0.18.1.1 #
####################
tar xf gettext-0.18.1.1.tar.gz
cd gettext-0.18.1.1/gettext-tools
./configure --prefix=/tools --disable-shared
make -C gnulib-lib
make -C src msgfmt
cp -v src/msgfmt /tools/bin
cd ../../
rm -rf gettext-0.18.1.1
#############
# Grep 2.10 #
#############
tar xf grep-2.10.tar.xz
cd grep-2.10
./configure --prefix=/tools --disable-perl-regexp
make -j4
make install
cd ..
rm -rf grep-2.10
############
# Gzip 1.4 #
############
tar xf gzip-1.4.tar.gz
cd gzip-1.4
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf gzip-1.4
#############
# M4 1.4.16 #
#############
tar xf m4-1.4.16.tar.bz2
cd m4-1.4.16
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf m4-1.4.16
#############
# make 3.82 #
#############
tar xf make-3.82.tar.bz2
cd make-3.82
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf make-3.82
###############
# Patch 2.6.1 #
###############
tar xf patch-2.6.1.tar.bz2
cd patch-2.6.1
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf patch-2.6.1
###############
# Perl 5.14.2 #
###############
tar xf perl-5.14.2.tar.bz2
cd perl-5.14.2
patch -Np1 -i ../perl-5.14.2-libc-1.patch
sh Configure -des -Dprefix=/tools
make -j4
cp -v perl cpan/podlators/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.14.2
cp -Rv lib/* /tools/lib/perl5/5.14.2
cd ..
rm -rf perl-5.14.2
#############
# Sed 4.2.1 #
#############
tar xf sed-4.2.1.tar.bz2
cd sed-4.2.1
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf sed-4.2.1
############
# Tar 1.26 #
############
tar xf tar-1.26.tar.bz2
cd tar-1.26
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf tar-1.26
#################
# Texinfo 4.13a #
#################
tar xf texinfo-4.13a.tar.gz
cd texinfo-4.13
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf texinfo-4.13
############
# Xz 5.0.3 #
############
tar xf xz-5.0.3.tar.bz2
cd xz-5.0.3
./configure --prefix=/tools
make -j4
make install
cd ..
rm -rf xz-5.0.3
## [Optionally] Strip extra debugging symbols and documentation
#strip --strip-debug /tools/lib*
#strip --strip-unneeded /tools/{,s}bin/*
#rm -rf /tools/{,share}/{info,man,doc}
## Change ownership of tools dir to root
#chown -R root:root $LFS/tools