2009-11-14 16:29:09 -07:00
|
|
|
#!/usr/bin/env bash
|
2008-06-11 14:34:08 -06:00
|
|
|
# Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style
|
|
|
|
# license that can be found in the LICENSE file.
|
|
|
|
|
2008-09-18 16:06:43 -06:00
|
|
|
set -e
|
2010-08-18 08:08:49 -06:00
|
|
|
if [ ! -f env.bash ]; then
|
|
|
|
echo 'make.bash must be run from $GOROOT/src' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-03-31 20:48:33 -06:00
|
|
|
. ./env.bash
|
2009-12-11 16:14:09 -07:00
|
|
|
|
2011-10-13 10:25:25 -06:00
|
|
|
if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then
|
2011-03-18 16:23:00 -06:00
|
|
|
echo 'ERROR: Your system has gold 2.20 installed.'
|
|
|
|
echo 'This version is shipped by Ubuntu even though'
|
|
|
|
echo 'it is known not to work on Ubuntu.'
|
|
|
|
echo 'Binaries built with this linker are likely to fail in mysterious ways.'
|
|
|
|
echo
|
|
|
|
echo 'Run sudo apt-get remove binutils-gold.'
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-09-02 12:20:02 -06:00
|
|
|
# Create target directories
|
2012-01-29 10:19:05 -07:00
|
|
|
mkdir -p "$GOROOT/bin/go-tool"
|
2010-09-02 12:20:02 -06:00
|
|
|
mkdir -p "$GOROOT/pkg"
|
|
|
|
|
2012-01-29 10:19:05 -07:00
|
|
|
# Remove old, pre-go-tool binaries.
|
|
|
|
rm -f "$GOROOT"/bin/[568][acgl]
|
|
|
|
rm -f "$GOROOT"/bin/{6cov,6nm,cgo,ebnflint,goapi,gofix,goinstall,gomake,gopack,gopprof,gotest,gotype,govet,goyacc,hgpatch,quietgcc}
|
|
|
|
|
|
|
|
# If GOBIN is set and it has a Go compiler, it must also be cleaned.
|
|
|
|
if [ -n "GOBIN" ]; then
|
|
|
|
if [ -x "$GOBIN"/5g -o -x "$GOBIN"/6g -o -x "$GOBIN"/8g ]; then
|
|
|
|
rm -f "$GOBIN"/[568][acgl]
|
|
|
|
rm -f "$GOBIN"/{6cov,6nm,cgo,ebnflint,goapi,gofix,goinstall,gomake,gopack,gopprof,gotest,gotype,govet,goyacc,hgpatch,quietgcc}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT}
|
|
|
|
|
2010-05-15 11:08:29 -06:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:-"-j4"}
|
|
|
|
export MAKEFLAGS
|
2009-11-24 17:01:35 -07:00
|
|
|
unset CDPATH # in case user has it set
|
|
|
|
|
2009-11-23 18:32:51 -07:00
|
|
|
rm -f "$GOBIN"/quietgcc
|
2009-11-01 17:13:37 -07:00
|
|
|
CC=${CC:-gcc}
|
2010-07-15 15:15:39 -06:00
|
|
|
export CC
|
2009-12-11 16:14:09 -07:00
|
|
|
sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc
|
2009-11-23 18:32:51 -07:00
|
|
|
chmod +x "$GOBIN"/quietgcc
|
2008-11-19 13:54:44 -07:00
|
|
|
|
2009-11-23 18:32:51 -07:00
|
|
|
rm -f "$GOBIN"/gomake
|
2010-08-18 08:08:49 -06:00
|
|
|
(
|
|
|
|
echo '#!/bin/sh'
|
|
|
|
echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}'
|
|
|
|
echo 'exec '$MAKE' "$@"'
|
|
|
|
) >"$GOBIN"/gomake
|
2009-11-23 18:32:51 -07:00
|
|
|
chmod +x "$GOBIN"/gomake
|
2009-11-14 16:29:09 -07:00
|
|
|
|
2011-11-11 14:41:37 -07:00
|
|
|
# on Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux,
|
|
|
|
# so loop through the possible selinux mount points
|
|
|
|
for se_mount in /selinux /sys/fs/selinux
|
|
|
|
do
|
|
|
|
if [ -d $se_mount -a -f $se_mount/booleans/allow_execstack -a -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
|
|
|
|
if ! cat $se_mount/booleans/allow_execstack | grep -c '^1 1$' >> /dev/null ; then
|
|
|
|
echo "WARNING: the default SELinux policy on, at least, Fedora 12 breaks "
|
|
|
|
echo "Go. You can enable the features that Go needs via the following "
|
|
|
|
echo "command (as root):"
|
|
|
|
echo " # setsebool -P allow_execstack 1"
|
|
|
|
echo
|
|
|
|
echo "Note that this affects your system globally! "
|
|
|
|
echo
|
|
|
|
echo "The build will continue in five seconds in case we "
|
|
|
|
echo "misdiagnosed the issue..."
|
2009-11-11 16:02:15 -07:00
|
|
|
|
2011-11-11 14:41:37 -07:00
|
|
|
sleep 5
|
|
|
|
fi
|
2009-11-11 16:02:15 -07:00
|
|
|
fi
|
2011-11-11 14:41:37 -07:00
|
|
|
done
|
2009-11-11 16:02:15 -07:00
|
|
|
|
2011-12-21 13:57:47 -07:00
|
|
|
$USE_GO_TOOL ||
|
2009-11-24 22:07:05 -07:00
|
|
|
(
|
2009-12-11 16:14:09 -07:00
|
|
|
cd "$GOROOT"/src/pkg;
|
2009-11-24 22:07:05 -07:00
|
|
|
bash deps.bash # do this here so clean.bash will work in the pkg directory
|
2011-10-14 13:54:36 -06:00
|
|
|
) || exit 1
|
2009-12-11 16:14:09 -07:00
|
|
|
bash "$GOROOT"/src/clean.bash
|
2009-11-10 20:20:34 -07:00
|
|
|
|
2012-01-19 15:13:33 -07:00
|
|
|
# pkg builds runtime/cgo and the Go programs in cmd.
|
2011-12-19 13:51:13 -07:00
|
|
|
for i in lib9 libbio libmach cmd
|
2009-06-22 16:43:50 -06:00
|
|
|
do
|
2011-02-28 15:20:32 -07:00
|
|
|
echo; echo; echo %%%% making $i %%%%; echo
|
|
|
|
gomake -C $i install
|
2009-06-22 16:43:50 -06:00
|
|
|
done
|
2008-09-11 14:03:46 -06:00
|
|
|
|
2011-12-19 13:51:13 -07:00
|
|
|
echo; echo; echo %%%% making runtime generated files %%%%; echo
|
|
|
|
|
2011-12-20 14:50:13 -07:00
|
|
|
(
|
|
|
|
cd "$GOROOT"/src/pkg/runtime
|
|
|
|
./autogen.sh
|
2011-12-21 05:47:12 -07:00
|
|
|
gomake install; gomake clean # copy runtime.h to pkg directory
|
2011-12-20 14:50:13 -07:00
|
|
|
) || exit 1
|
|
|
|
|
|
|
|
if $USE_GO_TOOL; then
|
|
|
|
echo
|
cmd/go: implement go get + bug fixes
Move error information into Package struct, so that
a package can be returned even if a dependency failed
to load or did not exist. This makes it possible to run
'go fix' or 'go fmt' on packages with broken dependencies
or missing imports. It also enables go get -fix.
The new go list -e flag lets go list process those package
errors as normal data.
Change p.Doc to be first sentence of package doc, not
entire package doc. Makes go list -json or
go list -f '{{.ImportPath}} {{.Doc}}' much more reasonable.
The go tool now depends on http, which means also
net and crypto/tls, both of which use cgo. Trying to
make the build scripts that build the go tool understand
and handle cgo is too much work. Instead, we build
a stripped down version of the go tool, compiled as go_bootstrap,
that substitutes an error stub for the usual HTTP code.
The buildscript builds go_bootstrap, go_bootstrap builds
the standard packages and commands, including the full
including-HTTP-support go tool, and then go_bootstrap
gets deleted.
Also handle the case where the buildscript needs updating
during all.bash: if it fails but a go command can be found on
the current $PATH, try to regenerate it. This gracefully
handles situations like adding a new file to a package
used by the go tool.
R=r, adg
CC=golang-dev
https://golang.org/cl/5553059
2012-01-23 13:16:51 -07:00
|
|
|
echo '# Building go_bootstrap command from bootstrap script.'
|
|
|
|
if ! ./buildscript/${GOOS}_$GOARCH.sh; then
|
|
|
|
echo '# Bootstrap script failed.'
|
|
|
|
if [ ! -x "$GOBIN/go" ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo '# Regenerating bootstrap script using pre-existing go binary.'
|
|
|
|
./buildscript.sh
|
|
|
|
./buildscript/${GOOS}_$GOARCH.sh
|
|
|
|
fi
|
2011-12-20 14:50:13 -07:00
|
|
|
|
|
|
|
echo '# Building Go code.'
|
cmd/go: implement go get + bug fixes
Move error information into Package struct, so that
a package can be returned even if a dependency failed
to load or did not exist. This makes it possible to run
'go fix' or 'go fmt' on packages with broken dependencies
or missing imports. It also enables go get -fix.
The new go list -e flag lets go list process those package
errors as normal data.
Change p.Doc to be first sentence of package doc, not
entire package doc. Makes go list -json or
go list -f '{{.ImportPath}} {{.Doc}}' much more reasonable.
The go tool now depends on http, which means also
net and crypto/tls, both of which use cgo. Trying to
make the build scripts that build the go tool understand
and handle cgo is too much work. Instead, we build
a stripped down version of the go tool, compiled as go_bootstrap,
that substitutes an error stub for the usual HTTP code.
The buildscript builds go_bootstrap, go_bootstrap builds
the standard packages and commands, including the full
including-HTTP-support go tool, and then go_bootstrap
gets deleted.
Also handle the case where the buildscript needs updating
during all.bash: if it fails but a go command can be found on
the current $PATH, try to regenerate it. This gracefully
handles situations like adding a new file to a package
used by the go tool.
R=r, adg
CC=golang-dev
https://golang.org/cl/5553059
2012-01-23 13:16:51 -07:00
|
|
|
go_bootstrap install -a -v std
|
|
|
|
rm -f "$GOBIN/go_bootstrap"
|
|
|
|
|
2011-12-20 14:50:13 -07:00
|
|
|
else
|
|
|
|
echo; echo; echo %%%% making pkg %%%%; echo
|
|
|
|
gomake -C pkg install
|
|
|
|
fi
|
2011-12-19 13:51:13 -07:00
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
# Print post-install messages.
|
|
|
|
# Implemented as a function so that all.bash can repeat the output
|
|
|
|
# after run.bash finishes running all the tests.
|
|
|
|
installed() {
|
2010-12-13 13:50:57 -07:00
|
|
|
eval $(gomake --no-print-directory -f Make.inc go-env)
|
2008-11-18 11:08:46 -07:00
|
|
|
echo
|
2010-08-18 08:08:49 -06:00
|
|
|
echo ---
|
|
|
|
echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
|
|
|
|
echo Installed commands in "$GOBIN".
|
2010-08-24 18:00:33 -06:00
|
|
|
case "$OLDPATH" in
|
2010-10-24 23:38:48 -06:00
|
|
|
"$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
|
2010-08-24 18:00:33 -06:00
|
|
|
;;
|
|
|
|
*)
|
2010-08-24 18:43:31 -06:00
|
|
|
echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
|
2010-08-24 18:00:33 -06:00
|
|
|
esac
|
2010-08-18 08:08:49 -06:00
|
|
|
echo The compiler is $GC.
|
|
|
|
if [ "$(uname)" = "Darwin" ]; then
|
|
|
|
echo
|
|
|
|
echo On OS X the debuggers must be installed setgrp procmod.
|
|
|
|
echo Read and run ./sudo.bash to install the debuggers.
|
|
|
|
fi
|
|
|
|
if [ "$GOROOT_FINAL" != "$GOROOT" ]; then
|
|
|
|
echo
|
|
|
|
echo The binaries expect "$GOROOT" to be copied or moved to "$GOROOT_FINAL".
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
(installed) # run in sub-shell to avoid polluting environment
|
|
|
|
|