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
|
2012-02-03 22:54:08 -07:00
|
|
|
if [ ! -f run.bash ]; then
|
2010-08-18 08:08:49 -06:00
|
|
|
echo 'make.bash must be run from $GOROOT/src' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-12-11 16:14:09 -07:00
|
|
|
|
2012-02-12 21:14:37 -07:00
|
|
|
# Test for Windows.
|
|
|
|
case "$(uname)" in
|
|
|
|
*MINGW* | *WIN32* | *CYGWIN*)
|
|
|
|
echo 'ERROR: Do not use make.bash to build on Windows.'
|
|
|
|
echo 'Use make.bat instead.'
|
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
# Test for bad ld.
|
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
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
# Test for bad SELinux.
|
|
|
|
# On Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux,
|
|
|
|
# so loop through the possible selinux mount points.
|
2011-11-11 14:41:37 -07:00
|
|
|
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
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
# Finally! Run the build.
|
2011-12-20 14:50:13 -07:00
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
echo '# Building C bootstrap tool.'
|
2012-02-12 21:14:37 -07:00
|
|
|
echo cmd/dist
|
2012-02-03 22:54:08 -07:00
|
|
|
mkdir -p ../bin/tool
|
2012-02-09 15:47:12 -07:00
|
|
|
export GOROOT="$(cd .. && pwd)"
|
|
|
|
GOROOT_FINAL="${GOROOT_FINAL:-$GOROOT}"
|
|
|
|
DEFGOROOT='-DGOROOT_FINAL="'"$GOROOT_FINAL"'"'
|
2012-02-13 20:31:51 -07:00
|
|
|
gcc -O2 -Wall -Werror -ggdb -o cmd/dist/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c
|
|
|
|
eval $(./cmd/dist/dist env)
|
2012-01-30 21:43:46 -07:00
|
|
|
echo
|
2011-12-19 13:51:13 -07:00
|
|
|
|
2012-02-06 11:48:43 -07:00
|
|
|
if [ "$1" = "--dist-tool" ]; then
|
|
|
|
# Stop after building dist tool.
|
2012-02-13 20:31:51 -07:00
|
|
|
mv cmd/dist/dist $GOTOOLDIR/dist
|
2012-02-06 11:48:43 -07:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-02-13 20:31:51 -07:00
|
|
|
echo "# Building compilers and Go bootstrap tool for host, $GOHOSTOS/$GOHOSTARCH."
|
|
|
|
./cmd/dist/dist bootstrap -a -v # builds go_bootstrap
|
|
|
|
# Delay move of dist tool to now, because bootstrap cleared tool directory.
|
|
|
|
mv cmd/dist/dist $GOTOOLDIR/dist
|
|
|
|
$GOTOOLDIR/go_bootstrap clean -i std
|
2012-02-03 22:54:08 -07:00
|
|
|
echo
|
2010-08-18 08:08:49 -06:00
|
|
|
|
2012-02-13 20:31:51 -07:00
|
|
|
if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
|
|
|
|
echo "# Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
|
|
|
|
GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
|
|
|
|
$GOTOOLDIR/go_bootstrap install -v std
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "# Building packages and commands for $GOOS/$GOARCH."
|
|
|
|
$GOTOOLDIR/go_bootstrap install -v std
|
2012-02-03 22:54:08 -07:00
|
|
|
echo
|
2010-08-18 08:08:49 -06:00
|
|
|
|
2012-02-13 20:31:51 -07:00
|
|
|
rm -f $GOTOOLDIR/go_bootstrap
|
|
|
|
|
2012-02-03 22:54:08 -07:00
|
|
|
if [ "$1" != "--no-banner" ]; then
|
2012-02-13 20:31:51 -07:00
|
|
|
$GOTOOLDIR/dist banner
|
2012-02-03 22:54:08 -07:00
|
|
|
fi
|