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 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 | 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, | 10 # toolchain that runs on x86 linux and generates code for a little-endian, |
11 # hard-float, mips32 target. | 11 # hard-float, mips32 target. |
12 # | 12 # |
13 # It expects the host machine to have relatively recent versions of GMP (4.2.0 | 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. | 14 # or later), MPFR (2.4.2), and MPC (0.8.1) in order to build the GCC. |
15 # | 15 # |
16 # Common way to get those is: | 16 # Common way to get those is: |
17 # sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev | 17 # sudo apt-get install libmpfr-dev libmpc-dev libgmp3-dev |
18 | 18 |
19 ###################################################################### | 19 ###################################################################### |
20 # Config | 20 # Config |
21 ###################################################################### | 21 ###################################################################### |
22 | 22 |
23 set -o nounset | 23 set -o nounset |
24 set -o errexit | 24 set -o errexit |
25 set -o xtrace | 25 set -o xtrace |
26 | 26 |
| 27 readonly SCRIPT_DIR=$(dirname $0) |
| 28 |
27 readonly MAKE_OPTS="-j8" | 29 readonly MAKE_OPTS="-j8" |
28 readonly ARCH="mips32" | 30 readonly ARCH="mips32" |
29 | 31 |
30 readonly GCC_URL="http://ftp.gnu.org/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2" | 32 readonly GCC_URL="http://ftp.gnu.org/gnu/gcc/gcc-4.7.2/gcc-4.7.2.tar.bz2" |
31 readonly GCC_SHA1SUM="a464ba0f26eef24c29bcd1e7489421117fb9ee35" | 33 readonly GCC_SHA1SUM="a464ba0f26eef24c29bcd1e7489421117fb9ee35" |
32 | 34 |
33 readonly BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2" | 35 readonly BINUTILS_URL="http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2" |
34 readonly BINUTILS_SHA1SUM="65b304a0b9a53a686ce50a01173d1f40f8efe404" | 36 readonly BINUTILS_SHA1SUM="65b304a0b9a53a686ce50a01173d1f40f8efe404" |
35 | 37 |
36 readonly KERNEL_URL="http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux-
2.6.38.4.tar.gz" | 38 readonly KERNEL_URL="http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/linux-
2.6.38.4.tar.gz" |
(...skipping 10 matching lines...) Expand all Loading... |
47 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted | 49 readonly INSTALL_ROOT=$(pwd)/toolchain/linux_mips-trusted |
48 | 50 |
49 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted | 51 readonly TMP=$(pwd)/toolchain/tmp/crosstool-trusted |
50 | 52 |
51 readonly BUILD_DIR=${TMP}/build | 53 readonly BUILD_DIR=${TMP}/build |
52 | 54 |
53 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips) | 55 readonly PATCH_MIPS32=$(readlink -f ../third_party/qemu/qemu-0.12.5.patch_mips) |
54 | 56 |
55 readonly JAIL_MIPS32=${INSTALL_ROOT}/sysroot | 57 readonly JAIL_MIPS32=${INSTALL_ROOT}/sysroot |
56 | 58 |
| 59 readonly CROSS_TARBALL="chromesdk_linux_mipsel" |
| 60 |
57 # These are simple compiler wrappers to force 32bit builds. | 61 # These are simple compiler wrappers to force 32bit builds. |
58 readonly CC32=$(readlink -f pnacl/scripts/mygcc32) | 62 readonly CC32=$(readlink -f pnacl/scripts/mygcc32) |
59 readonly CXX32=$(readlink -f pnacl/scripts/myg++32) | 63 readonly CXX32=$(readlink -f pnacl/scripts/myg++32) |
60 | 64 |
61 ###################################################################### | 65 ###################################################################### |
62 # Helper | 66 # Helper |
63 ###################################################################### | 67 ###################################################################### |
64 | 68 |
65 Banner() { | 69 Banner() { |
66 echo "######################################################################" | 70 echo "######################################################################" |
67 echo $* | 71 echo $* |
68 echo "######################################################################" | 72 echo "######################################################################" |
69 } | 73 } |
70 | 74 |
71 SubBanner() { | 75 SubBanner() { |
72 echo "......................................................................" | 76 echo "......................................................................" |
73 echo $* | 77 echo $* |
74 echo "......................................................................" | 78 echo "......................................................................" |
75 } | 79 } |
76 | 80 |
77 Usage() { | 81 Usage() { |
78 echo | 82 echo |
79 echo "$0 trusted_sdk" | 83 echo "$0 <nacl_sdk|chrome_sdk>" |
80 echo | 84 echo |
81 echo "trusted_sdk - Build everything and package it" | 85 echo "nacl_sdk - Build nacl toolchain and package it" |
| 86 echo "chrome_sdk - Build chrome toolchain and package it" |
82 echo | 87 echo |
83 } | 88 } |
84 | 89 |
85 CheckoutOrCopy() { | 90 CheckoutOrCopy() { |
86 local url=$1 | 91 local url=$1 |
87 local revision=$2 | 92 local revision=$2 |
88 local filename="${TMP}/${url##*/}" | 93 local filename="${TMP}/${url##*/}" |
89 local filetype="${url%%:*}" | 94 local filetype="${url%%:*}" |
90 | 95 |
91 if [ "${filename}" == "" ]; then | 96 if [ "${filename}" == "" ]; then |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 echo "Exiting." | 181 echo "Exiting." |
177 exit 1 | 182 exit 1 |
178 fi | 183 fi |
179 done | 184 done |
180 } | 185 } |
181 | 186 |
182 | 187 |
183 ClearInstallDir() { | 188 ClearInstallDir() { |
184 Banner "clearing dirs in ${INSTALL_ROOT}" | 189 Banner "clearing dirs in ${INSTALL_ROOT}" |
185 rm -rf ${INSTALL_ROOT}/* | 190 rm -rf ${INSTALL_ROOT}/* |
| 191 mkdir -p ${JAIL_MIPS32} |
186 } | 192 } |
187 | 193 |
188 ClearBuildDir() { | 194 ClearBuildDir() { |
189 Banner "clearing dirs in ${BUILD_DIR}" | 195 Banner "clearing dirs in ${BUILD_DIR}" |
190 rm -rf ${BUILD_DIR}/* | 196 rm -rf ${BUILD_DIR}/* |
191 } | 197 } |
192 | 198 |
193 CreateTarBall() { | 199 CreateTarBall() { |
194 local tarball=$1 | 200 local tarball=$1 |
195 Banner "creating tar ball ${tarball}" | 201 Banner "creating tar ball ${tarball}" |
196 tar cfz ${tarball}-mips.tgz -C ${INSTALL_ROOT} . | 202 tar cfz ${tarball}.tgz -C ${INSTALL_ROOT} . |
197 } | 203 } |
198 | 204 |
199 | 205 |
200 # Download the toolchain source tarballs or use a local copy when available. | 206 # Download the toolchain source tarballs or use a local copy when available. |
201 DownloadOrCopyAndInstallToolchain() { | 207 DownloadOrCopyAndInstallToolchain() { |
202 Banner "Installing toolchain" | 208 Banner "Installing toolchain" |
203 | 209 |
204 local tarball="${TMP}/${BINUTILS_URL##*/}" | 210 local tarball="${TMP}/${BINUTILS_URL##*/}" |
205 DownloadOrCopyAndVerify ${BINUTILS_URL} ${BINUTILS_SHA1SUM} | 211 DownloadOrCopyAndVerify ${BINUTILS_URL} ${BINUTILS_SHA1SUM} |
206 SubBanner "extracting from ${tarball}" | 212 SubBanner "extracting from ${tarball}" |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 } | 467 } |
462 | 468 |
463 | 469 |
464 # ---------------------------------------------------------------------- | 470 # ---------------------------------------------------------------------- |
465 # mips32 deb files to complete our code sourcery jail | 471 # mips32 deb files to complete our code sourcery jail |
466 # ---------------------------------------------------------------------- | 472 # ---------------------------------------------------------------------- |
467 | 473 |
468 readonly REPO_DEBIAN=http://ftp.debian.org/debian | 474 readonly REPO_DEBIAN=http://ftp.debian.org/debian |
469 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package
s.bz2 | 475 readonly MIPS32_PACKAGES=${REPO_DEBIAN}/dists/squeeze/main/binary-mipsel/Package
s.bz2 |
470 | 476 |
471 readonly TMP_PACKAGELIST_MIPS32=${TMP}/../packagelist_mipsel.tmp | 477 readonly BASE_PACKAGELIST_MIPS32=${SCRIPT_DIR}/packagelist.squeeze.mipsel.base |
472 | 478 readonly EXTRA_PACKAGELIST_MIPS32=${SCRIPT_DIR}/packagelist.squeeze.mipsel.extra |
473 # These are good enough for native client. | 479 readonly TMP_BASE_PKG_MIPS32=${TMP}/packagelist.generated.squeeze.mipsel.base |
474 readonly BASE_PACKAGES="\ | 480 readonly TMP_EXTRA_PKG_MIPS32=${TMP}/packagelist.generated.squeeze.mipsel.extra |
475 libssl0.9.8 \ | |
476 libssl-dev \ | |
477 libx11-6 \ | |
478 libx11-dev \ | |
479 x11proto-core-dev \ | |
480 libxt6 \ | |
481 libxt-dev \ | |
482 zlib1g \ | |
483 zlib1g-dev \ | |
484 libasound2 \ | |
485 libasound2-dev \ | |
486 libaa1 \ | |
487 libaa1-dev \ | |
488 libxau-dev \ | |
489 libxau6 \ | |
490 libxcb1 \ | |
491 libxcb1-dev \ | |
492 libxcb-render0 \ | |
493 libxcb-render0-dev \ | |
494 libxcb-render-util0 \ | |
495 libxcb-render-util0-dev \ | |
496 libxcb-shm0 \ | |
497 libxcb-shm0-dev \ | |
498 libxdmcp6 \ | |
499 libxdmcp-dev \ | |
500 libxss1 \ | |
501 libxss-dev" | |
502 | 481 |
503 GeneratePackageLists() { | 482 GeneratePackageLists() { |
504 Banner "generating package lists for mips32" | 483 local sdk_target=$1 |
505 echo -n > ${TMP_PACKAGELIST_MIPS32} | 484 local packages= |
| 485 local TMP_PACKAGELIST= |
| 486 Banner "generating ${sdk_target} package lists for mips32" |
506 DownloadOrCopy ${MIPS32_PACKAGES} | 487 DownloadOrCopy ${MIPS32_PACKAGES} |
507 bzcat ${TMP}/Packages.bz2\ | 488 bzcat ${TMP}/Packages.bz2\ |
508 | egrep '^(Package:|Filename:)' > ${TMP}/Packages_mipsel | 489 | egrep '^(Package:|Filename:)' > ${TMP}/Packages_mipsel |
509 for pkg in ${BASE_PACKAGES} ; do | 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 |
510 grep -A 1 "${pkg}\$" ${TMP}/Packages_mipsel\ | 505 grep -A 1 "${pkg}\$" ${TMP}/Packages_mipsel\ |
511 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST_MIPS32} | 506 | egrep -o "pool/.*" >> ${TMP_PACKAGELIST} |
512 done | 507 done |
513 } | 508 } |
514 | 509 |
515 InstallMissingLibraries() { | 510 InstallMissingLibraries() { |
516 readonly DEP_FILES_NEEDED_MIPS32=$(cat ${TMP_PACKAGELIST_MIPS32}) | 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 |
517 for file in ${DEP_FILES_NEEDED_MIPS32} ; do | 523 for file in ${DEP_FILES_NEEDED_MIPS32} ; do |
518 local package="${TMP}/${file##*/}" | 524 local package="${TMP}/${file##*/}" |
519 Banner "installing ${file}" | 525 Banner "installing ${file}" |
520 DownloadOrCopy ${REPO_DEBIAN}/${file} | 526 DownloadOrCopy ${REPO_DEBIAN}/${file} |
521 SubBanner "extracting to ${JAIL_MIPS32}" | 527 SubBanner "extracting to ${JAIL_MIPS32}" |
522 dpkg --fsys-tarfile ${package}\ | 528 dpkg --fsys-tarfile ${package}\ |
523 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32} | 529 | tar -xvf - --exclude=./usr/share -C ${JAIL_MIPS32} |
524 done | 530 done |
525 | 531 |
526 Banner "some cleanup" | 532 Banner "some cleanup" |
(...skipping 18 matching lines...) Expand all Loading... |
545 | 551 |
546 rm -f librt.so | 552 rm -f librt.so |
547 ln -s ../../lib/librt.so.1 librt.so | 553 ln -s ../../lib/librt.so.1 librt.so |
548 | 554 |
549 rm -f libpcre.so | 555 rm -f libpcre.so |
550 ln -s ../../lib/libpcre.so.3 libpcre.so | 556 ln -s ../../lib/libpcre.so.3 libpcre.so |
551 | 557 |
552 rm -f libresolv.so | 558 rm -f libresolv.so |
553 ln -s ../../lib/libresolv.so.2 libresolv.so | 559 ln -s ../../lib/libresolv.so.2 libresolv.so |
554 | 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* |
555 ln -s ../../../mipsel-linux-gnu/lib/libstdc++.so.6.0.17 . | 574 ln -s ../../../mipsel-linux-gnu/lib/libstdc++.so.6.0.17 . |
556 ln -s libstdc++.so.6.0.17 libstdc++.so.6 | 575 ln -s libstdc++.so.6.0.17 libstdc++.so.6 |
557 ln -s libstdc++.so.6.0.17 libstdc++.so | 576 ln -s libstdc++.so.6.0.17 libstdc++.so |
558 | 577 |
| 578 rm -f libgcc_s.so* |
559 ln -s ../../../mipsel-linux-gnu/lib/libgcc_s.so.1 . | 579 ln -s ../../../mipsel-linux-gnu/lib/libgcc_s.so.1 . |
560 ln -s libgcc_s.so.1 libgcc_s.so | 580 ln -s libgcc_s.so.1 libgcc_s.so |
561 } | 581 } |
562 | 582 |
563 BuildAndInstallQemu() { | 583 BuildAndInstallQemu() { |
564 local saved_dir=$(pwd) | 584 local saved_dir=$(pwd) |
565 local tmpdir="${TMP}/qemu-mips.nacl" | 585 local tmpdir="${TMP}/qemu-mips.nacl" |
566 local tarball="qemu-0.12.5.tar.gz" | 586 local tarball="qemu-0.12.5.tar.gz" |
567 | 587 |
568 Banner "Building qemu in ${tmpdir}" | 588 Banner "Building qemu in ${tmpdir}" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 ###################################################################### | 632 ###################################################################### |
613 # Main | 633 # Main |
614 ###################################################################### | 634 ###################################################################### |
615 | 635 |
616 if [[ $# -eq 0 ]] ; then | 636 if [[ $# -eq 0 ]] ; then |
617 echo "you must specify a mode on the commandline:" | 637 echo "you must specify a mode on the commandline:" |
618 echo | 638 echo |
619 Usage | 639 Usage |
620 exit -1 | 640 exit -1 |
621 | 641 |
622 elif [[ $1 == "trusted_sdk" ]]; then | 642 elif [[ $1 == "nacl_sdk" || $1 == "chrome_sdk" ]] ; then |
623 mkdir -p ${TMP} | 643 mkdir -p ${TMP} |
624 SanityCheck | 644 SanityCheck |
625 ClearInstallDir | 645 ClearInstallDir |
626 ClearBuildDir | 646 ClearBuildDir |
627 DownloadOrCopyAndInstallToolchain | 647 DownloadOrCopyAndInstallToolchain |
628 GeneratePackageLists | 648 GeneratePackageLists $1 |
629 InstallMissingLibraries | 649 InstallMissingLibraries $1 |
630 InstallTrustedLinkerScript | 650 if [[ $1 == "nacl_sdk" ]] ; then |
631 BuildAndInstallQemu | 651 InstallTrustedLinkerScript |
632 CreateTarBall $1 | 652 BuildAndInstallQemu |
| 653 CreateTarBall $1 |
| 654 else |
| 655 CreateTarBall ${CROSS_TARBALL} |
| 656 fi |
633 | 657 |
634 else | 658 else |
635 Usage | 659 Usage |
636 exit -1 | 660 exit -1 |
637 | 661 |
638 fi | 662 fi |
639 | 663 |
OLD | NEW |