forked from flavioc/cross-hurd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
255 lines (240 loc) · 6.63 KB
/
bootstrap.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
#!/bin/sh
. ./vars.sh
. ./download-funcs.sh
. ./common.sh
compile_binutils ()
{
print_info "Cross compiling binutils"
rm -rf "$BINUTILS_SRC".obj &&
mkdir -p "$BINUTILS_SRC".obj &&
cd "$BINUTILS_SRC".obj &&
AR="$HOST_MACHINE-ar" AS="$HOST_MACHINE-as" \
../$BINUTILS_SRC/configure \
--host="$HOST" \
--target="$TARGET" \
--prefix="$ROOT" \
--with-sysroot="$SYSTEM" \
--disable-static \
--with-lib-path="$SYS_ROOT"/lib \
--disable-multilib \
--disable-werror \
--disable-nls &&
make -j$PROCS all &&
make -j$PROCS install &&
cd ..
}
unpack_gcc_and_fix() {
if [ -d "$GCC_SRC" ]; then
rm -rf "$GCC_SRC"
fi
unpack_gcc &&
cd "$GCC_SRC" && fix_gcc_path && cd ..
}
compile_gcc ()
{
print_info "Cross compiling first phase of GCC"
unpack_gcc_and_fix &&
rm -rf "$GCC_SRC".obj &&
mkdir -p "$GCC_SRC".obj &&
cd "$GCC_SRC".obj &&
AR=ar LDFLAGS="-Wl,-rpath,${ROOT}/lib" \
../$GCC_SRC/configure \
--prefix="$ROOT" \
--build="$HOST" \
--host="$HOST" \
--target="$TARGET" \
--with-sysroot="$SYSTEM" \
--with-local-prefix="$SYS_ROOT" \
--with-native-system-header-dir="$SYS_ROOT"/include \
--disable-nls \
--disable-shared \
--disable-threads \
--disable-multilib \
--disable-target-zlib \
--with-system-zlib \
--without-headers \
--with-newlib \
--disable-decimal-float \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c &&
make -j$PROCS all-gcc &&
make -j$PROCS install-gcc &&
make -j$PROCS configure-target-libgcc &&
cd "$TARGET"/libgcc &&
make -j$PROCS all &&
make -j$PROCS install &&
cd - &&
mv config.status config.status.removed &&
rm -f config.cache *config.cache */*/config.cache &&
cd ..
}
install_gnumach_headers() {
print_info "Installing GNU Mach Headers" &&
cd "$GNUMACH_SRC" &&
autoreconf -i &&
cd .. &&
mkdir -p "$GNUMACH_SRC".obj &&
cd "$GNUMACH_SRC".obj &&
../$GNUMACH_SRC/configure \
--host="$TARGET" \
--prefix="$SYS_ROOT" &&
make -j$PROCS install-data &&
cd -
}
install_gnumig() {
print_info "Installing cross GNU Mig" &&
cd "$GNUMIG_SRC" &&
autoreconf -i &&
cd .. &&
rm -rf "$GNUMIG_SRC".obj &&
mkdir -p "$GNUMIG_SRC".obj &&
cd "$GNUMIG_SRC".obj &&
../$GNUMIG_SRC/configure --target="$TARGET" \
--prefix="$ROOT" &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
install_hurd_headers() {
print_info "Installing Hurd headers" &&
cd "$HURD_SRC" &&
autoreconf -i &&
cd .. &&
mkdir -p "$HURD_SRC".obj &&
cd "$HURD_SRC".obj &&
../$HURD_SRC/configure \
--host="$TARGET" \
--prefix= \
--disable-profile \
--without-parted &&
make -j$PROCS prefix="$SYS_ROOT" no_deps=t install-headers &&
if grep -q '^CC = gcc$' config.make
then
print_info "Removing config.status for later configure..."
rm config.status
else :
fi &&
cd ..
}
compile_first_glibc() {
print_info "Installing glibc (first pass)" &&
rm -rf "$GLIBC_SRC".first_obj &&
mkdir -p "$GLIBC_SRC".first_obj &&
cd "$GLIBC_SRC".first_obj &&
BUILD_CC="$HOST_MACHINE-gcc" CC="$TARGET"-gcc \
AR="$TARGET"-ar CXX="cxx-not-found" RANLIB="$TARGET"-ranlib \
../$GLIBC_SRC/configure \
--with-binutils=${ROOT}/bin \
--build="$HOST" \
--host="$TARGET" \
--prefix="$SYS_ROOT" \
--with-headers="$SYS_ROOT"/include \
--cache-file=config.cache \
--enable-obsolete-rpc \
--disable-profile \
--enable-add-ons=libpthread \
--enable-obsolete-rpc \
--disable-werror \
--disable-nscd \
libc_cv_ctors_header=yes &&
make -j$PROCS || # workaround for "fails first time"?
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
compile_full_gcc () {
print_info "Cross compiling GCC"
unpack_gcc_and_fix
rm -rf "$GCC_SRC".obj &&
mkdir -p "$GCC_SRC".obj &&
cd "$GCC_SRC".obj &&
AR="$HOST_MACHINE-ar" \
LDFLAGS="-Wl,-rpath,${ROOT}/lib" \
../$GCC_SRC/configure \
--prefix="$ROOT" \
--target="$TARGET" \
--with-sysroot="$SYSTEM" \
--with-local-prefix="$SYS_ROOT" \
--with-native-system-header-dir="$SYS_ROOT"/include \
--disable-static \
--disable-nls \
--enable-languages=c,c++ \
--enable-threads=posix \
--disable-multilib \
--with-system-zlib \
--with-libstdcxx-time \
--disable-libstdcxx-pch \
--disable-bootstrap \
--disable-libcilkrts \
--disable-libgomp \
--with-arch=$CPU &&
make -j$PROCS AS_FOR_TARGET="$TARGET-as" LD_FOR_TARGET="$TARGET-ld" all &&
make -j$PROCS install &&
cd ..
}
compile_second_glibc() {
print_info "Installing GLibC (second pass)" &&
rm -rf "$GLIBC_SRC".second_obj &&
mkdir -p "$GLIBC_SRC".second_obj &&
cd "$GLIBC_SRC".second_obj &&
rm -f config.cache &&
BUILD_CC="$HOST_MACHINE-gcc" CC="$TARGET"-gcc CXX="" \
AR="$TARGET"-ar RANLIB="$TARGET"-ranlib \
../$GLIBC_SRC/configure \
--with-binutils=${ROOT}/bin \
--build="$HOST" \
--host="$TARGET" \
--prefix="$SYS_ROOT" \
--with-headers="$SYS_ROOT"/include \
--enable-obsolete-rpc \
--disable-profile \
--enable-add-ons=libpthread \
--enable-obsolete-rpc \
--disable-werror \
--disable-nscd &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
compile_pkgconfiglite() {
cd "$PKGCONFIGLITE_SRC" &&
# otherwise "ln pkg-config i586-pc-gnu-pkg-config" in the install step fails
rm -fv "$ROOT"/bin/*-pkg-config &&
./configure --prefix="$ROOT" --host=${TARGET}\
--with-pc-path="/sys/lib/pkgconfig:/sys/share/pkgconfig" &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
print_info "Root is $ROOT"
print_info "Cross-compiling on $HOST to $TARGET"
create_tools_symlink() {
if [ ! -e $SYS_ROOT ]; then
sudo ln -sf "$PWD"/tools $SYS_ROOT
fi
if [ ! -e /cross-tools ]; then
sudo ln -sf "$PWD"/cross-tools $ROOT
fi
}
mkdir -p "$SYSTEM" && cd "$SYSTEM" &&
mkdir -p bin src boot "tools/include" "tools/lib" "cross-tools/$TARGET" &&
create_tools_symlink &&
ln -sfn "$SYS_ROOT"/include "$SYS_ROOT"/lib "$ROOT"/"$TARGET"/ &&
cd src &&
compile_binutils &&
compile_gcc &&
compile_pkgconfiglite &&
install_gnumach_headers &&
install_gnumig &&
install_hurd_headers &&
compile_first_glibc &&
compile_full_gcc &&
compile_second_glibc &&
print_info "bootstrap.sh finished successfully" &&
exit 0