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
|
|
|
|
if [ "$GOBIN" = "$GOROOT/bin" ]; then
|
|
|
|
mkdir -p "$GOROOT/bin"
|
|
|
|
fi
|
|
|
|
mkdir -p "$GOROOT/pkg"
|
|
|
|
|
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-05-03 19:16:55 -06:00
|
|
|
# TODO(brainman): delete this after 01/01/2012.
|
|
|
|
rm -f "$GOBIN"/gotest # remove old bash version of gotest on Windows
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2010-08-25 15:54:10 -06:00
|
|
|
# pkg builds libcgo 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-20 18:37:58 -07:00
|
|
|
gomake install # copy runtime.h to pkg directory
|
2011-12-20 14:50:13 -07:00
|
|
|
) || exit 1
|
|
|
|
|
|
|
|
if $USE_GO_TOOL; then
|
|
|
|
echo
|
|
|
|
echo '# Building go command from bootstrap script.'
|
|
|
|
./buildscript_${GOOS}_$GOARCH.sh
|
|
|
|
|
|
|
|
echo '# Building Go code.'
|
|
|
|
GOPATH="" go install -a all
|
|
|
|
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
|
|
|
|
|