| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 #@ This script builds the (trusted) cross toolchain for arm. | 6 #@ This script builds the (trusted) cross toolchain for arm. |
| 7 #@ It must be run from the native_client/ directory. | 7 #@ It must be run from the native_client/ directory. |
| 8 #@ | 8 #@ |
| 9 #@ The toolchain consists primarily of a jail with arm header and libraries. | 9 #@ The toolchain consists primarily of a jail with arm header and libraries. |
| 10 #@ It also provides additional tools such as QEMU. | 10 #@ It also provides additional tools such as QEMU. |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 # Historic Notes: | 402 # Historic Notes: |
| 403 # Traditionally we were building static 32 bit images of qemu on a | 403 # Traditionally we were building static 32 bit images of qemu on a |
| 404 # 64bit system which would run then on both x86-32 and x86-64 systems. | 404 # 64bit system which would run then on both x86-32 and x86-64 systems. |
| 405 # The latest version of qemu contains new dependencies which | 405 # The latest version of qemu contains new dependencies which |
| 406 # currently make it impossible to build such images on 64bit systems | 406 # currently make it impossible to build such images on 64bit systems |
| 407 # We can build a static 64bit qemu but it does not work with | 407 # We can build a static 64bit qemu but it does not work with |
| 408 # the sandboxed translators for unknown reason. | 408 # the sandboxed translators for unknown reason. |
| 409 # So instead we chose to build 32bit shared images. | 409 # So instead we chose to build 32bit shared images. |
| 410 # | 410 # |
| 411 | 411 |
| 412 readonly QEMU_TARBALL=$(readlink -f ../third_party/qemu/qemu-1.0.1.tar.gz) | 412 readonly QEMU_TARBALL=qemu-1.0.1.tar.gz |
| 413 readonly QEMU_PATCH=$(readlink -f ../third_party/qemu/qemu-1.0.1.patch_arm) | 413 readonly QEMU_SHA=4d08b5a83538fcd7b222bec6f1c584da8d12497a |
| 414 readonly QEMU_DIR=qemu-1.0.1 | 414 readonly QEMU_DIR=qemu-1.0.1 |
| 415 | 415 |
| 416 # TODO(sbc): update to version 2.3.0 |
| 417 #readonly QEMU_TARBALL=qemu-2.3.0.tar.bz2 |
| 418 #readonly QEMU_SHA=373d74bfafce1ca45f85195190d0a5e22b29299e |
| 419 #readonly QEMU_DIR=qemu-2.3.0 |
| 420 |
| 421 readonly QEMU_URL=http://wiki.qemu-project.org/download/${QEMU_TARBALL} |
| 422 readonly QEMU_PATCH=$(readlink -f ../third_party/qemu/${QEMU_DIR}.patch_arm) |
| 423 |
| 416 BuildAndInstallQemu() { | 424 BuildAndInstallQemu() { |
| 417 local saved_dir=$(pwd) | 425 local saved_dir=$(pwd) |
| 418 local tmpdir="${TMP}/qemu.nacl" | 426 local tmpdir="${TMP}/qemu.nacl" |
| 419 | 427 |
| 428 set -x |
| 420 Banner "Building qemu in ${tmpdir}" | 429 Banner "Building qemu in ${tmpdir}" |
| 421 | 430 |
| 422 if [[ -z "$QEMU_TARBALL" ]] ; then | 431 if [ -n "${QEMU_URL}" ]; then |
| 423 echo "ERROR: missing qemu tarball: ../third_party/qemu/qemu-1.0.1.tar.gz" | 432 if [[ ! -f ${TMP}/${QEMU_TARBALL} ]]; then |
| 424 exit 1 | 433 wget -O ${TMP}/${QEMU_TARBALL} $QEMU_URL |
| 434 fi |
| 435 |
| 436 echo "${QEMU_SHA} ${TMP}/${QEMU_TARBALL}" | sha1sum --check - |
| 437 else |
| 438 if [[ ! -f "$QEMU_TARBALL" ]] ; then |
| 439 echo "ERROR: missing qemu tarball: $QEMU_TARBALL" |
| 440 exit 1 |
| 441 fi |
| 425 fi | 442 fi |
| 426 | 443 |
| 427 rm -rf ${tmpdir} | 444 rm -rf ${tmpdir} |
| 428 mkdir ${tmpdir} | 445 mkdir ${tmpdir} |
| 429 cd ${tmpdir} | 446 cd ${tmpdir} |
| 430 SubBanner "Untaring ${QEMU_TARBALL}" | 447 SubBanner "Untaring ${QEMU_TARBALL}" |
| 431 tar zxf ${QEMU_TARBALL} | 448 tar xf ${TMP}/${QEMU_TARBALL} |
| 432 cd ${QEMU_DIR} | 449 cd ${QEMU_DIR} |
| 433 | 450 |
| 434 SubBanner "Patching ${QEMU_PATCH}" | 451 SubBanner "Patching ${QEMU_PATCH}" |
| 435 patch -p1 < ${QEMU_PATCH} | 452 patch -p1 < ${QEMU_PATCH} |
| 436 | 453 |
| 437 SubBanner "Configuring" | 454 SubBanner "Configuring" |
| 438 env -i PATH=/usr/bin/:/bin LIBS=-lrt \ | 455 env -i PATH=/usr/bin/:/bin LIBS=-lrt \ |
| 439 ./configure \ | 456 ./configure \ |
| 440 --extra-cflags="-m32" \ | 457 --extra-cflags="-m32" \ |
| 441 --extra-ldflags="-Wl,-rpath=/lib32" \ | |
| 442 --disable-system \ | 458 --disable-system \ |
| 443 --disable-docs \ | 459 --disable-docs \ |
| 444 --enable-linux-user \ | 460 --enable-linux-user \ |
| 445 --disable-darwin-user \ | |
| 446 --disable-bsd-user \ | 461 --disable-bsd-user \ |
| 447 --target-list=arm-linux-user \ | 462 --target-list=arm-linux-user \ |
| 448 --disable-smartcard-nss \ | 463 --disable-smartcard-nss \ |
| 449 --disable-sdl | 464 --disable-sdl |
| 450 | 465 |
| 451 # see above for why we can no longer use -static | 466 # see above for why we can no longer use -static |
| 452 # --static | 467 # --static |
| 453 | 468 |
| 454 SubBanner "Make" | 469 SubBanner "Make" |
| 455 env -i PATH=/usr/bin/:/bin V=99 make MAKE_OPTS=${MAKE_OPTS} | 470 env -i PATH=/usr/bin/:/bin V=99 make MAKE_OPTS=${MAKE_OPTS} |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 elif [[ "$(type -t $1)" != "function" ]]; then | 539 elif [[ "$(type -t $1)" != "function" ]]; then |
| 525 echo "ERROR: unknown function '$1'." >&2 | 540 echo "ERROR: unknown function '$1'." >&2 |
| 526 echo "For help, try:" | 541 echo "For help, try:" |
| 527 echo " $0 help" | 542 echo " $0 help" |
| 528 exit 1 | 543 exit 1 |
| 529 else | 544 else |
| 530 ChangeDirectory | 545 ChangeDirectory |
| 531 SanityCheck | 546 SanityCheck |
| 532 "$@" | 547 "$@" |
| 533 fi | 548 fi |
| OLD | NEW |