make.bash 2.12 KB
Newer Older
1
#!/usr/bin/env bash
2 3 4 5
# 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.

6
set -e
Russ Cox's avatar
Russ Cox committed
7
if [ ! -f run.bash ]; then
8 9 10
	echo 'make.bash must be run from $GOROOT/src' 1>&2
	exit 1
fi
11

Russ Cox's avatar
Russ Cox committed
12
# Test for bad ld.
13
if ld --version 2>&1 | grep 'gold.* 2\.20' >/dev/null; then
14 15 16 17 18 19 20 21 22 23
	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

Russ Cox's avatar
Russ Cox committed
24 25 26
# Test for bad SELinux.
# On Fedora 16 the selinux filesystem is mounted at /sys/fs/selinux,
# so loop through the possible selinux mount points.
27 28 29 30 31 32 33 34 35 36 37 38 39
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..."
40

41 42
			sleep 5
		fi
43
	fi
44
done
45

Russ Cox's avatar
Russ Cox committed
46
# Finally!  Run the build.
Russ Cox's avatar
Russ Cox committed
47

Russ Cox's avatar
Russ Cox committed
48 49
echo '# Building C bootstrap tool.'
mkdir -p ../bin/tool
Gustavo Niemeyer's avatar
Gustavo Niemeyer committed
50 51 52
export GOROOT="$(cd .. && pwd)"
GOROOT_FINAL="${GOROOT_FINAL:-$GOROOT}"
DEFGOROOT='-DGOROOT_FINAL="'"$GOROOT_FINAL"'"'
Russ Cox's avatar
Russ Cox committed
53
gcc -O2 -Wall -Werror -o ../bin/tool/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c
Russ Cox's avatar
Russ Cox committed
54
echo
55

Russ Cox's avatar
Russ Cox committed
56 57 58 59 60
if [ "$1" = "--dist-tool" ]; then
	# Stop after building dist tool.
	exit 0
fi

Russ Cox's avatar
Russ Cox committed
61 62 63
echo '# Building compilers and Go bootstrap tool.'
../bin/tool/dist bootstrap -v # builds go_bootstrap
echo
64

Russ Cox's avatar
Russ Cox committed
65 66 67 68 69
echo '# Building packages and commands.'
../bin/tool/go_bootstrap clean std
../bin/tool/go_bootstrap install -a -v std
rm -f ../bin/tool/go_bootstrap
echo
70

Russ Cox's avatar
Russ Cox committed
71 72 73
if [ "$1" != "--no-banner" ]; then
	../bin/tool/dist banner
fi