OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright 2009 The Go Authors. All rights reserved. | 2 # Copyright 2009 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 set -e | 6 set -e |
| 7 |
| 8 if test -z "${GOBIN}"; then |
| 9 if ! test -d "$HOME"/bin; then |
| 10 echo '$GOBIN is not set and $HOME/bin is not a directory or does
not exist.' 1>&2 |
| 11 echo 'mkdir $HOME/bin or set $GOBIN to a directory where binarie
s should' 1>&2 |
| 12 echo 'be installed.' 1>&2 |
| 13 exit 1 |
| 14 fi |
| 15 fi |
| 16 |
7 GOBIN="${GOBIN:-$HOME/bin}" | 17 GOBIN="${GOBIN:-$HOME/bin}" |
8 export MAKEFLAGS=-j4 | 18 export MAKEFLAGS=-j4 |
9 | 19 |
10 unset CDPATH # in case user has it set | 20 unset CDPATH # in case user has it set |
11 | 21 |
12 if ! test -f "$GOROOT"/include/u.h | 22 if ! test -f "$GOROOT"/include/u.h |
13 then | 23 then |
14 echo '$GOROOT is not set correctly or not exported' 1>&2 | 24 echo '$GOROOT is not set correctly or not exported' 1>&2 |
15 exit 1 | 25 exit 1 |
16 fi | 26 fi |
17 | 27 |
18 if ! test -d "$GOBIN" | |
19 then | |
20 echo '$GOBIN is not a directory or does not exist' 1>&2 | |
21 echo 'create it or set $GOBIN differently' 1>&2 | |
22 exit 1 | |
23 fi | |
24 | |
25 case "$GOARCH" in | 28 case "$GOARCH" in |
26 amd64 | 386 | arm) | 29 amd64 | 386 | arm) |
27 ;; | 30 ;; |
28 *) | 31 *) |
29 echo '$GOARCH is set to <'$GOARCH'>, must be amd64, 386, or arm' 1>&2 | 32 echo '$GOARCH is set to <'$GOARCH'>, must be amd64, 386, or arm' 1>&2 |
30 exit 1 | 33 exit 1 |
31 esac | 34 esac |
32 | 35 |
33 case "$GOOS" in | 36 case "$GOOS" in |
34 darwin | freebsd | linux | mingw | nacl) | 37 darwin | freebsd | linux | mingw | nacl) |
35 ;; | 38 ;; |
36 *) | 39 *) |
37 echo '$GOOS is set to <'$GOOS'>, must be darwin, freebsd, linux, mingw,
or nacl' 1>&2 | 40 echo '$GOOS is set to <'$GOOS'>, must be darwin, freebsd, linux, mingw,
or nacl' 1>&2 |
38 exit 1 | 41 exit 1 |
39 esac | 42 esac |
40 | 43 |
41 rm -f "$GOBIN"/quietgcc | 44 rm -f "$GOBIN"/quietgcc |
42 CC=${CC:-gcc} | 45 CC=${CC:-gcc} |
43 sed -e "s|@CC@|$CC|" < quietgcc.bash > "$GOBIN"/quietgcc | 46 sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc |
44 chmod +x "$GOBIN"/quietgcc | 47 chmod +x "$GOBIN"/quietgcc |
45 | 48 |
46 rm -f "$GOBIN"/gomake | 49 rm -f "$GOBIN"/gomake |
47 MAKE=make | 50 MAKE=make |
48 if ! make --version 2>/dev/null | grep 'GNU Make' >/dev/null; then | 51 if ! make --version 2>/dev/null | grep 'GNU Make' >/dev/null; then |
49 MAKE=gmake | 52 MAKE=gmake |
50 fi | 53 fi |
51 (echo '#!/bin/sh'; echo 'exec '$MAKE' "$@"') >"$GOBIN"/gomake | 54 (echo '#!/bin/sh'; echo 'exec '$MAKE' "$@"') >"$GOBIN"/gomake |
52 chmod +x "$GOBIN"/gomake | 55 chmod +x "$GOBIN"/gomake |
53 | 56 |
54 if ! (cd lib9 && which quietgcc) >/dev/null 2>&1; then | |
55 echo "installed quietgcc as $GOBIN/quietgcc but 'which quietgcc' fails"
1>&2 | |
56 echo "double-check that $GOBIN is in your "'$PATH' 1>&2 | |
57 exit 1 | |
58 fi | |
59 | |
60 if [ -d /selinux -a -f /selinux/booleans/allow_execstack ] ; then | 57 if [ -d /selinux -a -f /selinux/booleans/allow_execstack ] ; then |
61 if ! cat /selinux/booleans/allow_execstack | grep -c '^1 1$' >> /dev/nul
l ; then | 58 if ! cat /selinux/booleans/allow_execstack | grep -c '^1 1$' >> /dev/nul
l ; then |
62 echo "WARNING: the default SELinux policy on, at least, Fedora 1
2 breaks " | 59 echo "WARNING: the default SELinux policy on, at least, Fedora 1
2 breaks " |
63 echo "Go. You can enable the features that Go needs via the foll
owing " | 60 echo "Go. You can enable the features that Go needs via the foll
owing " |
64 echo "command (as root):" | 61 echo "command (as root):" |
65 echo " # setsebool -P allow_execstack 1" | 62 echo " # setsebool -P allow_execstack 1" |
66 echo | 63 echo |
67 echo "Note that this affects your system globally! " | 64 echo "Note that this affects your system globally! " |
68 echo | 65 echo |
69 echo "The build will continue in five seconds in case we " | 66 echo "The build will continue in five seconds in case we " |
70 echo "misdiagnosed the issue..." | 67 echo "misdiagnosed the issue..." |
71 | 68 |
72 sleep 5 | 69 sleep 5 |
73 fi | 70 fi |
74 fi | 71 fi |
75 | 72 |
76 ( | 73 ( |
77 » cd pkg; | 74 » cd "$GOROOT"/src/pkg; |
78 bash deps.bash # do this here so clean.bash will work in the pkg direct
ory | 75 bash deps.bash # do this here so clean.bash will work in the pkg direct
ory |
79 ) | 76 ) |
80 bash clean.bash | 77 bash "$GOROOT"/src/clean.bash |
81 | 78 |
82 for i in lib9 libbio libmach cmd pkg libcgo cmd/cgo cmd/ebnflint cmd/godoc cmd/g
ofmt cmd/goyacc cmd/hgpatch | 79 for i in lib9 libbio libmach cmd pkg libcgo cmd/cgo cmd/ebnflint cmd/godoc cmd/g
ofmt cmd/goyacc cmd/hgpatch |
83 do | 80 do |
84 case "$i-$GOOS" in | 81 case "$i-$GOOS" in |
85 libcgo-nacl | cmd/*-nacl) | 82 libcgo-nacl | cmd/*-nacl) |
86 ;; | 83 ;; |
87 *) | 84 *) |
88 # The ( ) here are to preserve the current directory | 85 # The ( ) here are to preserve the current directory |
89 # for the next round despite the cd $i below. | 86 # for the next round despite the cd $i below. |
90 # set -e does not apply to ( ) so we must explicitly | 87 # set -e does not apply to ( ) so we must explicitly |
91 # test the exit status. | 88 # test the exit status. |
92 ( | 89 ( |
93 echo; echo; echo %%%% making $i %%%%; echo | 90 echo; echo; echo %%%% making $i %%%%; echo |
94 » » » cd $i | 91 » » » cd "$GOROOT"/src/$i |
95 case $i in | 92 case $i in |
96 cmd) | 93 cmd) |
97 bash make.bash | 94 bash make.bash |
98 ;; | 95 ;; |
99 pkg) | 96 pkg) |
100 » » » » gomake install | 97 » » » » "$GOBIN"/gomake install |
101 ;; | 98 ;; |
102 *) | 99 *) |
103 » » » » gomake install | 100 » » » » "$GOBIN"/gomake install |
104 esac | 101 esac |
105 ) || exit 1 | 102 ) || exit 1 |
106 esac | 103 esac |
107 done | 104 done |
108 | 105 |
109 case "`uname`" in | 106 case "`uname`" in |
110 Darwin) | 107 Darwin) |
111 echo; | 108 echo; |
112 echo %%% run sudo.bash to install debuggers | 109 echo %%% run sudo.bash to install debuggers |
113 echo | 110 echo |
114 esac | 111 esac |
OLD | NEW |