2010-03-31 20:48:33 -06:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# 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.
|
|
|
|
|
2011-04-23 12:34:08 -06:00
|
|
|
# If set to a Windows-style path convert to an MSYS-Unix
|
|
|
|
# one using the built-in shell commands.
|
|
|
|
if [[ "$GOROOT" == *:* ]]; then
|
|
|
|
GOROOT=$(cd "$GOROOT"; pwd)
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$GOBIN" == *:* ]]; then
|
|
|
|
GOBIN=$(cd "$GOBIN"; pwd)
|
|
|
|
fi
|
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
export GOROOT=${GOROOT:-$(cd ..; pwd)}
|
2010-03-31 20:48:33 -06:00
|
|
|
|
|
|
|
if ! test -f "$GOROOT"/include/u.h
|
|
|
|
then
|
2010-08-18 08:08:49 -06:00
|
|
|
echo '$GOROOT is not set correctly or not exported: '$GOROOT 1>&2
|
2010-03-31 20:48:33 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Double-check that we're in $GOROOT, for people with multiple Go trees.
|
|
|
|
# Various aspects of the build cd into $GOROOT-rooted paths,
|
|
|
|
# making it easy to jump to a different tree and get confused.
|
|
|
|
DIR1=$(cd ..; pwd)
|
2010-09-21 00:43:31 -06:00
|
|
|
DIR2=$(cd "$GOROOT"; pwd)
|
2010-03-31 20:48:33 -06:00
|
|
|
if [ "$DIR1" != "$DIR2" ]; then
|
2010-11-05 21:04:08 -06:00
|
|
|
echo 'Suspicious $GOROOT '"$GOROOT"': does not match current directory.' 1>&2
|
2010-03-31 20:48:33 -06:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-08-24 18:00:33 -06:00
|
|
|
export GOBIN=${GOBIN:-"$GOROOT/bin"}
|
2010-09-02 12:20:02 -06:00
|
|
|
if [ ! -d "$GOBIN" -a "$GOBIN" != "$GOROOT/bin" ]; then
|
2010-08-24 18:00:33 -06:00
|
|
|
echo '$GOBIN is not a directory or does not exist' 1>&2
|
|
|
|
echo 'create it or set $GOBIN differently' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export OLDPATH=$PATH
|
2011-06-13 13:28:54 -06:00
|
|
|
export PATH="$GOBIN":$PATH
|
2010-08-24 18:00:33 -06:00
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
MAKE=make
|
|
|
|
if ! make --version 2>/dev/null | grep 'GNU Make' >/dev/null; then
|
|
|
|
MAKE=gmake
|
|
|
|
fi
|
2010-03-31 20:48:33 -06:00
|
|
|
|
2011-06-13 13:28:54 -06:00
|
|
|
PROGS="
|
|
|
|
ar
|
|
|
|
awk
|
|
|
|
bash
|
|
|
|
bison
|
|
|
|
chmod
|
|
|
|
cp
|
|
|
|
cut
|
|
|
|
echo
|
|
|
|
egrep
|
|
|
|
gcc
|
|
|
|
grep
|
|
|
|
ls
|
2011-11-11 12:56:18 -07:00
|
|
|
$MAKE
|
2011-06-13 13:28:54 -06:00
|
|
|
mkdir
|
|
|
|
mv
|
|
|
|
pwd
|
|
|
|
rm
|
|
|
|
sed
|
|
|
|
sort
|
|
|
|
tee
|
|
|
|
touch
|
|
|
|
tr
|
|
|
|
true
|
|
|
|
uname
|
|
|
|
uniq
|
|
|
|
"
|
|
|
|
|
2011-06-27 12:30:02 -06:00
|
|
|
for i in $PROGS; do
|
2011-06-13 13:28:54 -06:00
|
|
|
if ! which $i >/dev/null 2>&1; then
|
|
|
|
echo "Cannot find '$i' on search path." 1>&2
|
|
|
|
echo "See http://golang.org/doc/install.html#ctools" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if bison --version 2>&1 | grep 'bison++' >/dev/null 2>&1; then
|
|
|
|
echo "Your system's 'bison' is bison++."
|
|
|
|
echo "Go needs the original bison instead." 1>&2
|
|
|
|
echo "See http://golang.org/doc/install.html#ctools" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2011-07-27 15:38:39 -06:00
|
|
|
# Issue 2020: some users configure bash to default to
|
2011-07-28 17:38:14 -06:00
|
|
|
# set -o noclobber
|
2011-07-27 15:38:39 -06:00
|
|
|
# which makes >x fail if x already exists. Restore sanity.
|
2011-07-28 17:38:14 -06:00
|
|
|
set +o noclobber
|
2011-07-27 15:38:39 -06:00
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
# Tried to use . <($MAKE ...) here, but it cannot set environment
|
|
|
|
# variables in the version of bash that ships with OS X. Amazing.
|
2011-02-08 18:37:08 -07:00
|
|
|
eval $($MAKE --no-print-directory -f Make.inc go-env | egrep 'GOARCH|GOOS|GOHOSTARCH|GOHOSTOS|GO_ENV')
|
2010-03-31 20:48:33 -06:00
|
|
|
|
2010-08-18 08:08:49 -06:00
|
|
|
# Shell doesn't tell us whether make succeeded,
|
|
|
|
# so Make.inc generates a fake variable name.
|
|
|
|
if [ "$MAKE_GO_ENV_WORKED" != 1 ]; then
|
|
|
|
echo 'Did not find Go environment variables.' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
unset MAKE_GO_ENV_WORKED
|