2012-05-01 23:32:46 -06:00
|
|
|
#!/bin/rc -e
|
|
|
|
# Copyright 2012 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.
|
|
|
|
|
2015-01-13 00:01:18 -07:00
|
|
|
# See golang.org/s/go15bootstrap for an overview of the build process.
|
|
|
|
|
2012-05-01 23:32:46 -06:00
|
|
|
# Environment variables that control make.rc:
|
|
|
|
#
|
|
|
|
# GOROOT_FINAL: The expected final Go root, baked into binaries.
|
|
|
|
# The default is the location of the Go tree during the build.
|
|
|
|
#
|
|
|
|
# GOHOSTARCH: The architecture for host tools (compilers and
|
|
|
|
# binaries). Binaries of this type must be executable on the current
|
|
|
|
# system, so the only common reason to set this is to set
|
|
|
|
# GOHOSTARCH=386 on an amd64 machine.
|
|
|
|
#
|
|
|
|
# GOARCH: The target architecture for installed packages and tools.
|
|
|
|
#
|
|
|
|
# GOOS: The target operating system for installed packages and tools.
|
|
|
|
#
|
2015-05-28 01:13:23 -06:00
|
|
|
# GO_GCFLAGS: Additional go tool compile arguments to use when
|
2012-05-01 23:32:46 -06:00
|
|
|
# building the packages and commands.
|
|
|
|
#
|
2015-05-28 01:13:23 -06:00
|
|
|
# GO_LDFLAGS: Additional go tool link arguments to use when
|
2012-05-01 23:32:46 -06:00
|
|
|
# building the commands.
|
|
|
|
#
|
2013-02-26 10:25:46 -07:00
|
|
|
# CGO_ENABLED: Controls cgo usage during the build. Set it to 1
|
|
|
|
# to include all cgo related files, .c and .go file with "cgo"
|
|
|
|
# build directive, in the build. Set it to 0 to ignore them.
|
2012-05-01 23:32:46 -06:00
|
|
|
|
|
|
|
rfork e
|
2013-02-26 10:25:46 -07:00
|
|
|
if(! test -f run.rc){
|
2012-05-01 23:32:46 -06:00
|
|
|
echo 'make.rc must be run from $GOROOT/src' >[1=2]
|
|
|
|
exit wrongdir
|
|
|
|
}
|
|
|
|
|
|
|
|
# Clean old generated file that will cause problems in the build.
|
2014-09-07 22:06:45 -06:00
|
|
|
rm -f ./runtime/runtime_defs.go
|
2012-05-01 23:32:46 -06:00
|
|
|
|
|
|
|
# Determine the host compiler toolchain.
|
|
|
|
eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
|
|
|
|
|
2017-10-28 07:00:35 -06:00
|
|
|
vflag=()
|
|
|
|
if(~ $1 -v) {
|
|
|
|
vflag=(-v)
|
|
|
|
shift
|
|
|
|
}
|
|
|
|
|
2022-12-09 13:09:46 -07:00
|
|
|
fn nogoenv {
|
|
|
|
GO111MODULE=off GOENV=off GOOS=() GOARCH=() GOEXPERIMENT=() GOFLAGS=() $*
|
|
|
|
}
|
|
|
|
|
2023-07-23 03:21:31 -06:00
|
|
|
bootgo = 1.20.6
|
2012-05-01 23:32:46 -06:00
|
|
|
GOROOT = `{cd .. && pwd}
|
2021-09-02 13:00:01 -06:00
|
|
|
goroot_bootstrap_set = 'true'
|
|
|
|
if(! ~ $#GOROOT_BOOTSTRAP 1){
|
|
|
|
goroot_bootstrap_set = 'false'
|
2015-01-13 00:01:18 -07:00
|
|
|
GOROOT_BOOTSTRAP = $home/go1.4
|
2022-10-05 19:13:08 -06:00
|
|
|
for(d in sdk/go$bootgo go$bootgo)
|
2021-12-06 11:36:42 -07:00
|
|
|
if(test -d $home/$d)
|
|
|
|
GOROOT_BOOTSTRAP = $home/$d
|
2021-09-02 13:00:01 -06:00
|
|
|
}
|
2017-08-21 23:36:19 -06:00
|
|
|
for(p in $path){
|
|
|
|
if(! test -x $GOROOT_BOOTSTRAP/bin/go){
|
|
|
|
if(go_exe = `{path=$p whatis go}){
|
2022-12-09 13:09:46 -07:00
|
|
|
goroot = `{GOROOT=() nogoenv $go_exe env GOROOT}
|
2017-08-21 23:36:19 -06:00
|
|
|
if(! ~ $goroot $GOROOT){
|
2021-09-02 13:00:01 -06:00
|
|
|
if(~ $goroot_bootstrap_set 'true'){
|
|
|
|
echo 'WARNING: '$GOROOT_BOOTSTRAP'/bin/go does not exist, found '$go_exe' from env' >[1=2]
|
|
|
|
echo 'WARNING: set '$goroot' as GOROOT_BOOTSTRAP' >[1=2]
|
|
|
|
}
|
2017-08-21 23:36:19 -06:00
|
|
|
GOROOT_BOOTSTRAP = $goroot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-01-13 00:01:18 -07:00
|
|
|
if(! test -x $GOROOT_BOOTSTRAP/bin/go){
|
|
|
|
echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
|
2022-10-05 19:13:08 -06:00
|
|
|
echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
|
2015-01-13 00:01:18 -07:00
|
|
|
exit bootstrap
|
|
|
|
}
|
2017-08-21 23:36:19 -06:00
|
|
|
if(~ $GOROOT_BOOTSTRAP $GOROOT){
|
|
|
|
echo 'ERROR: $GOROOT_BOOTSTRAP must not be set to $GOROOT' >[1=2]
|
2022-10-05 19:13:08 -06:00
|
|
|
echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go '$bootgo'.' >[1=2]
|
2017-08-21 23:36:19 -06:00
|
|
|
exit bootstrap
|
|
|
|
}
|
2017-10-28 07:00:35 -06:00
|
|
|
|
2022-07-26 12:21:03 -06:00
|
|
|
# Get the exact bootstrap toolchain version to help with debugging.
|
|
|
|
# We clear GOOS and GOARCH to avoid an ominous but harmless warning if
|
|
|
|
# the bootstrap doesn't support them.
|
2022-12-09 13:09:46 -07:00
|
|
|
GOROOT_BOOTSTRAP_VERSION=`{nogoenv $GOROOT_BOOTSTRAP/bin/go version | sed 's/go version //'}
|
2022-07-26 12:21:03 -06:00
|
|
|
echo 'Building Go cmd/dist using '$GOROOT_BOOTSTRAP'. ('$"GOROOT_BOOTSTRAP_VERSION')'
|
2017-10-28 07:00:35 -06:00
|
|
|
if(~ $#vflag 1)
|
|
|
|
echo cmd/dist
|
2022-12-09 13:09:46 -07:00
|
|
|
GOROOT=$GOROOT_BOOTSTRAP nogoenv $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
|
2012-05-01 23:32:46 -06:00
|
|
|
|
|
|
|
eval `{./cmd/dist/dist env -9}
|
2017-10-28 07:00:35 -06:00
|
|
|
if(~ $#vflag 1)
|
|
|
|
echo
|
2012-05-01 23:32:46 -06:00
|
|
|
|
|
|
|
if(~ $1 --dist-tool){
|
|
|
|
# Stop after building dist tool.
|
|
|
|
mkdir -p $GOTOOLDIR
|
|
|
|
if(! ~ $2 '')
|
|
|
|
cp cmd/dist/dist $2
|
|
|
|
mv cmd/dist/dist $GOTOOLDIR/dist
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2017-10-23 19:57:54 -06:00
|
|
|
# Run dist bootstrap to complete make.bash.
|
|
|
|
# Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
2022-08-12 10:16:47 -06:00
|
|
|
# Throw ours, built with the bootstrap toolchain, away after bootstrap.
|
2021-08-11 13:40:12 -06:00
|
|
|
./cmd/dist/dist bootstrap -a $vflag $*
|
2017-10-23 19:57:54 -06:00
|
|
|
rm -f ./cmd/dist/dist
|
2012-05-01 23:32:46 -06:00
|
|
|
|
2017-10-23 19:57:54 -06:00
|
|
|
# DO NOT ADD ANY NEW CODE HERE.
|
|
|
|
# The bootstrap+rm above are the final step of make.rc.
|
|
|
|
# If something must be added, add it to cmd/dist's cmdbootstrap,
|
|
|
|
# to avoid needing three copies in three different shell languages
|
|
|
|
# (make.bash, make.bat, make.rc).
|