| OLD | NEW |
| 1 #!/bin/bash -e | 1 #!/bin/bash -e |
| 2 | 2 |
| 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # Script to install everything needed to build chromium (well, ideally, anyway) | 7 # Script to install everything needed to build chromium (well, ideally, anyway) |
| 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions | 8 # See http://code.google.com/p/chromium/wiki/LinuxBuildInstructions |
| 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit | 9 # and http://code.google.com/p/chromium/wiki/LinuxBuild64Bit |
| 10 | 10 |
| 11 usage() { | 11 usage() { |
| 12 echo "Usage: $0 [--options]" | 12 echo "Usage: $0 [--options]" |
| 13 echo "Options:" | 13 echo "Options:" |
| 14 echo "--[no-]syms: enable or disable installation of debugging symbols" | 14 echo "--[no-]syms: enable or disable installation of debugging symbols" |
| 15 echo "--[no-]gold: enable or disable installation of gold linker" | |
| 16 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" | 15 echo "--[no-]lib32: enable or disable installation of 32 bit libraries" |
| 17 echo "--[no-]restore-usr-bin-ld: enable or disable restoring /usr/bin/ld to" | |
| 18 echo " ld.bfd if it is currently gold" | |
| 19 echo "Script will prompt interactively if options not given." | 16 echo "Script will prompt interactively if options not given." |
| 20 exit 1 | 17 exit 1 |
| 21 } | 18 } |
| 22 | 19 |
| 23 while test "$1" != "" | 20 while test "$1" != "" |
| 24 do | 21 do |
| 25 case "$1" in | 22 case "$1" in |
| 26 --syms) do_inst_syms=1;; | 23 --syms) do_inst_syms=1;; |
| 27 --no-syms) do_inst_syms=0;; | 24 --no-syms) do_inst_syms=0;; |
| 28 --gold) do_inst_gold=1;; | |
| 29 --no-gold) do_inst_gold=0;; | |
| 30 --lib32) do_inst_lib32=1;; | 25 --lib32) do_inst_lib32=1;; |
| 31 --no-lib32) do_inst_lib32=0;; | 26 --no-lib32) do_inst_lib32=0;; |
| 32 --restore-usr-bin-ld) do_restore_usr_bin_ld=1;; | |
| 33 --no-restore-usr-bin-ld) do_restore_usr_bin_ld=0;; | |
| 34 *) usage;; | 27 *) usage;; |
| 35 esac | 28 esac |
| 36 shift | 29 shift |
| 37 done | 30 done |
| 38 | 31 |
| 39 install_gold() { | |
| 40 # Gold is optional; it's a faster replacement for ld, | |
| 41 # and makes life on 2GB machines much more pleasant. | |
| 42 | |
| 43 # First make sure root can access this directory, as that's tripped | |
| 44 # up some folks. | |
| 45 if sudo touch xyz.$$ | |
| 46 then | |
| 47 sudo rm xyz.$$ | |
| 48 else | |
| 49 echo root cannot write to the current directory, not installing gold | |
| 50 return | |
| 51 fi | |
| 52 | |
| 53 BINUTILS=binutils-2.21.1 | |
| 54 BINUTILS_URL=http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2 | |
| 55 BINUTILS_SHA1=525255ca6874b872540c9967a1d26acfbc7c8230 | |
| 56 | |
| 57 test -f $BINUTILS.tar.bz2 || wget $BINUTILS_URL | |
| 58 if test "`sha1sum $BINUTILS.tar.bz2|cut -d' ' -f1`" != "$BINUTILS_SHA1" | |
| 59 then | |
| 60 echo Bad sha1sum for $BINUTILS.tar.bz2 | |
| 61 exit 1 | |
| 62 fi | |
| 63 | |
| 64 tar -xjvf $BINUTILS.tar.bz2 | |
| 65 cd $BINUTILS | |
| 66 ./configure --prefix=/usr/local/gold --enable-gold=default --enable-threads \ | |
| 67 --enable-bfd=yes | |
| 68 NCPU=`cat /proc/cpuinfo |grep ^processor|wc -l` | |
| 69 make maybe-all-binutils maybe-all-gold maybe-all-ld -j${NCPU} | |
| 70 if sudo make maybe-install-binutils maybe-install-gold maybe-install-ld | |
| 71 then | |
| 72 # Still need to figure out graceful way of pointing gyp to use | |
| 73 # /usr/local/gold/bin/ld without requiring him to set environment | |
| 74 # variables. | |
| 75 sudo strip /usr/local/gold/bin/ld.gold | |
| 76 sudo strip /usr/local/gold/bin/ld.bfd | |
| 77 else | |
| 78 echo "make install failed, not installing gold" | |
| 79 fi | |
| 80 } | |
| 81 | |
| 82 if ! egrep -q \ | 32 if ! egrep -q \ |
| 83 'Ubuntu (10\.04|10\.10|11\.04|11\.10|lucid|maverick|natty|oneiric)' \ | 33 'Ubuntu (10\.04|10\.10|11\.04|11\.10|lucid|maverick|natty|oneiric)' \ |
| 84 /etc/issue; then | 34 /etc/issue; then |
| 85 echo "Only Ubuntu 10.04 (lucid) through 11.10 (oneiric) are currently" \ | 35 echo "Only Ubuntu 10.04 (lucid) through 11.10 (oneiric) are currently" \ |
| 86 "supported" >&2 | 36 "supported" >&2 |
| 87 exit 1 | 37 exit 1 |
| 88 fi | 38 fi |
| 89 | 39 |
| 90 if ! uname -m | egrep -q "i686|x86_64"; then | 40 if ! uname -m | egrep -q "i686|x86_64"; then |
| 91 echo "Only x86 architectures are currently supported" >&2 | 41 echo "Only x86 architectures are currently supported" >&2 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 echo "The following command failed: " ${new_list_cmd} | 189 echo "The following command failed: " ${new_list_cmd} |
| 240 echo | 190 echo |
| 241 echo "It produces the following output:" | 191 echo "It produces the following output:" |
| 242 yes n | $new_list_cmd || true | 192 yes n | $new_list_cmd || true |
| 243 echo | 193 echo |
| 244 echo "You will have to install the above packages yourself." | 194 echo "You will have to install the above packages yourself." |
| 245 echo | 195 echo |
| 246 exit 100 | 196 exit 100 |
| 247 fi | 197 fi |
| 248 | 198 |
| 249 # Some operating systems already ship gold (on recent Debian and | |
| 250 # Ubuntu you can do "apt-get install binutils-gold" to get it), but | |
| 251 # older releases didn't. Additionally, gold 2.20 (included in Ubuntu | |
| 252 # Lucid) makes binaries that just segfault, and 2.20.1 does not support | |
| 253 # --map-whole-files. | |
| 254 # So install from source if we don't have a good version. | |
| 255 | |
| 256 case `ld --version` in | |
| 257 *gold*2.2[1-9].*) | |
| 258 echo "*** Warning ***" | |
| 259 echo "If the default linker is gold, linking may fail for:" | |
| 260 echo "the Linux kernel, kernel modules, Valgrind, and Wine." | |
| 261 echo "If you previously installed gold as the default linker," | |
| 262 echo "you can restore the original linker by running:" | |
| 263 echo "'cd /usr/bin; sudo rm ld; sudo mv ld.orig ld'" | |
| 264 echo | |
| 265 if [ "$do_restore_usr_bin_ld" = "" ] | |
| 266 then | |
| 267 echo -n "Restore /usr/bin/ld to the original linker? (Y/n) " | |
| 268 if yes_no 0 | |
| 269 then | |
| 270 do_restore_usr_bin_ld=1 | |
| 271 fi | |
| 272 echo | |
| 273 fi | |
| 274 if [ "$do_restore_usr_bin_ld" = "1" ] | |
| 275 then | |
| 276 if sudo mv /usr/bin/ld.orig /usr/bin/ld | |
| 277 then | |
| 278 echo "Restored /usr/bin/ld.orig as /usr/bin/ld" | |
| 279 else | |
| 280 echo "Failed to restore /usr/bin/ld.orig as /usr/bin/ld" | |
| 281 fi | |
| 282 echo | |
| 283 fi | |
| 284 ;; | |
| 285 esac | |
| 286 | |
| 287 # Check the gold version first. | |
| 288 gold_up_to_date="1" | |
| 289 if [ -x "/usr/local/gold/bin/ld" ] | |
| 290 then | |
| 291 case `/usr/local/gold/bin/ld --version` in | |
| 292 *gold*2.2[1-9].*) ;; | |
| 293 * ) | |
| 294 gold_up_to_date="0" | |
| 295 esac | |
| 296 fi | |
| 297 | |
| 298 # Then check and make sure ld.bfd exists. | |
| 299 if [ "$gold_up_to_date" = "1" ] && [ ! -x "/usr/local/gold/bin/ld.bfd" ] | |
| 300 then | |
| 301 gold_up_to_date="0" | |
| 302 fi | |
| 303 | |
| 304 if [ "$gold_up_to_date" = "0" ] | |
| 305 then | |
| 306 if test "$do_inst_gold" = "" | |
| 307 then | |
| 308 echo "Gold is a new linker that links Chrome 5x faster than GNU ld." | |
| 309 echo -n "*** To use the gold linker, " | |
| 310 echo "you must pass -B/usr/local/gold/bin/ to g++ ***" | |
| 311 echo -n "Install the gold linker? (y/N) " | |
| 312 if yes_no 1; then | |
| 313 do_inst_gold=1 | |
| 314 fi | |
| 315 fi | |
| 316 if test "$do_inst_gold" = "1" | |
| 317 then | |
| 318 echo "Building binutils with gold..." | |
| 319 install_gold || exit 99 | |
| 320 else | |
| 321 echo "Not installing gold." | |
| 322 fi | |
| 323 fi | |
| 324 | |
| 325 # Install 32bit backwards compatibility support for 64bit systems | 199 # Install 32bit backwards compatibility support for 64bit systems |
| 326 if [ "$(uname -m)" = "x86_64" ]; then | 200 if [ "$(uname -m)" = "x86_64" ]; then |
| 327 if test "$do_inst_lib32" = "" | 201 if test "$do_inst_lib32" = "" |
| 328 then | 202 then |
| 329 echo "Installing 32bit libraries not already provided by the system" | 203 echo "Installing 32bit libraries not already provided by the system" |
| 330 echo | 204 echo |
| 331 echo "This is only needed to build a 32-bit Chrome on your 64-bit system." | 205 echo "This is only needed to build a 32-bit Chrome on your 64-bit system." |
| 332 echo | 206 echo |
| 333 echo "While we only need to install a relatively small number of library" | 207 echo "While we only need to install a relatively small number of library" |
| 334 echo "files, we temporarily need to download a lot of large *.deb packages" | 208 echo "files, we temporarily need to download a lot of large *.deb packages" |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 sed -e 's/[.]so[.][0-9].*/.so/' | | 378 sed -e 's/[.]so[.][0-9].*/.so/' | |
| 505 sort -u); do | 379 sort -u); do |
| 506 [ "x${i##*/}" = "xld-linux.so" ] && continue | 380 [ "x${i##*/}" = "xld-linux.so" ] && continue |
| 507 [ -r "$i" ] && continue | 381 [ -r "$i" ] && continue |
| 508 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | | 382 j="$(ls "$i."* | sed -e 's/.*[.]so[.]\([^.]*\)$/\1/;t;d' | |
| 509 sort -n | tail -n 1)" | 383 sort -n | tail -n 1)" |
| 510 [ -r "$i.$j" ] || continue | 384 [ -r "$i.$j" ] || continue |
| 511 sudo ln -s "${i##*/}.$j" "$i" | 385 sudo ln -s "${i##*/}.$j" "$i" |
| 512 done | 386 done |
| 513 fi | 387 fi |
| OLD | NEW |