blob: 84b9908f455f3748cec718e8238524d325165314 [file] [log] [blame]
Devon H. O'Dell553be842009-11-14 15:29:09 -08001#!/usr/bin/env bash
Rob Pikedf28e142008-06-11 13:34:08 -07002# 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 Cox76036192008-09-18 15:06:43 -07006set -e
Russ Coxda392d92010-08-18 10:08:49 -04007if [ ! -f env.bash ]; then
8 echo 'make.bash must be run from $GOROOT/src' 1>&2
9 exit 1
10fi
Russ Cox69fd2a42010-03-31 19:48:33 -070011. ./env.bash
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080012
Russ Coxeedfc442011-03-18 18:23:00 -040013if 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
22fi
23
Russ Cox5bf658c2010-09-02 14:20:02 -040024# Create target directories
25if [ "$GOBIN" = "$GOROOT/bin" ]; then
26 mkdir -p "$GOROOT/bin"
27fi
28mkdir -p "$GOROOT/pkg"
29
Russ Coxda392d92010-08-18 10:08:49 -040030GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT}
Russ Coxda392d92010-08-18 10:08:49 -040031
Christopher Wedgwoodcffdb1e2010-05-15 10:08:29 -070032MAKEFLAGS=${MAKEFLAGS:-"-j4"}
33export MAKEFLAGS
Russ Cox6c827cb2009-11-24 16:01:35 -080034unset CDPATH # in case user has it set
35
Sergio Luis O. B. Correia6fc82072009-11-23 17:32:51 -080036rm -f "$GOBIN"/quietgcc
Ian Lance Taylorfab7ae12009-11-01 16:13:37 -080037CC=${CC:-gcc}
Ian Lance Taylor84f67eb2010-07-15 14:15:39 -070038export CC
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080039sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc
Sergio Luis O. B. Correia6fc82072009-11-23 17:32:51 -080040chmod +x "$GOBIN"/quietgcc
Russ Coxd2dfd762008-11-19 12:54:44 -080041
Sergio Luis O. B. Correia6fc82072009-11-23 17:32:51 -080042rm -f "$GOBIN"/gomake
Russ Coxda392d92010-08-18 10:08:49 -040043(
44 echo '#!/bin/sh'
45 echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}'
46 echo 'exec '$MAKE' "$@"'
47) >"$GOBIN"/gomake
Sergio Luis O. B. Correia6fc82072009-11-23 17:32:51 -080048chmod +x "$GOBIN"/gomake
Devon H. O'Dell553be842009-11-14 15:29:09 -080049
Alex Brainman37dca9d2011-05-04 11:16:55 +100050# TODO(brainman): delete this after 01/01/2012.
51rm -f "$GOBIN"/gotest # remove old bash version of gotest on Windows
52
Russ Coxd9f1ddb2011-01-25 10:19:39 -050053if [ -d /selinux -a -f /selinux/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
Adam Langley2643f742009-11-11 15:02:15 -080054 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
67fi
68
Rob Pikea0c55432009-11-24 21:07:05 -080069(
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080070 cd "$GOROOT"/src/pkg;
Rob Pikea0c55432009-11-24 21:07:05 -080071 bash deps.bash # do this here so clean.bash will work in the pkg directory
72)
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080073bash "$GOROOT"/src/clean.bash
Russ Cox9ff712e2009-11-10 19:20:34 -080074
Russ Cox15f336b2010-08-25 17:54:10 -040075# pkg builds libcgo and the Go programs in cmd.
76for i in lib9 libbio libmach cmd pkg
Russ Coxbede9922009-06-22 15:43:50 -070077do
Dave Cheney432b4f32011-03-01 09:20:32 +110078 echo; echo; echo %%%% making $i %%%%; echo
79 gomake -C $i install
Russ Coxbede9922009-06-22 15:43:50 -070080done
Rob Pikec80b06a2008-09-11 13:03:46 -070081
Russ Coxda392d92010-08-18 10:08:49 -040082# 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.
85installed() {
Russ Cox3a2ba992010-12-13 15:50:57 -050086 eval $(gomake --no-print-directory -f Make.inc go-env)
Russ Cox6b7dd4c2008-11-18 10:08:46 -080087 echo
Russ Coxda392d92010-08-18 10:08:49 -040088 echo ---
89 echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
90 echo Installed commands in "$GOBIN".
Russ Coxaafe474e2010-08-24 20:00:33 -040091 case "$OLDPATH" in
Andrew Gerrand6e87a0a2010-10-25 16:38:48 +110092 "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
Russ Coxaafe474e2010-08-24 20:00:33 -040093 ;;
94 *)
Russ Coxe3034ad2010-08-24 20:43:31 -040095 echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
Russ Coxaafe474e2010-08-24 20:00:33 -040096 esac
Russ Coxda392d92010-08-18 10:08:49 -040097 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