-
Notifications
You must be signed in to change notification settings - Fork 2
/
build_cross_compiler.sh
executable file
·184 lines (160 loc) · 4.19 KB
/
build_cross_compiler.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
#!/bin/sh
set -e
export TARGET=powerpc-linux-gnueabi
export PREFIX=$PWD/cross
export PATH=$PATH:$PREFIX/bin
rm -fr $PREFIX
mkdir $PREFIX
mkdir $PREFIX/etc
touch $PREFIX/etc/ld.so.conf
mkdir $PREFIX/$TARGET
mkdir $PREFIX/$TARGET/lib
touch $PREFIX/$TARGET/lib/crti.o
touch $PREFIX/$TARGET/lib/crtn.o
touch $PREFIX/$TARGET/lib/libc.so
rm -fr build_binutils
rm -fr build_gcc
rm -fr build_gdb
rm -fr build_gdbserver
rm -fr build_glibc
rm -fr binutils-2.17
rm -fr gdb-6.6
rm -fr glibc-2.5
rm -fr gcc-4.1.2
if [ ! -f binutils-2.17.tar.bz2 ]; then
wget http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2
fi
if [ ! -f gdb-6.6a.tar.bz2 ]; then
wget http://ftp.gnu.org/gnu/gdb/gdb-6.6a.tar.bz2
fi
if [ ! -f glibc-2.5.tar.bz2 ]; then
wget http://ftp.gnu.org/gnu/glibc/glibc-2.5.tar.bz2
fi
if [ ! -f gcc-4.1.2.tar.bz2 ]; then
wget http://ftp.gnu.org/gnu/gcc/gcc-4.1.2/gcc-4.1.2.tar.bz2
fi
if [ ! -d linux ]; then
git clone git://github.com/torvalds/linux.git
fi
tar xjfv binutils-2.17.tar.bz2
tar xjfv gdb-6.6a.tar.bz2
tar xjfv glibc-2.5.tar.bz2
tar xjfv gcc-4.1.2.tar.bz2
cd linux
git checkout -f tags/v2.6.18
make ARCH=powerpc INSTALL_HDR_PATH=$PREFIX/$TARGET headers_install
cd ../
mkdir build_binutils
mkdir build_gcc
mkdir build_gdb
mkdir build_gdbserver
mkdir build_glibc
cd build_binutils
../binutils-2.17/configure \
--target=$TARGET \
--prefix=$PREFIX \
--disable-multilib \
--disable-nls
make -j2 all
make install
cd ..
cd build_gcc
../gcc-4.1.2/configure \
--target=$TARGET \
--prefix=$PREFIX \
--enable-languages=c,c++ \
--disable-multilib \
--disable-nls \
--disable-threads \
--with-long-double-128
make -j2 all-gcc
make install-gcc
cd ..
cd build_glibc
../glibc-2.5/configure \
--prefix=$PREFIX/$TARGET \
--host=$TARGET \
--target=$TARGET \
--with-headers=$PREFIX/$TARGET/include \
--disable-multilib \
--enable-kernel=2.6.18 \
--disable-nls \
--disable-threads \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes
make install-bootstrap-headers=yes install-headers
make -j2 csu/subdir_lib
install csu/crt1.o csu/crti.o csu/crtn.o $PREFIX/$TARGET/lib
$TARGET-gcc -nostdlib -nostartfiles -shared -x c /dev/null \
-o $PREFIX/$TARGET/lib/libc.so
touch $PREFIX/$TARGET/include/gnu/stubs.h
cd ..
rm -fr build_gcc
mkdir build_gcc
cd build_gcc
../gcc-4.1.2/configure \
--target=$TARGET \
--prefix=$PREFIX \
--enable-languages=c,c++ \
--disable-multilib \
--disable-nls \
--with-long-double-128
make -j2 all-gcc
make install-gcc
cd ..
rm -fr build_glibc
mkdir build_glibc
cd build_glibc
../glibc-2.5/configure \
--prefix=$PREFIX/$TARGET \
--build=$MACHTYPE \
--host=$TARGET \
--target=$TARGET \
--with-headers=$PREFIX/$TARGET/include \
--disable-multilib \
--enable-kernel=2.6.18 \
--disable-nls \
libc_cv_forced_unwind=yes \
libc_cv_c_cleanup=yes
make -j2
make install
cd ..
cd build_gcc
make -j2
make install
cd ..
cd build_gdb
../gdb-6.6/configure \
--target=$TARGET \
--prefix=$PREFIX \
--enable-sim-powerpc \
--enable-sim-stdio
make -j2 all
make install
cd ..
cd build_gdbserver
../gdb-6.6/gdb/gdbserver/configure \
--target=$TARGET \
--host=$TARGET \
--prefix=
make -j2 all
make DESTDIR=$PREFIX/target install
cd ..
rm -fr build_glibc
mkdir build_glibc
cd build_glibc
../glibc-2.5/configure \
--prefix= \
--build=$MACHTYPE \
--host=$TARGET \
--target=$TARGET \
--with-headers=$PREFIX/$TARGET/include \
--disable-multilib \
--enable-kernel=2.6.18 \
--disable-nls
make -j2 all
make install_root=$PREFIX/target install
cd ..
cp $PREFIX/$TARGET/lib/libgcc* $PREFIX/target/lib/
cp $PREFIX/$TARGET/lib/libstdc++* $PREFIX/target/lib/
cp $PREFIX/$TARGET/lib/libsupc++* $PREFIX/target/lib/