blob: 3580d2a0bdeef5e35164cd454a48ac655e79d1e8 [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
Christopher Wedgwood604bd702011-10-13 12:25:25 -040013if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then
Russ Coxeedfc442011-03-18 18:23:00 -040014 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
Bobby Powers90c50702011-11-11 16:41:37 -050053# on Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux,
54# so loop through the possible selinux mount points
55for se_mount in /selinux /sys/fs/selinux
56do
57 if [ -d $se_mount -a -f $se_mount/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
58 if ! cat $se_mount/booleans/allow_execstack | grep -c '^1 1$' >> /dev/null ; then
59 echo "WARNING: the default SELinux policy on, at least, Fedora 12 breaks "
60 echo "Go. You can enable the features that Go needs via the following "
61 echo "command (as root):"
62 echo " # setsebool -P allow_execstack 1"
63 echo
64 echo "Note that this affects your system globally! "
65 echo
66 echo "The build will continue in five seconds in case we "
67 echo "misdiagnosed the issue..."
Adam Langley2643f742009-11-11 15:02:15 -080068
Bobby Powers90c50702011-11-11 16:41:37 -050069 sleep 5
70 fi
Adam Langley2643f742009-11-11 15:02:15 -080071 fi
Bobby Powers90c50702011-11-11 16:41:37 -050072done
Adam Langley2643f742009-11-11 15:02:15 -080073
Rob Pikea0c55432009-11-24 21:07:05 -080074(
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080075 cd "$GOROOT"/src/pkg;
Rob Pikea0c55432009-11-24 21:07:05 -080076 bash deps.bash # do this here so clean.bash will work in the pkg directory
Russ Cox12ece772011-10-14 15:54:36 -040077) || exit 1
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080078bash "$GOROOT"/src/clean.bash
Russ Cox9ff712e2009-11-10 19:20:34 -080079
Russ Cox15f336b2010-08-25 17:54:10 -040080# pkg builds libcgo and the Go programs in cmd.
81for i in lib9 libbio libmach cmd pkg
Russ Coxbede9922009-06-22 15:43:50 -070082do
Dave Cheney432b4f32011-03-01 09:20:32 +110083 echo; echo; echo %%%% making $i %%%%; echo
84 gomake -C $i install
Russ Coxbede9922009-06-22 15:43:50 -070085done
Rob Pikec80b06a2008-09-11 13:03:46 -070086
Russ Coxda392d92010-08-18 10:08:49 -040087# Print post-install messages.
88# Implemented as a function so that all.bash can repeat the output
89# after run.bash finishes running all the tests.
90installed() {
Russ Cox3a2ba992010-12-13 15:50:57 -050091 eval $(gomake --no-print-directory -f Make.inc go-env)
Russ Cox6b7dd4c2008-11-18 10:08:46 -080092 echo
Russ Coxda392d92010-08-18 10:08:49 -040093 echo ---
94 echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
95 echo Installed commands in "$GOBIN".
Russ Coxaafe474e2010-08-24 20:00:33 -040096 case "$OLDPATH" in
Andrew Gerrand6e87a0a2010-10-25 16:38:48 +110097 "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
Russ Coxaafe474e2010-08-24 20:00:33 -040098 ;;
99 *)
Russ Coxe3034ad2010-08-24 20:43:31 -0400100 echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
Russ Coxaafe474e2010-08-24 20:00:33 -0400101 esac
Russ Coxda392d92010-08-18 10:08:49 -0400102 echo The compiler is $GC.
103 if [ "$(uname)" = "Darwin" ]; then
104 echo
105 echo On OS X the debuggers must be installed setgrp procmod.
106 echo Read and run ./sudo.bash to install the debuggers.
107 fi
108 if [ "$GOROOT_FINAL" != "$GOROOT" ]; then
109 echo
110 echo The binaries expect "$GOROOT" to be copied or moved to "$GOROOT_FINAL".
111 fi
112}
113
114(installed) # run in sub-shell to avoid polluting environment
115