2009-11-14 15:29:09 -08:00
|
|
|
#!/usr/bin/env bash
|
2008-06-11 13:34:08 -07: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 15:06:43 -07:00
|
|
|
set -e
|
2010-08-18 10:08:49 -04:00
|
|
|
if [ ! -f env.bash ]; then
|
|
|
|
|
echo 'make.bash must be run from $GOROOT/src' 1>&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2010-03-31 19:48:33 -07:00
|
|
|
. ./env.bash
|
2009-12-11 15:14:09 -08:00
|
|
|
|
2011-10-13 12:25:25 -04:00
|
|
|
if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then
|
2011-03-18 18:23:00 -04: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 14:20:02 -04:00
|
|
|
# Create target directories
|
|
|
|
|
if [ "$GOBIN" = "$GOROOT/bin" ]; then
|
|
|
|
|
mkdir -p "$GOROOT/bin"
|
|
|
|
|
fi
|
|
|
|
|
mkdir -p "$GOROOT/pkg"
|
|
|
|
|
|
2010-08-18 10:08:49 -04:00
|
|
|
GOROOT_FINAL=${GOROOT_FINAL:-$GOROOT}
|
|
|
|
|
|
2010-05-15 10:08:29 -07:00
|
|
|
MAKEFLAGS=${MAKEFLAGS:-"-j4"}
|
|
|
|
|
export MAKEFLAGS
|
2009-11-24 16:01:35 -08:00
|
|
|
unset CDPATH # in case user has it set
|
|
|
|
|
|
2009-11-23 17:32:51 -08:00
|
|
|
rm -f "$GOBIN"/quietgcc
|
2009-11-01 16:13:37 -08:00
|
|
|
CC=${CC:-gcc}
|
2010-07-15 14:15:39 -07:00
|
|
|
export CC
|
2009-12-11 15:14:09 -08:00
|
|
|
sed -e "s|@CC@|$CC|" < "$GOROOT"/src/quietgcc.bash > "$GOBIN"/quietgcc
|
2009-11-23 17:32:51 -08:00
|
|
|
chmod +x "$GOBIN"/quietgcc
|
2008-11-19 12:54:44 -08:00
|
|
|
|
2009-11-23 17:32:51 -08:00
|
|
|
rm -f "$GOBIN"/gomake
|
2010-08-18 10:08:49 -04:00
|
|
|
(
|
|
|
|
|
echo '#!/bin/sh'
|
|
|
|
|
echo 'export GOROOT=${GOROOT:-'$GOROOT_FINAL'}'
|
|
|
|
|
echo 'exec '$MAKE' "$@"'
|
|
|
|
|
) >"$GOBIN"/gomake
|
2009-11-23 17:32:51 -08:00
|
|
|
chmod +x "$GOBIN"/gomake
|
2009-11-14 15:29:09 -08:00
|
|
|
|
2011-05-04 11:16:55 +10:00
|
|
|
# TODO(brainman): delete this after 01/01/2012.
|
|
|
|
|
rm -f "$GOBIN"/gotest # remove old bash version of gotest on Windows
|
|
|
|
|
|
2011-11-11 16:41:37 -05: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 15:02:15 -08:00
|
|
|
|
2011-11-11 16:41:37 -05:00
|
|
|
sleep 5
|
|
|
|
|
fi
|
2009-11-11 15:02:15 -08:00
|
|
|
fi
|
2011-11-11 16:41:37 -05:00
|
|
|
done
|
2009-11-11 15:02:15 -08:00
|
|
|
|
2009-11-24 21:07:05 -08:00
|
|
|
(
|
2009-12-11 15:14:09 -08:00
|
|
|
cd "$GOROOT"/src/pkg;
|
2009-11-24 21:07:05 -08:00
|
|
|
bash deps.bash # do this here so clean.bash will work in the pkg directory
|
2011-10-14 15:54:36 -04:00
|
|
|
) || exit 1
|
2009-12-11 15:14:09 -08:00
|
|
|
bash "$GOROOT"/src/clean.bash
|
2009-11-10 19:20:34 -08:00
|
|
|
|
2010-08-25 17:54:10 -04:00
|
|
|
# pkg builds libcgo and the Go programs in cmd.
|
2011-12-19 15:51:13 -05:00
|
|
|
for i in lib9 libbio libmach cmd
|
2009-06-22 15:43:50 -07:00
|
|
|
do
|
2011-03-01 09:20:32 +11:00
|
|
|
echo; echo; echo %%%% making $i %%%%; echo
|
|
|
|
|
gomake -C $i install
|
2009-06-22 15:43:50 -07:00
|
|
|
done
|
2008-09-11 13:03:46 -07:00
|
|
|
|
2011-12-19 15:51:13 -05:00
|
|
|
echo; echo; echo %%%% making runtime generated files %%%%; echo
|
|
|
|
|
(cd "$GOROOT"/src/pkg/runtime; ./autogen.sh) || exit 1
|
|
|
|
|
|
|
|
|
|
echo; echo; echo %%%% making pkg %%%%; echo
|
|
|
|
|
gomake -C pkg install
|
|
|
|
|
|
2010-08-18 10:08:49 -04: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 15:50:57 -05:00
|
|
|
eval $(gomake --no-print-directory -f Make.inc go-env)
|
2008-11-18 10:08:46 -08:00
|
|
|
echo
|
2010-08-18 10:08:49 -04:00
|
|
|
echo ---
|
|
|
|
|
echo Installed Go for $GOOS/$GOARCH in "$GOROOT".
|
|
|
|
|
echo Installed commands in "$GOBIN".
|
2010-08-24 20:00:33 -04:00
|
|
|
case "$OLDPATH" in
|
2010-10-25 16:38:48 +11:00
|
|
|
"$GOBIN:"* | *":$GOBIN" | *":$GOBIN:"*)
|
2010-08-24 20:00:33 -04:00
|
|
|
;;
|
|
|
|
|
*)
|
2010-08-24 20:43:31 -04:00
|
|
|
echo '***' "You need to add $GOBIN to your "'$PATH.' '***'
|
2010-08-24 20:00:33 -04:00
|
|
|
esac
|
2010-08-18 10:08:49 -04: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
|
|
|
|
|
|