Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tools/trusted_cross_toolchains/trusted-toolchain-creator.mipsel.squeeze.sh

Issue 11036032: [MIPS] Script to build a trusted mipsel-linux-gnu cross toolchain from source. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Minor update - use GCC 4.7.2 (instead of 4.6.3). Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 # Copyright 2012 The Native Client Authors. All rights reserved. 2 # Copyright 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can 3 # Use of this source code is governed by a BSD-style license that can
4 # be found in the LICENSE file. 4 # be found in the LICENSE file.
5 # 5 #
6 #@ This script creates the mips trusted SDK. 6 #@ This script creates the mips trusted SDK.
7 #@ It must be run from the native_client directory. 7 #@ It must be run from the native_client directory.
8 8
9 # This script is intended to build a mipsel-linux-gnu cross compilation
10 # toolchain that runs on x86 linux and generates code for a little-endian,
11 # hard-float, mips32 target.
12 #
13 # It expects the host machine to have relatively recent versions of GMP (4.2.0
14 # or later), MPFR (2.4.2), and MPC (0.8.1) in order to build the GCC.
15 #
16 # Common way to get those is:
17 # sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev
18
9 ###################################################################### 19 ######################################################################
10 # Config 20 # Config
11 ###################################################################### 21 ######################################################################
12 22
13 set -o nounset 23 set -o nounset
14 set -o errexit 24 set -o errexit
25 set -o xtrace
15 26
16 readonly CS_URL=https://sourcery.mentor.com/sgpp/lite/mips/portal/package9761/pu blic/mips-linux-gnu/mips-2011.09-75-mips-linux-gnu-i686-pc-linux-gnu.tar.bz2 27 readonly MAKE_OPTS="-j8"
28 readonly ARCH="mips32"
29
30 readonly GCC_URL="http://ftp.gnu.org/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2"
31 readonly GCC_SHA1SUM="a464ba0f26eef24c29bcd1e7489421117fb9ee35"
32
33 readonly BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2"
34 readonly BINUTILS_SHA1SUM="65b304a0b9a53a686ce50a01173d1f40f8efe404"
35
36 readonly KERNEL_URL="http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux- 2.6.38.4.tar.gz"
37 readonly KERNEL_SHA1SUM="377fa5cf5f1d0c396759b1c4d147330e7e5b6d7f"
38
39 readonly GDB_URL="http://ftp.gnu.org/gnu/gdb/gdb-7.5.tar.bz2"
40 readonly GDB_SHA1SUM="79b61152813e5730fa670c89e5fc3c04b670b02c"
41
42 readonly EGLIBC_SVN_URL="svn://svn.eglibc.org/branches/eglibc-2_14"
43 readonly EGLIBC_REVISION="20996"
17 44
18 readonly DOWNLOAD_QEMU_URL="http://download.savannah.gnu.org/releases/qemu/qemu- 0.12.5.tar.gz" 45 readonly DOWNLOAD_QEMU_URL="http://download.savannah.gnu.org/releases/qemu/qemu- 0.12.5.tar.gz"
19 46
20 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted 47 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted
21 48
22 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted 49 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted
23 50
51 readonly BUILD_DIR=${TMP}/build
52
24 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips) 53 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips)
25 54
26 readonly CS_ROOT=${INSTALL_ROOT}/mips-release 55 readonly JAIL_MIPS32=${INSTALL_ROOT}/sysroot
27 56
28 readonly JAIL_MIPS32=${CS_ROOT}/mips-linux-gnu/libc/el 57 # These are simple compiler wrappers to force 32bit builds.
29
30 readonly MAKE_OPTS="-j8"
31 # These are simple compiler wrappers to force 32bit builds
32 readonly CC32=$(readlink -f pnacl/scripts/mygcc32) 58 readonly CC32=$(readlink -f pnacl/scripts/mygcc32)
33 readonly CXX32=$(readlink -f pnacl/scripts/myg++32) 59 readonly CXX32=$(readlink -f pnacl/scripts/myg++32)
60
34 ###################################################################### 61 ######################################################################
35 # Helper 62 # Helper
36 ###################################################################### 63 ######################################################################
37 64
38 Banner() { 65 Banner() {
39 echo "######################################################################" 66 echo "######################################################################"
40 echo $* 67 echo $*
41 echo "######################################################################" 68 echo "######################################################################"
42 } 69 }
43 70
44 SubBanner() { 71 SubBanner() {
45 echo "......................................................................" 72 echo "......................................................................"
46 echo $* 73 echo $*
47 echo "...................................................................." 74 echo "......................................................................"
48 } 75 }
49 76
50 Usage() { 77 Usage() {
51 echo 78 echo
52 echo "$0 trusted_sdk" 79 echo "$0 trusted_sdk"
53 echo 80 echo
54 echo "trusted_sdk - Build everything and package it" 81 echo "trusted_sdk - Build everything and package it"
55 echo 82 echo
56 } 83 }
57 84
58 DownloadOrCopy() { 85 CheckoutOrCopy() {
59 if [[ -f "$2" ]] ; then 86 local url=$1
60 echo "$2 already in place" 87 local revision=$2
61 elif [[ $1 =~ 'http://' || $1 =~ 'https://' ]] ; then 88 local filename="${TMP}/${url##*/}"
62 SubBanner "downloading from $1 -> $2" 89 local filetype="${url%%:*}"
63 wget $1 -O $2 90
91 if [ "${filename}" == "" ]; then
92 echo "Unknown error occured. Aborting."
93 exit 1
94 fi
95
96 if [ "${filetype}" == "svn" ]; then
97 SubBanner "checkout from ${url} -> ${filename}"
98 svn --force export -r ${revision} ${url} ${filename}
64 else 99 else
65 SubBanner "copying from $1" 100 SubBanner "copying from ${url}"
66 cp $1 $2 101 cp ${url} ${filename}
67 fi 102 fi
68 } 103 }
69 104
105 DownloadOrCopy() {
106 local url=$1
107 local filename="${TMP}/${url##*/}"
108 local filetype="${url%%:*}"
109
110 if [ "${filename}" == "" ]; then
111 echo "Unknown error occured. Aborting."
112 exit 1
113 fi
114
115 if [[ "${filetype}" == "http" || ${filetype} == "https" ]] ; then
116 if [ ! -f "${filename}" ]; then
117 SubBanner "downloading from ${url} -> ${filename}"
118 wget ${url} -O ${filename}
119 fi
120 else
121 SubBanner "copying from ${url}"
122 cp ${url} ${filename}
123 fi
124 }
125
126 DownloadOrCopyAndVerify() {
127 local url=$1
128 local checksum=$2
129 local filename="${TMP}/${url##*/}"
130 local filetype="${url%%:*}"
131
132 if [ "${filename}" == "" ]; then
133 echo "Unknown error occured. Aborting."
134 exit 1
135 fi
136
137 if [[ "${filetype}" == "http" || ${filetype} == "https" ]] ; then
138 if [ ! -f "${filename}" ]; then
139 SubBanner "downloading from ${url} -> ${filename}"
140 wget ${url} -O ${filename}
141 fi
142 if [ "${checksum}" != "nochecksum" ]; then
143 if [ "$(sha1sum ${filename} | cut -d ' ' -f 1)" != "${checksum}" ]; then
144 echo "${filename} sha1sum failed. Deleting file and aborting."
145 rm -f ${filename}
146 exit 1
147 fi
148 fi
149 else
150 SubBanner "copying from ${url}"
151 cp ${url} ${filename}
152 fi
153 }
154
70 ###################################################################### 155 ######################################################################
71 # 156 #
72 ###################################################################### 157 ######################################################################
73 158
74 # some sanity checks to make sure this script is run from the right place 159 # some sanity checks to make sure this script is run from the right place
75 # with the right tools 160 # with the right tools.
76 SanityCheck() { 161 SanityCheck() {
77 Banner "Sanity Checks" 162 Banner "Sanity Checks"
78 if [[ $(basename $(pwd)) != "native_client" ]] ; then 163 if [[ $(basename $(pwd)) != "native_client" ]] ; then
79 echo "ERROR: run this script from the native_client/ dir" 164 echo "ERROR: run this script from the native_client/ dir"
80 exit -1 165 exit -1
81 fi 166 fi
82 167
83 if ! mkdir -p "${INSTALL_ROOT}" ; then 168 if ! mkdir -p "${INSTALL_ROOT}" ; then
84 echo "ERROR: ${INSTALL_ROOT} can't be created." 169 echo "ERROR: ${INSTALL_ROOT} can't be created."
85 exit -1 170 exit -1
86 fi 171 fi
87 172
88 for tool in cleanlinks wget ; do 173 for tool in cleanlinks wget ; do
89 if ! which ${tool} ; then 174 if ! which ${tool} ; then
90 echo "Required binary $tool not found." 175 echo "Required binary $tool not found."
91 echo "Exiting." 176 echo "Exiting."
92 exit 1 177 exit 1
93 fi 178 fi
94 done 179 done
95 } 180 }
96 181
97 182
98 ClearInstallDir() { 183 ClearInstallDir() {
99 Banner "clearing dirs in ${INSTALL_ROOT}" 184 Banner "clearing dirs in ${INSTALL_ROOT}"
100 rm -rf ${INSTALL_ROOT}/* 185 rm -rf ${INSTALL_ROOT}/*
101 } 186 }
102 187
188 ClearBuildDir() {
189 Banner "clearing dirs in ${BUILD_DIR}"
190 rm -rf ${BUILD_DIR}/*
191 }
103 192
104 CreateTarBall() { 193 CreateTarBall() {
105 local tarball=$1 194 local tarball=$1
106 Banner "creating tar ball ${tarball}" 195 Banner "creating tar ball ${tarball}"
107 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} . 196 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} .
108 } 197 }
109 198
110 199
111 # try to keep the tarball small 200 # Download the toolchain source tarballs or use a local copy when available.
112 PruneDirs() { 201 DownloadOrCopyAndInstallToolchain() {
113 Banner "pruning code sourcery tree" 202 Banner "Installing toolchain"
114 SubBanner "Size before: $(du -msc ${CS_ROOT})" 203
115 rm -rf ${CS_ROOT}/share 204 local tarball="${TMP}/${BINUTILS_URL##*/}"
116 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/uclibc 205 DownloadOrCopyAndVerify ${BINUTILS_URL} ${BINUTILS_SHA1SUM}
117 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/soft-float 206 SubBanner "extracting from ${tarball}"
118 rm -rf ${CS_ROOT}/mips-linux-gnu/lib/micromips 207 tar jxf ${tarball} -C ${TMP}
119 208
120 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/uclibc 209 tarball="${TMP}/${GCC_URL##*/}"
121 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/soft-float 210 DownloadOrCopyAndVerify ${GCC_URL} ${GCC_SHA1SUM}
122 rm -rf ${CS_ROOT}/mips-linux-gnu/libc/micromips 211 SubBanner "extracting from ${tarball}"
123 212 tar jxf ${tarball} -C ${TMP}
124 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/uclibc 213
125 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/soft-float 214 tarball="${TMP}/${GDB_URL##*/}"
126 rm -rf ${CS_ROOT}/lib/gcc/mips-linux-gnu/4.4.1/micromips 215 DownloadOrCopyAndVerify ${GDB_URL} ${GDB_SHA1SUM}
127 216 SubBanner "extracting from ${tarball}"
128 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/uclibc 217 tar jxf ${tarball} -C ${TMP}
129 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/soft-float 218
130 rm -rf ${CS_ROOT}/mips-linux-gnu/include/c++/4.4.1/mips-linux-gnu/micromips 219 tarball="${TMP}/${KERNEL_URL##*/}"
131 220 DownloadOrCopyAndVerify ${KERNEL_URL} ${KERNEL_SHA1SUM}
132 SubBanner "Size after: $(du -msc ${CS_ROOT})" 221 SubBanner "extracting from ${tarball}"
222 tar zxf ${tarball} -C ${TMP}
223
224 local eglibc_dir="${TMP}/${EGLIBC_SVN_URL##*/}"
225 CheckoutOrCopy ${EGLIBC_SVN_URL} ${EGLIBC_REVISION}
226
227
228 Banner "Preparing the code"
229
230 if [ ! -d "${TMP}/eglibc-2_14/libc/ports" ]; then
231 ln -s ${TMP}/eglibc-2_14/ports ${TMP}/eglibc-2_14/libc/ports
232 fi
233
234 # Fix a minor syntax issue in tc-mips.c.
235 local OLD_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, msg);"
236 local NEW_TEXT="as_warn_where (fragp->fr_file, fragp->fr_line, \"%s\", msg);"
237 local FILE_NAME="${TMP}/binutils-2.22/gas/config/tc-mips.c"
238 sed -i "s/${OLD_TEXT}/${NEW_TEXT}/g" "${FILE_NAME}"
239
240 export PATH=${INSTALL_ROOT}/bin:$PATH
241
242
243 Banner "Building binutils"
244
245 mkdir -p ${BUILD_DIR}/binutils/
246 pushd ${BUILD_DIR}/binutils/
247
248 SubBanner "Configuring"
249 ${TMP}/binutils-2.22/configure \
250 --prefix=${INSTALL_ROOT} \
251 --target=mipsel-linux-gnu \
252 --with-sysroot=${JAIL_MIPS32}
253
254 SubBanner "Make"
255 make ${MAKE_OPTS} all-binutils all-gas all-ld
256
257 SubBanner "Install"
258 make ${MAKE_OPTS} install-binutils install-gas install-ld
259
260 popd
261
262
263 Banner "Building GCC (initial)"
264
265 mkdir -p ${BUILD_DIR}/gcc/initial
266 pushd ${BUILD_DIR}/gcc/initial
267
268 SubBanner "Configuring"
269 ${TMP}/gcc-4.7.2/configure \
270 --prefix=${INSTALL_ROOT} \
271 --disable-libssp \
272 --disable-libgomp \
273 --disable-libmudflap \
274 --disable-fixed-point \
275 --disable-decimal-float \
276 --with-mips-plt \
277 --with-endian=little \
278 --with-arch=${ARCH} \
279 --enable-languages=c \
280 --with-newlib \
281 --without-headers \
282 --disable-shared \
283 --disable-threads \
284 --disable-libquadmath \
285 --disable-libatomic \
286 --target=mipsel-linux-gnu
287
288 SubBanner "Make"
289 make ${MAKE_OPTS} all
290
291 SubBanner "Install"
292 make ${MAKE_OPTS} install
293
294 popd
295
296
297 Banner "Installing Linux kernel headers"
298 pushd ${TMP}/linux-2.6.38.4
299 make headers_install ARCH=mips INSTALL_HDR_PATH=${JAIL_MIPS32}/usr
300 popd
301
302
303 Banner "Building EGLIBC (initial)"
304
305 mkdir -p ${JAIL_MIPS32}/usr/lib
306 mkdir -p ${BUILD_DIR}/eglibc/initial
307 pushd ${BUILD_DIR}/eglibc/initial
308
309 SubBanner "Configuring"
310 BUILD_CC=gcc \
311 AR=mipsel-linux-gnu-ar \
312 RANLIB=mipsel-linux-gnu-ranlib \
313 CC=mipsel-linux-gnu-gcc \
314 CXX=mipsel-linux-gnu-g++ \
315 ${TMP}/eglibc-2_14/libc/configure \
316 --prefix=/usr \
317 --enable-add-ons \
318 --build=i686-pc-linux-gnu \
319 --host=mipsel-linux-gnu \
320 --disable-profile \
321 --without-gd \
322 --without-cvs \
323 --with-headers=${JAIL_MIPS32}/usr/include
324
325 SubBanner "Install"
326 make ${MAKE_OPTS} install-headers install_root=${JAIL_MIPS32} \
327 install-bootstrap-headers=yes
328
329 make csu/subdir_lib && \
330 cp csu/crt1.o csu/crti.o csu/crtn.o ${JAIL_MIPS32}/usr/lib
331
332 mipsel-linux-gnu-gcc -nostdlib \
333 -nostartfiles \
334 -shared \
335 -x c /dev/null \
336 -o ${JAIL_MIPS32}/usr/lib/libc.so
337
338 popd
339
340
341 Banner "Building GCC (intermediate)"
342
343 mkdir -p ${BUILD_DIR}/gcc/intermediate
344 pushd ${BUILD_DIR}/gcc/intermediate
345
346 SubBanner "Configuring"
347 ${TMP}/gcc-4.7.2/configure \
348 --prefix=${INSTALL_ROOT} \
349 --disable-libssp \
350 --disable-libgomp \
351 --disable-libmudflap \
352 --disable-fixed-point \
353 --disable-decimal-float \
354 --with-mips-plt \
355 --with-endian=little \
356 --with-arch=${ARCH} \
357 --target=mipsel-linux-gnu \
358 --enable-languages=c \
359 --disable-libquadmath \
360 --disable-libatomic \
361 --with-sysroot=${JAIL_MIPS32}
362
363 SubBanner "Make"
364 make ${MAKE_OPTS} all
365
366 SubBanner "Install"
367 make ${MAKE_OPTS} install
368
369 popd
370
371
372 Banner "Building EGLIBC (final)"
373
374 mkdir -p ${BUILD_DIR}/eglibc/final
375 pushd ${BUILD_DIR}/eglibc/final
376
377 BUILD_CC=gcc \
378 AR=mipsel-linux-gnu-ar \
379 RANLIB=mipsel-linux-gnu-ranlibi \
380 CC=mipsel-linux-gnu-gcc \
381 CXX=mipsel-linux-gnu-g++ \
382 ${TMP}/eglibc-2_14/libc/configure \
383 --prefix=/usr \
384 --enable-add-ons \
385 --host=mipsel-linux-gnu \
386 --disable-profile \
387 --without-gd \
388 --without-cvs \
389 --build=i686-pc-linux-gnu \
390 --with-headers=${JAIL_MIPS32}/usr/include
391
392 SubBanner "Make"
393 make ${MAKE_OPTS} all
394
395 SubBanner "Install"
396 make ${MAKE_OPTS} install install_root=${JAIL_MIPS32}
397
398 popd
399
400
401 Banner "Building GCC (final)"
402
403 mkdir -p ${BUILD_DIR}/gcc/final
404 pushd ${BUILD_DIR}/gcc/final
405
406 ${TMP}/gcc-4.7.2/configure \
407 --prefix=${INSTALL_ROOT} \
408 --disable-libssp \
409 --disable-libgomp \
410 --disable-libmudflap \
411 --disable-fixed-point \
412 --disable-decimal-float \
413 --with-mips-plt \
414 --with-endian=little \
415 --with-arch=${ARCH} \
416 --target=mipsel-linux-gnu \
417 --enable-__cxa_atexit \
418 --enable-languages=c,c++ \
419 --with-sysroot=${JAIL_MIPS32}
420
421 SubBanner "Make"
422 make ${MAKE_OPTS} all
423
424 SubBanner "Install"
425 make ${MAKE_OPTS} install
426
427 popd
428
429
430 Banner "Building GDB"
431
432 mkdir -p ${BUILD_DIR}/gdb/
433 pushd ${BUILD_DIR}/gdb/
434
435 ${TMP}/gdb-7.5/configure \
436 --prefix=${INSTALL_ROOT} \
437 --target=mipsel-linux-gnu
438
439 SubBanner "Make"
440 make ${MAKE_OPTS} all-gdb
441
442 SubBanner "Install"
443 make ${MAKE_OPTS} install-gdb
444
445 popd
133 } 446 }
134 447
135
136 # Download the codesourcery tarball or use a local copy when available.
137 DownloadOrCopyAndInstallCodeSourceryTarball() {
138 Banner "Installing Codesourcery Toolchain"
139 local tarball="${TMP}/${CS_URL##*/}"
140 DownloadOrCopy ${CS_URL} ${tarball}
141
142 SubBanner "Untaring ${INSTALL_ROOT}/${tarball}"
143 tar jxf ${tarball} -C ${INSTALL_ROOT}
144
145 pushd ${INSTALL_ROOT}
146 mv mips-* mips-release
147 popd
148 }
149
150 448
151 InstallTrustedLinkerScript() { 449 InstallTrustedLinkerScript() {
152 local trusted_ld_script=${INSTALL_ROOT}/ld_script_mips_trusted 450 local trusted_ld_script=${INSTALL_ROOT}/ld_script_mips_trusted
153 # We are using the output of "ld --verbose" which contains 451 # We are using the output of "ld --verbose" which contains
154 # the linker script delimited by "=========". 452 # the linker script delimited by "=========".
155 # We are changing the image start address to 70000000 453 # We are changing the image start address to 70000000
156 # to move the sel_ldr and other images "out of the way" 454 # to move the sel_ldr and other images "out of the way"
157 Banner "installing trusted linker script to ${trusted_ld_script}" 455 Banner "installing trusted linker script to ${trusted_ld_script}"
158 456
159 ${CS_ROOT}/bin/mips-linux-gnu-ld --verbose |\ 457 ${INSTALL_ROOT}/bin/mipsel-linux-gnu-ld --verbose |\
160 grep -A 10000 "=======" |\ 458 grep -A 10000 "=======" |\
161 grep -v "=======" |\ 459 grep -v "=======" |\
162 sed -e 's/0400000/70000000/g' > ${trusted_ld_script} 460 sed -e 's/0400000/70000000/g' > ${trusted_ld_script}
163 } 461 }
164 462
165 463
166 InstallMissingHeaders() {
167 Banner "installing openssl headers from local system"
168 cp -r /usr/include/openssl ${JAIL_MIPS32}/usr/include/
169 }
170
171
172 MissingSharedLibCleanup() {
173 Banner "Cleanup dangling symlinks"
174 }
175
176 # ---------------------------------------------------------------------- 464 # ----------------------------------------------------------------------
177 # mips32 deb files to complete our code sourcery jail 465 # mips32 deb files to complete our code sourcery jail
178 # ---------------------------------------------------------------------- 466 # ----------------------------------------------------------------------
179 467
180 readonly REPO_DEBIAN=http://ftp.debian.org/debian 468 readonly REPO_DEBIAN=http://ftp.debian.org/debian
181 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package s.bz2 469 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package s.bz2
182 470
183 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp 471 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp
184 472
185 # These are good enough for native client 473 # These are good enough for native client.
186 readonly BASE_PACKAGES="\ 474 readonly BASE_PACKAGES="\
187 libssl0.9.8 \ 475 libssl0.9.8 \
188 libssl-dev \ 476 libssl-dev \
189 libx11-6 \ 477 libx11-6 \
190 libx11-dev \ 478 libx11-dev \
191 x11proto-core-dev \ 479 x11proto-core-dev \
192 libxt6 \ 480 libxt6 \
193 libxt-dev \ 481 libxt-dev \
194 zlib1g \ 482 zlib1g \
195 zlib1g-dev \ 483 zlib1g-dev \
(...skipping 12 matching lines...) Expand all
208 libxcb-shm0 \ 496 libxcb-shm0 \
209 libxcb-shm0-dev \ 497 libxcb-shm0-dev \
210 libxdmcp6 \ 498 libxdmcp6 \
211 libxdmcp-dev \ 499 libxdmcp-dev \
212 libxss1 \ 500 libxss1 \
213 libxss-dev" 501 libxss-dev"
214 502
215 GeneratePackageLists() { 503 GeneratePackageLists() {
216 Banner "generating package lists for mips32" 504 Banner "generating package lists for mips32"
217 echo -n > ${TMP_PACKAGELIST_MIPS32} 505 echo -n > ${TMP_PACKAGELIST_MIPS32}
218 DownloadOrCopy ${MIPS32_PACKAGES} ${TMP}/../Packages_mipsel.bz2 506 DownloadOrCopy ${MIPS32_PACKAGES}
219 bzcat ${TMP}/../Packages_mipsel.bz2\ 507 bzcat ${TMP}/Packages.bz2\
220 | egrep '^(Package:|Filename:)' > ${TMP}/../Packages_mipsel 508 | egrep '^(Package:|Filename:)' > ${TMP}/Packages_mipsel
221 for pkg in ${BASE_PACKAGES} ; do 509 for pkg in ${BASE_PACKAGES} ; do
222 grep -A 1 "${pkg}\$" ${TMP}/../Packages_mipsel\ 510 grep -A 1 "${pkg}\$" ${TMP}/Packages_mipsel\
223 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST_MIPS32} 511 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST_MIPS32}
224 done 512 done
225 } 513 }
226 514
227 InstallMissingLibraries() { 515 InstallMissingLibraries() {
228 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32}) 516 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32})
229 for file in ${DEP_FILES_NEEDED_MIPS32} ; do 517 for file in ${DEP_FILES_NEEDED_MIPS32} ; do
230 local package="${TMP}/${file##*/}" 518 local package="${TMP}/${file##*/}"
231 Banner "installing ${file}" 519 Banner "installing ${file}"
232 DownloadOrCopy ${REPO_DEBIAN}/${file} ${package} 520 DownloadOrCopy ${REPO_DEBIAN}/${file}
233 SubBanner "extracting to ${JAIL_MIPS32}" 521 SubBanner "extracting to ${JAIL_MIPS32}"
234 dpkg --fsys-tarfile ${package}\ 522 dpkg --fsys-tarfile ${package}\
235 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32} 523 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32}
236 done 524 done
237 525
238 Banner "some cleanup" 526 Banner "some cleanup"
239 527
240 pushd ${JAIL_MIPS32}/usr/lib/ 528 pushd ${JAIL_MIPS32}/usr/lib/
241 cleanlinks > /dev/null 2> /dev/null 529 cleanlinks > /dev/null 2> /dev/null
242 FixLibs 530 FixLibs
(...skipping 13 matching lines...) Expand all
256 ln -s ../../lib/libdl.so.2 libdl.so 544 ln -s ../../lib/libdl.so.2 libdl.so
257 545
258 rm -f librt.so 546 rm -f librt.so
259 ln -s ../../lib/librt.so.1 librt.so 547 ln -s ../../lib/librt.so.1 librt.so
260 548
261 rm -f libpcre.so 549 rm -f libpcre.so
262 ln -s ../../lib/libpcre.so.3 libpcre.so 550 ln -s ../../lib/libpcre.so.3 libpcre.so
263 551
264 rm -f libresolv.so 552 rm -f libresolv.so
265 ln -s ../../lib/libresolv.so.2 libresolv.so 553 ln -s ../../lib/libresolv.so.2 libresolv.so
266
267 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libc.so
268 echo "GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld.so.1 ) )" >> libc.so
269
270 echo "OUTPUT_FORMAT(elf32-tradlittlemips)" > libpthread.so
271 echo "GROUP ( libpthread.so.0 libpthread_nonshared.a )" >> libpthread.so
272 } 554 }
273 555
274 BuildAndInstallQemu() { 556 BuildAndInstallQemu() {
275 local saved_dir=$(pwd) 557 local saved_dir=$(pwd)
276 local tmpdir="${TMP}/qemu-mips.nacl" 558 local tmpdir="${TMP}/qemu-mips.nacl"
277 local tarball="qemu-0.12.5.tar.gz" 559 local tarball="qemu-0.12.5.tar.gz"
560
278 Banner "Building qemu in ${tmpdir}" 561 Banner "Building qemu in ${tmpdir}"
562
279 rm -rf ${tmpdir} 563 rm -rf ${tmpdir}
280 mkdir ${tmpdir} 564 mkdir ${tmpdir}
281 cd ${tmpdir} 565 cd ${tmpdir}
566
282 SubBanner "Downloading" 567 SubBanner "Downloading"
283 wget -c ${DOWNLOAD_QEMU_URL} 568 wget -c ${DOWNLOAD_QEMU_URL}
569
284 SubBanner "Untaring" 570 SubBanner "Untaring"
285 tar zxf ${tarball} 571 tar zxf ${tarball}
286 cd qemu-0.12.5 572 cd qemu-0.12.5
287 SubBanner "Patching" 573
288 patch -p1 < ${PATCH_MIPS32} 574 if [ -f "${PATCH_MIPS32}" ]; then
575 SubBanner "Patching"
576 patch -p1 < ${PATCH_MIPS32}
577 fi
289 578
290 echo 579 echo
291 echo "NOTE: on 64 bit systems you will need to the following 32bit libs:" 580 echo "NOTE: on 64 bit systems you will need to the following 32bit libs:"
292 echo "lib32z1-dev" 581 echo "lib32z1-dev"
293 echo 582 echo
294 583
295 SubBanner "Configuring" 584 SubBanner "Configuring"
296 env -i PATH=/usr/bin/:/bin \ 585 env -i PATH=/usr/bin/:/bin \
297 ./configure \ 586 ./configure \
298 --cc=${CC32} \ 587 --cc=${CC32} \
299 --disable-system \ 588 --disable-system \
300 --enable-linux-user \ 589 --enable-linux-user \
301 --disable-darwin-user \ 590 --disable-darwin-user \
302 --disable-bsd-user \ 591 --disable-bsd-user \
303 --target-list=mipsel-linux-user \ 592 --target-list=mipsel-linux-user \
304 --disable-sdl \ 593 --disable-sdl \
305 --disable-linux-aio \ 594 --disable-linux-aio \
306 --static 595 --static
307 596
308 SubBanner "Make" 597 SubBanner "Make"
309 env -i PATH=/usr/bin/:/bin \ 598 env -i PATH=/usr/bin/:/bin \
310 make MAKE_OPTS=${MAKE_OPTS} 599 make MAKE_OPTS=${MAKE_OPTS}
311 600
312 SubBanner "Install" 601 SubBanner "Install"
313 cp mipsel-linux-user/qemu-mipsel ${INSTALL_ROOT}/qemu-mips32 602 cp mipsel-linux-user/qemu-mipsel ${INSTALL_ROOT}/qemu-mips32
314 cd ${saved_dir} 603 cd ${saved_dir}
315 cp tools/trusted_cross_toolchains/qemu_tool_mips32.sh ${INSTALL_ROOT} 604 cp tools/trusted_cross_toolchains/qemu_tool_mips32.sh ${INSTALL_ROOT}
316 ln -sf qemu_tool_mips32.sh ${INSTALL_ROOT}/run_under_qemu_mips32 605 ln -sf qemu_tool_mips32.sh ${INSTALL_ROOT}/run_under_qemu_mips32
317 } 606 }
607
318 ###################################################################### 608 ######################################################################
319 # Main 609 # Main
320 ###################################################################### 610 ######################################################################
321 611
322 if [[ $# -eq 0 ]] ; then 612 if [[ $# -eq 0 ]] ; then
323 echo "you must specify a mode on the commandline:" 613 echo "you must specify a mode on the commandline:"
324 echo 614 echo
325 Usage 615 Usage
326 exit -1 616 exit -1
327 617
328 elif [[ $1 == "trusted_sdk" ]]; then 618 elif [[ $1 == "trusted_sdk" ]]; then
329 mkdir -p ${TMP} 619 mkdir -p ${TMP}
330 SanityCheck 620 SanityCheck
331 ClearInstallDir 621 ClearInstallDir
332 DownloadOrCopyAndInstallCodeSourceryTarball 622 ClearBuildDir
333 PruneDirs 623 DownloadOrCopyAndInstallToolchain
334 GeneratePackageLists 624 GeneratePackageLists
335 InstallMissingHeaders
336 InstallMissingLibraries 625 InstallMissingLibraries
337 MissingSharedLibCleanup
338 InstallTrustedLinkerScript 626 InstallTrustedLinkerScript
339 BuildAndInstallQemu 627 BuildAndInstallQemu
340 CreateTarBall $1 628 CreateTarBall $1
341 629
342 else 630 else
343 Usage 631 Usage
344 exit -1 632 exit -1
345 633
346 fi 634 fi
347 635
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698