blob: 3878d263f2ac33d61846b4366a5e42976cab72b1 [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
Bobby Powers90c50702011-11-11 16:41:37 -050050# on Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux,
51# so loop through the possible selinux mount points
52for se_mount in /selinux /sys/fs/selinux
53do
54 if [ -d $se_mount -a -f $se_mount/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
55 if ! cat $se_mount/booleans/allow_execstack | grep -c '^1 1$' >> /dev/null ; then
56 echo "WARNING: the default SELinux policy on, at least, Fedora 12 breaks "
57 echo "Go. You can enable the features that Go needs via the following "
58 echo "command (as root):"
59 echo " # setsebool -P allow_execstack 1"
60 echo
61 echo "Note that this affects your system globally! "
62 echo
63 echo "The build will continue in five seconds in case we "
64 echo "misdiagnosed the issue..."
Adam Langley2643f742009-11-11 15:02:15 -080065
Bobby Powers90c50702011-11-11 16:41:37 -050066 sleep 5
67 fi
Adam Langley2643f742009-11-11 15:02:15 -080068 fi
Bobby Powers90c50702011-11-11 16:41:37 -050069done
Adam Langley2643f742009-11-11 15:02:15 -080070
Russ Cox05097272011-12-21 15:57:47 -050071$USE_GO_TOOL ||
Rob Pikea0c55432009-11-24 21:07:05 -080072(
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080073 cd "$GOROOT"/src/pkg;
Rob Pikea0c55432009-11-24 21:07:05 -080074 bash deps.bash # do this here so clean.bash will work in the pkg directory
Russ Cox12ece772011-10-14 15:54:36 -040075) || exit 1
Devon H. O'Dell857d4cf2009-12-11 15:14:09 -080076bash "$GOROOT"/src/clean.bash
Russ Cox9ff712e2009-11-10 19:20:34 -080077
Shenghou Mafec7aa92012-01-19 17:13:33 -050078# pkg builds runtime/cgo and the Go programs in cmd.
Russ Cox55889402011-12-19 15:51:13 -050079for i in lib9 libbio libmach cmd
Russ Coxbede9922009-06-22 15:43:50 -070080do
Dave Cheney432b4f32011-03-01 09:20:32 +110081 echo; echo; echo %%%% making $i %%%%; echo
82 gomake -C $i install
Russ Coxbede9922009-06-22 15:43:50 -070083done
Rob Pikec80b06a2008-09-11 13:03:46 -070084
Russ Cox55889402011-12-19 15:51:13 -050085echo; echo; echo %%%% making runtime generated files %%%%; echo
Russ Cox55889402011-12-19 15:51:13 -050086
Russ Cox41a61652011-12-20 16:50:13 -050087(
88 cd "$GOROOT"/src/pkg/runtime
89 ./autogen.sh
Russ Cox8f5f3472011-12-21 07:47:12 -050090 gomake install; gomake clean # copy runtime.h to pkg directory
Russ Cox41a61652011-12-20 16:50:13 -050091) || exit 1
92
93if $USE_GO_TOOL; then
94 echo
95 echo '# Building go command from bootstrap script.'
Shenghou Mac5f84332012-01-17 11:18:15 -050096 ./buildscript/${GOOS}_$GOARCH.sh
Russ Cox41a61652011-12-20 16:50:13 -050097
98 echo '# Building Go code.'
Russ Cox146a7032012-01-09 16:44:01 -080099 go install -a -v std
Russ Cox41a61652011-12-20 16:50:13 -0500100else
101 echo; echo; echo %%%% making pkg %%%%; echo
102 gomake -C pkg install
103fi
Russ Cox55889402011-12-19 15:51:13 -0500104
Russ Coxda392d92010-08-18 10:08:49 -0400105# Print post-install messages.
106# Implemented as a function so that all.bash can repeat the output
107# after run.bash finishes running all the tests.
108installed() {
Russ Cox3a2ba992010-12-13 15:50:57 -0500109 eval $(gomake --no-print-directory -f Make.inc go-env)
Russ Cox6b7dd4c2008-11-18 10:08:46 -0800110 echo
Russ Coxda392d92010-08-18 10:08:49 -0400111 echo ---
112 echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
113 echo Installed commands in "$GOBIN".
Russ Coxaafe474e2010-08-24 20:00:33 -0400114 case "$OLDPATH" in
Andrew Gerrand6e87a0a2010-10-25 16:38:48 +1100115 "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
Russ Coxaafe474e2010-08-24 20:00:33 -0400116 ;;
117 *)
Russ Coxe3034ad2010-08-24 20:43:31 -0400118 echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
Russ Coxaafe474e2010-08-24 20:00:33 -0400119 esac
Russ Coxda392d92010-08-18 10:08:49 -0400120 echo The compiler is $GC.
121 if [ "$(uname)" = "Darwin" ]; then
122 echo
123 echo On OS X the debuggers must be installed setgrp procmod.
124 echo Read and run ./sudo.bash to install the debuggers.
125 fi
126 if [ "$GOROOT_FINAL" != "$GOROOT" ]; then
127 echo
128 echo The binaries expect "$GOROOT" to be copied or moved to "$GOROOT_FINAL".
129 fi
130}
131
132(installed) # run in sub-shell to avoid polluting environment
133