Devon H. O'Dell | 553be84 | 2009-11-14 15:29:09 -0800 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Rob Pike | df28e14 | 2008-06-11 13:34:08 -0700 | [diff] [blame] | 2 | # Copyright 2009 The Go Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style |
| 4 | # license that can be found in the LICENSE file. |
| 5 | |
Russ Cox | 7603619 | 2008-09-18 15:06:43 -0700 | [diff] [blame] | 6 | set -e |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 7 | if [ ! -f env.bash ]; then |
| 8 | echo 'make.bash must be run from $GOROOT/src' 1>&2 |
| 9 | exit 1 |
| 10 | fi |
Russ Cox | 69fd2a4 | 2010-03-31 19:48:33 -0700 | [diff] [blame] | 11 | . ./env.bash |
Devon H. O'Dell | 857d4cf | 2009-12-11 15:14:09 -0800 | [diff] [blame] | 12 | |
Russ Cox | eedfc44 | 2011-03-18 18:23:00 -0400 | [diff] [blame] | 13 | if ld --version 2>&1 | grep 'gold.*2\.20' >/dev/null; then |
| 14 | echo 'ERROR: Your system has gold 2.20 installed.' |
| 15 | echo 'This version is shipped by Ubuntu even though' |
| 16 | echo 'it is known not to work on Ubuntu.' |
| 17 | echo 'Binaries built with this linker are likely to fail in mysterious ways.' |
| 18 | echo |
| 19 | echo 'Run sudo apt-get remove binutils-gold.' |
| 20 | echo |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
Russ Cox | 5bf658c | 2010-09-02 14:20:02 -0400 | [diff] [blame] | 24 | # Create target directories |
| 25 | if [ "$GOBIN" = "$GOROOT/bin" ]; then |
| 26 | mkdir -p "$GOROOT/bin" |
| 27 | fi |
| 28 | mkdir -p "$GOROOT/pkg" |
| 29 | |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 30 | GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT} |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 31 | |
Christopher Wedgwood | cffdb1e | 2010-05-15 10:08:29 -0700 | [diff] [blame] | 32 | MAKEFLAGS=${MAKEFLAGS:-"-j4"} |
| 33 | export MAKEFLAGS |
Russ Cox | 6c827cb | 2009-11-24 16:01:35 -0800 | [diff] [blame] | 34 | unset CDPATH # in case user has it set |
| 35 | |
Sergio Luis O. B. Correia | 6fc8207 | 2009-11-23 17:32:51 -0800 | [diff] [blame] | 36 | rm -f "$GOBIN"/quietgcc |
Ian Lance Taylor | fab7ae1 | 2009-11-01 16:13:37 -0800 | [diff] [blame] | 37 | CC=${CC:-gcc} |
Ian Lance Taylor | 84f67eb | 2010-07-15 14:15:39 -0700 | [diff] [blame] | 38 | export CC |
Devon H. O'Dell | 857d4cf | 2009-12-11 15:14:09 -0800 | [diff] [blame] | 39 | sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc |
Sergio Luis O. B. Correia | 6fc8207 | 2009-11-23 17:32:51 -0800 | [diff] [blame] | 40 | chmod +x "$GOBIN"/quietgcc |
Russ Cox | d2dfd76 | 2008-11-19 12:54:44 -0800 | [diff] [blame] | 41 | |
Sergio Luis O. B. Correia | 6fc8207 | 2009-11-23 17:32:51 -0800 | [diff] [blame] | 42 | rm -f "$GOBIN"/gomake |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 43 | ( |
| 44 | echo '#!/bin/sh' |
| 45 | echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}' |
| 46 | echo 'exec '$MAKE' "$@"' |
| 47 | ) >"$GOBIN"/gomake |
Sergio Luis O. B. Correia | 6fc8207 | 2009-11-23 17:32:51 -0800 | [diff] [blame] | 48 | chmod +x "$GOBIN"/gomake |
Devon H. O'Dell | 553be84 | 2009-11-14 15:29:09 -0800 | [diff] [blame] | 49 | |
Alex Brainman | 37dca9d | 2011-05-04 11:16:55 +1000 | [diff] [blame] | 50 | # TODO(brainman): delete this after 01/01/2012. |
| 51 | rm -f "$GOBIN"/gotest # remove old bash version of gotest on Windows |
| 52 | |
Russ Cox | d9f1ddb | 2011-01-25 10:19:39 -0500 | [diff] [blame] | 53 | if [ -d /selinux -a -f /selinux/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then |
Adam Langley | 2643f74 | 2009-11-11 15:02:15 -0800 | [diff] [blame] | 54 | if ! cat /selinux/booleans/allow_execstack | grep -c '^1 1$' >> /dev/null ; then |
| 55 | echo "WARNING: the default SELinux policy on, at least, Fedora 12 breaks " |
| 56 | echo "Go. You can enable the features that Go needs via the following " |
| 57 | echo "command (as root):" |
| 58 | echo " # setsebool -P allow_execstack 1" |
| 59 | echo |
| 60 | echo "Note that this affects your system globally! " |
| 61 | echo |
| 62 | echo "The build will continue in five seconds in case we " |
| 63 | echo "misdiagnosed the issue..." |
| 64 | |
| 65 | sleep 5 |
| 66 | fi |
| 67 | fi |
| 68 | |
Rob Pike | a0c5543 | 2009-11-24 21:07:05 -0800 | [diff] [blame] | 69 | ( |
Devon H. O'Dell | 857d4cf | 2009-12-11 15:14:09 -0800 | [diff] [blame] | 70 | cd "$GOROOT"/src/pkg; |
Rob Pike | a0c5543 | 2009-11-24 21:07:05 -0800 | [diff] [blame] | 71 | bash deps.bash # do this here so clean.bash will work in the pkg directory |
| 72 | ) |
Devon H. O'Dell | 857d4cf | 2009-12-11 15:14:09 -0800 | [diff] [blame] | 73 | bash "$GOROOT"/src/clean.bash |
Russ Cox | 9ff712e | 2009-11-10 19:20:34 -0800 | [diff] [blame] | 74 | |
Russ Cox | 15f336b | 2010-08-25 17:54:10 -0400 | [diff] [blame] | 75 | # pkg builds libcgo and the Go programs in cmd. |
| 76 | for i in lib9 libbio libmach cmd pkg |
Russ Cox | bede992 | 2009-06-22 15:43:50 -0700 | [diff] [blame] | 77 | do |
Dave Cheney | 432b4f3 | 2011-03-01 09:20:32 +1100 | [diff] [blame] | 78 | echo; echo; echo %%%% making $i %%%%; echo |
| 79 | gomake -C $i install |
Russ Cox | bede992 | 2009-06-22 15:43:50 -0700 | [diff] [blame] | 80 | done |
Rob Pike | c80b06a | 2008-09-11 13:03:46 -0700 | [diff] [blame] | 81 | |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 82 | # Print post-install messages. |
| 83 | # Implemented as a function so that all.bash can repeat the output |
| 84 | # after run.bash finishes running all the tests. |
| 85 | installed() { |
Russ Cox | 3a2ba99 | 2010-12-13 15:50:57 -0500 | [diff] [blame] | 86 | eval $(gomake --no-print-directory -f Make.inc go-env) |
Russ Cox | 6b7dd4c | 2008-11-18 10:08:46 -0800 | [diff] [blame] | 87 | echo |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 88 | echo --- |
| 89 | echo Installed Go for $GOOS/$GOARCH in "$GOROOT". |
| 90 | echo Installed commands in "$GOBIN". |
Russ Cox | aafe474e | 2010-08-24 20:00:33 -0400 | [diff] [blame] | 91 | case "$OLDPATH" in |
Andrew Gerrand | 6e87a0a | 2010-10-25 16:38:48 +1100 | [diff] [blame] | 92 | "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*) |
Russ Cox | aafe474e | 2010-08-24 20:00:33 -0400 | [diff] [blame] | 93 | ;; |
| 94 | *) |
Russ Cox | e3034ad | 2010-08-24 20:43:31 -0400 | [diff] [blame] | 95 | echo '***' "You need to add $GOBIN to your "'$PATH.' '***' |
Russ Cox | aafe474e | 2010-08-24 20:00:33 -0400 | [diff] [blame] | 96 | esac |
Russ Cox | da392d9 | 2010-08-18 10:08:49 -0400 | [diff] [blame] | 97 | echo The compiler is $GC. |
| 98 | if [ "$(uname)" = "Darwin" ]; then |
| 99 | echo |
| 100 | echo On OS X the debuggers must be installed setgrp procmod. |
| 101 | echo Read and run ./sudo.bash to install the debuggers. |
| 102 | fi |
| 103 | if [ "$GOROOT_FINAL" != "$GOROOT" ]; then |
| 104 | echo |
| 105 | echo The binaries expect "$GOROOT" to be copied or moved to "$GOROOT_FINAL". |
| 106 | fi |
| 107 | } |
| 108 | |
| 109 | (installed) # run in sub-shell to avoid polluting environment |
| 110 | |