blob: 60162045ede4b077275631489a0eaa0ffe1434d9 [file] [log] [blame]
Anthony Martin38590322012-05-01 22:32:46 -07001#!/bin/rc -e
2# Copyright 2012 The Go Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file.
5
David du Colombierb46b9422015-01-13 08:01:18 +01006# See golang.org/s/go15bootstrap for an overview of the build process.
7
Anthony Martin38590322012-05-01 22:32:46 -07008# Environment variables that control make.rc:
9#
10# GOROOT_FINAL: The expected final Go root, baked into binaries.
11# The default is the location of the Go tree during the build.
12#
13# GOHOSTARCH: The architecture for host tools (compilers and
14# binaries). Binaries of this type must be executable on the current
15# system, so the only common reason to set this is to set
16# GOHOSTARCH=386 on an amd64 machine.
17#
18# GOARCH: The target architecture for installed packages and tools.
19#
20# GOOS: The target operating system for installed packages and tools.
21#
Jeremy Jackins73549782015-05-28 16:13:23 +090022# GO_GCFLAGS: Additional go tool compile arguments to use when
Anthony Martin38590322012-05-01 22:32:46 -070023# building the packages and commands.
24#
Jeremy Jackins73549782015-05-28 16:13:23 +090025# GO_LDFLAGS: Additional go tool link arguments to use when
Anthony Martin38590322012-05-01 22:32:46 -070026# building the commands.
27#
Anthony Martinf08acae2013-02-26 09:25:46 -080028# CGO_ENABLED: Controls cgo usage during the build. Set it to 1
29# to include all cgo related files, .c and .go file with "cgo"
30# build directive, in the build. Set it to 0 to ignore them.
Anthony Martin38590322012-05-01 22:32:46 -070031
32rfork e
Anthony Martinf08acae2013-02-26 09:25:46 -080033if(! test -f run.rc){
Anthony Martin38590322012-05-01 22:32:46 -070034 echo 'make.rc must be run from $GOROOT/src' >[1=2]
35 exit wrongdir
36}
37
38# Clean old generated file that will cause problems in the build.
Russ Cox220a6de2014-09-08 00:06:45 -040039rm -f ./runtime/runtime_defs.go
Anthony Martin38590322012-05-01 22:32:46 -070040
41# Determine the host compiler toolchain.
42eval `{grep '^(CC|LD|O)=' /$objtype/mkfile}
43
Jeremy Jackins73549782015-05-28 16:13:23 +090044echo '##### Building Go bootstrap tool.'
Anthony Martin38590322012-05-01 22:32:46 -070045echo cmd/dist
46GOROOT = `{cd .. && pwd}
David du Colombierb46b9422015-01-13 08:01:18 +010047if(! ~ $#GOROOT_BOOTSTRAP 1)
48 GOROOT_BOOTSTRAP = $home/go1.4
49if(! test -x $GOROOT_BOOTSTRAP/bin/go){
50 echo 'ERROR: Cannot find '$GOROOT_BOOTSTRAP'/bin/go.' >[1=2]
51 echo 'Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.' >[1=2]
52 exit bootstrap
53}
54rm -f cmd/dist/dist
Russ Cox1fac6d12015-01-14 15:14:54 -050055GOROOT=$GOROOT_BOOTSTRAP GOOS='' GOARCH='' $GOROOT_BOOTSTRAP/bin/go build -o cmd/dist/dist ./cmd/dist
Anthony Martin38590322012-05-01 22:32:46 -070056
57eval `{./cmd/dist/dist env -9}
58echo
59
60if(~ $1 --dist-tool){
61 # Stop after building dist tool.
62 mkdir -p $GOTOOLDIR
63 if(! ~ $2 '')
64 cp cmd/dist/dist $2
65 mv cmd/dist/dist $GOTOOLDIR/dist
66 exit
67}
68
Anthony Martin38590322012-05-01 22:32:46 -070069buildall = -a
70if(~ $1 --no-clean)
71 buildall = ()
72./cmd/dist/dist bootstrap $buildall -v # builds go_bootstrap
73# Delay move of dist tool to now, because bootstrap may clear tool directory.
74mv cmd/dist/dist $GOTOOLDIR/dist
Anthony Martin38590322012-05-01 22:32:46 -070075echo
76
Anthony Martinf08acae2013-02-26 09:25:46 -080077# Run only one process at a time on 9vx.
78if(~ $sysname vx32)
79 pflag = (-p 1)
Anthony Martin38590322012-05-01 22:32:46 -070080
81if(! ~ $GOHOSTARCH $GOARCH || ! ~ $GOHOSTOS $GOOS){
Jeremy Jackins73549782015-05-28 16:13:23 +090082 echo '##### Building packages and commands for host,' $GOHOSTOS/$GOHOSTARCH^.
Anthony Martin38590322012-05-01 22:32:46 -070083 GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
Russ Cox096b2942015-02-22 12:41:32 -050084 $GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd
Anthony Martin38590322012-05-01 22:32:46 -070085 echo
86}
87
Jeremy Jackins73549782015-05-28 16:13:23 +090088echo '##### Building packages and commands for' $GOOS/$GOARCH^.
Russ Cox096b2942015-02-22 12:41:32 -050089$GOTOOLDIR/go_bootstrap install -gcflags $"GO_GCFLAGS -ldflags $"GO_LDFLAGS -v $pflag std cmd
Anthony Martin38590322012-05-01 22:32:46 -070090echo
91
92rm -f $GOTOOLDIR/go_bootstrap
93
94if(! ~ $1 --no-banner)
95 $GOTOOLDIR/dist banner
David du Colombierffe8a3c2013-05-24 13:55:19 -070096
97status=''