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