-
Notifications
You must be signed in to change notification settings - Fork 7
/
bootstrap-funcs.sh
256 lines (244 loc) · 7.32 KB
/
bootstrap-funcs.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
#!/bin/sh
#
export CC=$HOST_CC
export CXX=$HOST_CXX
export GNATBIND=$HOST_GNATBIND
export GNATMAKE=$HOST_GNATMAKE
export GNATLS=$HOST_GNATLS
export GNATLINK=$HOST_GNATLINK
compile_binutils() {
print_info "Cross compiling binutils"
rm -rf "$BINUTILS_SRC".obj &&
mkdir -p "$BINUTILS_SRC".obj &&
cd "$BINUTILS_SRC".obj &&
AR=$HOST_AR AS=$HOST_AS \
$SOURCE/$BINUTILS_SRC/configure \
--host="$HOST" \
--target="$CROSS_HURD_TARGET" \
--prefix="$CROSS_TOOLS" \
--with-sysroot="$SYSTEM" \
--disable-static \
--with-lib-path="$SYS_ROOT"/lib \
--disable-multilib \
--disable-nls &&
make -j$PROCS all &&
make -j$PROCS install &&
cd ..
}
compile_gcc() {
print_info "Cross compiling first phase of GCC"
rm -rf $GCC_SRC.first_obj &&
mkdir -p $GCC_SRC.first_obj &&
cd $GCC_SRC.first_obj &&
AR=$HOST_AR LDFLAGS="-Wl,-rpath,${CROSS_TOOLS}/lib" \
$SOURCE/$GCC_SRC/configure \
--prefix=$CROSS_TOOLS \
--build="$HOST" \
--host="$HOST" \
--target="$CROSS_HURD_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 \
--enable-languages=c &&
make -j$PROCS all-gcc &&
make -j$PROCS install-gcc &&
make -j$PROCS configure-target-libgcc &&
make -j$PROCS all-target-libgcc &&
make -j$PROCS install-target-libgcc &&
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 $SOURCE/$GNUMACH_SRC &&
autoreconf -i &&
cd - &&
mkdir -p "$GNUMACH_SRC".obj &&
local disable_user32=""
if [ -z "$USER32" ]; then
disable_user32="--disable-user32"
fi
cd "$GNUMACH_SRC".obj &&
$SOURCE/$GNUMACH_SRC/configure \
--host="$CROSS_HURD_TARGET" \
--prefix="$SYS_ROOT" \
$disable_user32 &&
make -j$PROCS install-data &&
cd ..
}
install_gnumig() {
print_info "Installing cross GNU Mig" &&
cd $SOURCE/$GNUMIG_SRC &&
autoreconf -i &&
cd - &&
rm -rf $GNUMIG_SRC.host_obj &&
mkdir -p $GNUMIG_SRC.host_obj &&
cd $GNUMIG_SRC.host_obj &&
$SOURCE/$GNUMIG_SRC/configure --target="$CROSS_HURD_TARGET" \
--prefix=$CROSS_TOOLS &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
check_gnumig() {
print_info "Checking GNU Mig" &&
pushd $GNUMIG_SRC.host_obj &&
make -j$PROCS check &&
popd
}
install_hurd_headers() {
print_info "Installing Hurd headers" &&
cd $SOURCE/$HURD_SRC &&
autoreconf -i &&
cd - &&
rm -rf $HURD_SRC.obj &&
mkdir -p $HURD_SRC.obj &&
cd $HURD_SRC.obj &&
$SOURCE/$HURD_SRC/configure \
--host="$CROSS_HURD_TARGET" \
--target="$CROSS_HURD_TARGET" \
--prefix= \
--disable-profile \
--without-libbz2 \
--without-libz \
--without-rump \
--disable-ncursesw \
--without-parted &&
make -j$PROCS prefix="$SYS_ROOT" no_deps=t install-headers &&
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_CC CC=$CROSS_HURD_TARGET-gcc \
AR=$CROSS_HURD_TARGET-ar CXX="cxx-not-found" RANLIB=$CROSS_HURD_TARGET-ranlib \
$SOURCE/$GLIBC_SRC/configure \
--with-binutils=${CROSS_TOOLS}/bin \
--build="$HOST" \
--host="$CROSS_HURD_TARGET" \
--prefix="$SYS_ROOT" \
--with-headers="$SYS_ROOT"/include \
--cache-file=config.cache \
--enable-obsolete-rpc \
--disable-profile \
--enable-add-ons=libpthread \
--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() {
local ada="ada"
if [ -n "$DISABLE_ADA" ]; then
ada=""
fi
print_info "Cross compiling GCC" &&
cp -R $SOURCE/$GCC_SRC $GCC_SRC.compiler &&
pushd $GCC_SRC.compiler &&
(if [ $CPU = "x86_64" ]; then
sed -i.orig '/m64=/s/lib64/lib/' gcc/config/i386/t-gnu64
fi) &&
popd &&
rm -rf $GCC_SRC.obj &&
mkdir -p $GCC_SRC.obj &&
pushd $GCC_SRC.obj &&
AR=$HOST_AR \
LDFLAGS="-Wl,-rpath,${CROSS_TOOLS}/lib" \
../$GCC_SRC.compiler/configure \
--prefix=$CROSS_TOOLS \
--target="$CROSS_HURD_TARGET" \
--with-sysroot="$SYSTEM" \
--with-local-prefix="$SYS_ROOT" \
--with-native-system-header-dir="$SYS_ROOT"/include \
--disable-nls \
--enable-languages=c,c++,$ada \
--enable-threads=posix \
--disable-multilib \
--with-system-zlib \
--with-libstdcxx-time \
--disable-libstdcxx-pch \
--disable-bootstrap \
--disable-libcilkrts \
--disable-libgomp &&
make -j$PROCS AS_FOR_TARGET="$CROSS_HURD_TARGET-as" LD_FOR_TARGET="$CROSS_HURD_TARGET-ld" all &&
(if [ -n "$ada" ]; then
make -j$PROCS configure-target-libada &&
make -j$PROCS all-target-libada &&
make -j$PROCS install-target-libada
fi) &&
make -j$PROCS configure-target-libstdc++-v3 &&
make -j$PROCS all-target-libstdc++-v3 &&
make -j$PROCS install-target-libstdc++-v3 &&
make -j$PROCS install &&
popd
}
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_CC CC=$CROSS_HURD_TARGET-gcc CXX="" \
AR=$CROSS_HURD_TARGET-ar RANLIB=$CROSS_HURD_TARGET-ranlib \
$SOURCE/$GLIBC_SRC/configure \
--with-binutils=$CROSS_TOOLS/bin \
--build="$HOST" \
--host="$CROSS_HURD_TARGET" \
--prefix="$SYS_ROOT" \
--with-headers="$SYS_ROOT"/include \
--disable-profile \
--enable-add-ons=libpthread \
--enable-obsolete-rpc \
--disable-nscd &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
compile_pkgconfiglite() {
# otherwise "ln pkg-config i586-pc-gnu-pkg-config" in the install step fails
rm -fv $CROSS_TOOLS/bin/*-pkg-config &&
rm -rf $PKGCONFIGLITE_SRC.obj &&
mkdir -p $PKGCONFIGLITE_SRC.obj &&
cd $PKGCONFIGLITE_SRC.obj &&
$SOURCE/$PKGCONFIGLITE_SRC/configure \
--prefix=$CROSS_TOOLS --host=$CROSS_HURD_TARGET \
--with-pc-path=$SYS_ROOT/lib/pkgconfig &&
make -j$PROCS &&
make -j$PROCS install &&
cd ..
}
create_tools_symlink() {
if [ ! -e $SYS_ROOT ]; then
sudo ln -sf "$PWD"/$(basename $SYS_ROOT) $SYS_ROOT
fi
if [ ! -e $CROSS_TOOLS ]; then
sudo ln -sf "$PWD"/$(basename $CROSS_TOOLS) $CROSS_TOOLS
fi
}
setup_directories() {
mkdir -p "$SYSTEM" && cd "$SYSTEM" &&
mkdir -p bin boot "$(basename $SYS_ROOT)/include" "$(basename $SYS_ROOT)/lib" "$(basename $CROSS_TOOLS)/$CROSS_HURD_TARGET" &&
create_tools_symlink &&
ln -sfn $SYS_ROOT/include $SYS_ROOT/lib $CROSS_TOOLS/$CROSS_HURD_TARGET/ &&
cd -
}