1 #!/usr/bin/env bash
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
6 set -e
7 if [ ! -f env.bash ]; then
8 echo 'make.bash must be run from $GOROOT/src' 1>&2
9 exit 1
10 fi
11 . ./env.bash
12
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
24 # Create target directories
25 if [ "$GOBIN" = "$GOROOT/bin" ]; then
26 mkdir -p "$GOROOT/bin"
27 fi
28 mkdir -p "$GOROOT/pkg"
29
30 GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT}
31
32 MAKEFLAGS=${MAKEFLAGS:-"-j4"}
33 export MAKEFLAGS
34 unset CDPATH # in case user has it set
35
36 rm -f "$GOBIN"/quietgcc
37 CC=${CC:-gcc}
38 export CC
39 sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc
40 chmod +x "$GOBIN"/quietgcc
41
42 rm -f "$GOBIN"/gomake
43 (
44 echo '#!/bin/sh'
45 echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}'
46 echo 'exec '$MAKE' "$@"'
47 ) >"$GOBIN"/gomake
48 chmod +x "$GOBIN"/gomake
49
50 # TODO(brainman): delete this after 01/01/2012.
51 rm -f "$GOBIN"/gotest # remove old bash version of gotest on Windows
52
53 if [ -d /selinux -a -f /selinux/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
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
69 (
70 cd "$GOROOT"/src/pkg;
71 bash deps.bash # do this here so clean.bash will work in the pkg directory
72 )
73 bash "$GOROOT"/src/clean.bash
74
75 # pkg builds libcgo and the Go programs in cmd.
76 for i in lib9 libbio libmach cmd pkg
77 do
78 echo; echo; echo %%%% making $i %%%%; echo
79 gomake -C $i install
80 done
81
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() {
86 eval $(gomake --no-print-directory -f Make.inc go-env)
87 echo
88 echo ---
89 echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
90 echo Installed commands in "$GOBIN".
91 case "$OLDPATH" in
92 "$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
93 ;;
94 *)
95 echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
96 esac
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